Documentation ¶
Overview ¶
Package man is the implementation of the Guardian and Sentinel structs. These can be used to guard against accidental launching of multiple processes and can determine if targets are 'alive'.
Windows clients have many options using built-in API calls, while other options such as TCP or Sockets (Named Pipes on Windows, UDS on *nix) to use generic control structs.
Sentinel is a struct that can be Marshaled/Unmashaled from a file or network stream with optional encryption capabilities. Sentinels can launch applications in may different ways, including downloading, injecting or directly executing.
Index ¶
- Constants
- Variables
- func Check(l Linker, n string) bool
- func ParseDownloadHeader(h http.Header) uint8
- type Guardian
- type Linker
- type Loader
- type Sentinel
- func (s Sentinel) Check(l Linker, n string) (bool, error)
- func (s Sentinel) CheckContext(x context.Context, l Linker, n string) (bool, error)
- func (s Sentinel) Crypt(c cipher.Block, w io.Writer) error
- func (s Sentinel) CryptFile(c cipher.Block, p string) error
- func (s Sentinel) File(p string) error
- func (s Sentinel) Wake(n string) (bool, error)
- func (s Sentinel) WakeContext(x context.Context, n string) (bool, error)
- func (s Sentinel) Write(w io.Writer) error
Constants ¶
const ( // TCP is a Linker type that can be used with a Guardian. // This Linker uses raw TCP sockets to determine Guardian status. TCP = netSync(false) // Pipe is a Linker type that can be used with a Guardian. // This Linker uses Unix Domain Sockets in *nix devices and Named Pipes // in Windows devices. // // Pipe names are prefixed with the appropriate namespace before being // checked or created (if it doesn't exist already). // // This is the default Linker used if a nil Linker is used. Pipe = netSync(true) // Mutex is a Linker type that can be used with a Guardian. // This Linker uses Windows Mutexes to determine Guardian status. // // This Linker type is only avaliable on Windows devices. // non-Windows devices will always return a 'device.ErrNoWindows' error. Mutex = objSync(0) // Event is a Linker type that can be used with a Guardian. // This Linker uses Windows Events to determine Guardian status. // // This Linker type is only avaliable on Windows devices. // non-Windows devices will always return a 'device.ErrNoWindows' error. Event = objSync(1) // Semaphore is a Linker type that can be used with a Guardian. // This Linker uses Windows Semaphores to determine Guardian status. // // This Linker type is only avaliable on Windows devices. // non-Windows devices will always return a 'device.ErrNoWindows' error. Semaphore = objSync(2) // Mailslot is a Linker type that can be used with a Guardian. // This Linker uses Windows MailslotS to determine Guardian status. // // This Linker type is only avaliable on Windows devices. // non-Windows devices will always return a 'device.ErrNoWindows' error. Mailslot = objSync(3) )
const ( // Self is a constant that can be used to reference the current executable // path without using the 'os.Executable' function. Self = "*" )
Variables ¶
var ErrNoEndpoints = xerr.Sub("no paths found", 0x13)
ErrNoEndpoints is an error returned if no valid Guardian paths could be used and/or found during a launch.
Functions ¶
func Check ¶
Check will attempt to contact any current Guardians watching on the supplied name. This function returns false if the specified name could not be reached or an error occurred.
This function defaults to the 'Pipe' Linker if a nil Linker is specified.
func ParseDownloadHeader ¶ added in v0.2.0
ParseDownloadHeader converts HTTP headers into index-based output types.
Resulting output types:
- 0: None found.
- 1: DLL.
- 2: Assembly Code (ASM).
- 3: Shell Script.
- 4: PowerShell Script.
Ignores '*/' prefix.
Examples
DLL: '/d' '/dll' '/dontcare' '/dynamic' '/dynamiclinklib' Assembly Code: '/a' '/b' '/asm' '/bin' '/assembly' '/binary' '/code' '/shellcode' '/superscript' '/shutupbro' Shell Script: '/x' '/s' '/cm' '/cmd' '/xgongiveittoya' '/xecute' '/xe' '/com' '/command' '/shell' '/sh' '/script' PowerShell: '/p' '/pwsh' '/powershell' '/power' '/powerwash' '/powerwashing' '/powerwashingsimulator' '/pwn' '/pwnme'
Types ¶
type Guardian ¶
type Guardian struct {
// contains filtered or unexported fields
}
Guardian is a struct that is used to maintain a running process that will re-establish itself if it is not detected running.
Guardian instances use Linker interfaces to determine status.
func Guard ¶
Guard will attempt to create a Guardian instance on the provided name using the specified Linker.
This function will return an error if the name is already being listened on.
This function defaults to the 'Pipe' Linker if a nil Linker is specified.
func GuardContext ¶
GuardContext will attempt to create a Guardian instance on the provided name.
This function will return an error if the name is already being listened on.
This function will choose the proper connection method based on the host operating system.
This function also takes a context.Context to be used for resource control.
func MustGuard ¶
MustGuard returns a Guardian instance that watches on the name provided.
This function must complete and will panic if an error occurs. Otherwise a Guardian instance is returned.
This function defaults to the 'Pipe' Linker if a nil Linker is specified.
func MustGuardContext ¶
MustGuardContext returns a Guardian instance that watches on the name provided.
This function must complete and will panic if an error occurs. Otherwise a Guardian instance is returned.
This function also takes a context.Context to be used for resource control.
func (*Guardian) Close ¶
Close will close the Guardian and stoppings the listener.
Any errors during listener close will be returned.
This function will block until the Guardian fully closes.
type Linker ¶ added in v0.1.0
type Linker interface { String() string // contains filtered or unexported methods }
Linker us an interface that specifies an object that can be used to check for a Guardian instance.
func LinkerFromName ¶ added in v0.1.0
LinkerFromName will attempt to map the name provided to an appropriate Linker interface.
If no linker is found, the 'Pipe' Linker will be returned.
type Loader ¶ added in v0.1.0
type Loader interface { Wake(string) (bool, error) Check(Linker, string) (bool, error) WakeContext(context.Context, string) (bool, error) CheckContext(context.Context, Linker, string) (bool, error) }
Loader is an interface that allows for Sentinel structs to be built ONLY AFTER a call to 'Check' returns false.
This prevents reading of any Sentinel files if the Guardian already is running and no action is needed.
This is an internal interface that can be used by the 'LazyF' and 'LazyC' functions.
type Sentinel ¶ added in v0.1.0
Sentinel is a struct that can be used as a 'Named' arguments value to functions in the 'man' package or can be Marshaled from a file or bytes source.
func C ¶ added in v0.1.0
C is a helper function that can be used as an in-line function.
This function will ALWAYS return a non-nil Sentinel.
This function uses the provided 'cipher.Block' to decrypt the resulting file data. A nil block is the same as a 'F(p)' call.
The returned Sentinel will be Marshaled from the supplied Cipher and file path.
If any errors occur, an empty Sentinel struct will be returned instead.
func Crypt ¶ added in v0.1.0
Crypt will attempt to Marshal the Sentinel struct from the supplied file path and 'cipher.Block'.
If the Block is nil, this function will behave similar to 'File(p)'.
This function will also attempt to fill in the Filter and Linker parameters.
Any errors that occur during reading will be returned.
func CryptReader ¶ added in v0.1.0
CryptReader will attempt to Marshal the Sentinel struct from the 'io.Reader' and the supplied 'cipher.Block'.
If the Block is nil, this function will behave similar to 'Reader(p)'.
This function will also attempt to fill in the Filter and Linker parameters.
Any errors that occur during reading will be returned.
func F ¶ added in v0.1.0
F is a helper function that can be used as an in-line function.
This function will ALWAYS return a non-nil Sentinel.
The returned Sentinel will be Marshaled from the supplied file path. If any errors occur, an empty Sentinel struct will be returned instead.
func File ¶ added in v0.1.0
File will attempt to Marshal the Sentinel struct from the supplied file path. This function will also attempt to fill in the Filter and Linker parameters.
Any errors that occur during reading will be returned.
func Reader ¶ added in v0.1.0
Reader will attempt to Marshal the Sentinel struct from the 'io.Reader'
This function will also attempt to fill in the Filter and Linker parameters.
Any errors that occur during reading will be returned.
func (Sentinel) Check ¶ added in v0.1.0
Check will attempt to look for a Guardian using the provided Linker and path. This overrides the set Linker in the Sentinel.
This function will return true and nil if a Guardian is launched and false and nil if a Guardian was found. Any other errors that occur will also be returned with false.
func (Sentinel) CheckContext ¶ added in v0.1.0
CheckContext will attempt to look for a Guardian using the provided Linker and path. This overrides the set Linker in the Sentinel and will use the provided Context for cancelation.
This function will return true and nil if a Guardian is launched and false and nil if a Guardian was found. Any other errors that occur will also be returned with false.
func (Sentinel) Crypt ¶ added in v0.1.0
Crypt will Marshal and write the Sentinel data to the supplied Writer and will encrypt it using the supplied 'cipher.Block' with a randomized IV value.
If the Block is nil, this function is the same as 's.Write(w)'.
Any errors that occur during writing will be returned.
func (Sentinel) CryptFile ¶ added in v0.1.0
CryptFile will attempt to Marshal the Sentinel struct into the supplied file path and 'cipher.Block'.
If the Block is nil, this function will behave similar to 's.File(p)'.
This function will also attempt to fill in the Filter and Linker parameters.
Any errors that occur during reading will be returned.
This function will truncate and overrite any file that exists at 'p'.
func (Sentinel) File ¶ added in v0.1.0
File will attempt to Marshal the Sentinel struct into the supplied file path. Any errors that occur during reading will be returned.
This function will truncate and overrite any file that exists at 'p'.
func (Sentinel) Wake ¶ added in v0.1.0
Wake will attempt to look for a Guardian using the provided path. This uses the set Linker in the Sentinel.
This function will return true and nil if a Guardian is launched and false and nil if a Guardian was found. Any other errors that occur will also be returned with false.
func (Sentinel) WakeContext ¶ added in v0.1.0
WakeContext will attempt to look for a Guardian using the provided path. This uses the set Linker in the Sentinel and will use the provided Context for cancelation.
This function will return true and nil if a Guardian is launched and false and nil if a Guardian was found. Any other errors that occur will also be returned with false.