hsrv

package
v0.0.1-beta.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2025 License: BSD-3-Clause Imports: 23 Imported by: 0

README

HTTP Server

Handles the implant side of things.

Documentation

Overview

Package hsrv - HTTP server

Index

Constants

View Source
const (
	LMFileRequested = "File requested"

	LKStaticFilesDir = "static_files_dir"
)

Log messages and keys.

View Source
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"
)
View Source
const (
	LMListening               = "Listener started"
	LMOneShellClosingListener = "Got one shell, closing listener"
	LMURLPaths                = "Non-Default URL Paths"

	LKError       = "error"
	LKFingerprint = "fingerprint"
	LKListenAddr  = "address"
)

Log messages and keys.

View Source
const (
	ErrorColor     = opshell.ColorRed
	FileColor      = opshell.ColorBlue
	ScriptColor    = opshell.ColorCyan
	ConnectedColor = opshell.ColorGreen
)

Colors for log things

View Source
const ShutdownWait = 4 * time.Second

ShutdownWait is how long we wait for cilents to disconnect on shutdown.

Variables

View Source
var ErrOneShellClosed = errors.New("closed after shell received")

ErrOneShellClosed indicates that the listener was closed as expected after receiving a single shell.

Functions

func StartFullDuplex

func StartFullDuplex(w http.ResponseWriter) error

StartFullDuplex enables full duplex mode on w, if possible. This is necessary for some clients which are waiting on a go-ahead. */

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,
	tmplf string,
	ich <-chan string,
	och chan<- opshell.CLine,
	iob *iobroker.Broker,
	certFile string,
	cbAddrs []string,
	printIPv6 bool,
	oneShell bool,
	printDebug bool,
	params crstemplate.Params,
) (*Server, error)

New returns a new Server, listening on addr. Call its Do method to start it serving. tmplf is non-empty, it is taken as a file from which to read the -template template. params.StaticFilesDir and params.URLPaths may be set by the caller; all other fields will be set by New or its handlers.

func (*Server) Do

func (s *Server) Do(ctx context.Context) error

Do actually serves HTTPS clients.

func (*Server) ErrorLogf

func (s *Server) ErrorLogf(format string, v ...any)

ErrorLogf sends a error message back.

func (*Server) Logf

func (s *Server) Logf(color opshell.Color, format string, v ...any)

Logf sends a colered message to the shell.

func (*Server) Printf

func (s *Server) Printf(color opshell.Color, format string, v ...any)

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

func (s *Server) RErrorLogf(r *http.Request, format string, v ...any)

RErrorLogf sends a pink message to the shell with r's remote address.

func (*Server) RLogf

func (s *Server) RLogf(color opshell.Color, r *http.Request, format string, v ...any)

RLogf sends a colored message to the shell with the requetsor's IP address.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL