task

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: GPL-3.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TvRefresh  uint8 = 0xC0
	TvUpload   uint8 = 0xC1
	TvDownload uint8 = 0xC2
	TvExecute  uint8 = 0xC3
	TvCode     uint8 = 0xC4
)

Custom Task Message ID Values

TvRefresh - 192: TvUpload - 193: TvDownload - 194: TvExecute - 195: TvCode - 196:

Variables

View Source
var Mappings = [256]Tasker{

	TvRefresh:  simpleTask(TvRefresh),
	TvUpload:   simpleTask(TvUpload),
	TvDownload: simpleTask(TvDownload),
	TvExecute:  simpleTask(TvExecute),
	TvCode:     simpleTask(TvCode),

	wintask.DLLTask: wintask.DLLTask,
}

Mappings is an fixed size array that contains the Tasker mappings for each ID value. Values that are less than 22 are ignored. Adding a mapping to here will allow it to be executed via the client Scheduler.

Functions

func Command

func Command(s string) *com.Packet

Command returns a Packet with the 'TvExecute' ID value and a Process struct in the payload that is based on the supplied command, which is parsed using 'cmd.Split'. By default, this will wait for the Process to complete before the client returns the output.

func Download

func Download(s string, b []byte) *com.Packet

Download returns a Packet that will instruct a Client to save the specified bytes to the local file location.

func DownloadFile

func DownloadFile(s, r string) (*com.Packet, error)

DownloadFile returns a Packet that will instruct a Client to save the contents of the supplied local file to the remote file location. This will return an error if any errors occur during reading or opening the local file.

func DownloadReader

func DownloadReader(s string, r io.Reader) (*com.Packet, error)

DownloadReader returns a Packet that will instruct a Client to save the contents of the supplied reader to the remote file location. This will return an error if any errors occur during reading.

func Execute

func Execute(e *Process) *com.Packet

Execute returns a Packet with the 'TvExecute' ID value and the provided Process struct as the Payload.

func RegisterEngine

func RegisterEngine(i uint8, s Engine) error

RegisterEngine is a function that can be used to register a Scripting engine into the XMT client tasking runtime. Script engines can increase the footprint of the compiled binary, so engines must be registed manually.

See the 'cmd/script' package for scripting engines.

func Run

func Run(s ...string) *com.Packet

Run returns a Packet with the 'TvExecute' ID value and a Process struct in the payload that is based on the provided string vardict. By default, this will wait for the Process to complete before the client returns the output.

func Upload

func Upload(s string) *com.Packet

Upload returns a Packet that will instruct a Client to upload the specified local file to the server.

Types

type Code

type Code struct {
	Data    []byte
	Wait    bool
	Filter  *cmd.Filter
	Timeout time.Duration
}

Code is a struct that is similar to the 'cmd.Code' struct. This is used to Task a Client with running shellcode on devices. This struct has many of the functionallies of the standard 'cmd.Code' function. The 'SetParent' function will attempt to set the target that runs the shellcode. If none are specified, the shellcode will be injected into the current process.

func (Code) MarshalStream

func (c Code) MarshalStream(w data.Writer) error

MarshalStream writes the data for this Code thread to the supplied Writer.

func (*Code) UnmarshalStream

func (c *Code) UnmarshalStream(r data.Reader) error

UnmarshalStream reads the data for this Code thread from the supplied Reader.

type Engine

type Engine interface {
	Invoke(context.Context, map[string]interface{}, string) (string, error)
}

Engine is an interface that allows for extending XMT with non-compiled code for easy deployability and flexibility. Each Script interface contains a single function that will take a Context, an environment block and the script code string.

The result of this function will be the output of the script and any errors that may occur. By default, the 'ID', 'OS', 'PID' 'PPID', 'OSVER' and 'HOSTNAME' variables are built-in to assist with code runtime.

type Process

type Process struct {
	Dir string

	Env, Args []string
	Stdin     []byte

	Timeout time.Duration
	Flags   uint32
	Filter  *cmd.Filter

	Wait bool
}

Process is a struct that is similar to the 'cmd.Process' struct. This is used to Task a Client with running a specified command.

func (Process) MarshalStream

func (p Process) MarshalStream(w data.Writer) error

MarshalStream writes the data for this Process to the supplied Writer.

func (*Process) SetFlags

func (p *Process) SetFlags(f uint32)

SetFlags will set the startup Flag values used for Windows programs. This function overrites many of the 'Set*' functions. Has no effect if the device is not running Windows.

func (*Process) SetParent

func (p *Process) SetParent(f *cmd.Filter)

SetParent will instruct the Process to choose a parent with the supplied process Filter. If the Filter is nil this will use the current process (default). This function has no effect if the device is not running Windows. Setting the Parent process will automatically set 'SetNewConsole' to true.

func (*Process) SetStdin

func (p *Process) SetStdin(r io.Reader) error

SetStdin wil attempt to read all the data from the supplied reader to fill the Stdin byte array for this Process struct. This function will return an error if any occurs during reading.

func (*Process) UnmarshalStream

func (p *Process) UnmarshalStream(r data.Reader) error

UnmarshalStream reads the data for this Process from the supplied Reader.

type Tasker

type Tasker interface {
	Thread() bool
	Do(context.Context, *com.Packet) (*com.Packet, error)
}

Tasker is an interface that will be tasked with executing a Job and will return an error or a resulting Packet with the resulting data. This function is NOT responsible with writing any error codes, the parent caller will handle that.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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