udp

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package udp contains a configurable client used for UDP-based peer-to-peer Agent communications

Index

Constants

View Source
const (
	BIND    = 0
	REVERSE = 1
)
View Source
const (
	// MaxSize is the maximum size that a UDP fragment can be, following the moderate school of thought due to 1500 MTU
	// http://ithare.com/udp-from-mog-perspective/
	MaxSize = 1450
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex // used to lock the Client when changes are being made by one function or routine
	// contains filtered or unexported fields
}

Client is a type of MerlinClient that is used to send and receive Merlin messages from the Merlin server

func New

func New(config Config) (*Client, error)

New instantiates and returns a Client that is constructed from the passed in Config

func (*Client) Authenticate

func (client *Client) Authenticate(msg messages.Base) (err error)

Authenticate is the top-level function used to authenticate an agent to server using a specific authentication protocol The function must take in a Base message for when the C2 server requests re-authentication through a message

func (*Client) Connect

func (client *Client) Connect() (err error)

Connect establish a connection with the remote host depending on the Client's type (e.g., BIND or REVERSE)

func (*Client) Construct

func (client *Client) Construct(msg messages.Base) (data []byte, err error)

Construct takes in a messages.Base structure that is ready to be sent to the server and runs all the configured transforms on it to encode and encrypt it.

func (*Client) Deconstruct

func (client *Client) Deconstruct(data []byte) (messages.Base, error)

Deconstruct takes in data returned from the server and runs all the Agent's transforms on it until a messages.Base structure is returned. The key is used for decryption transforms

func (*Client) Get

func (client *Client) Get(key string) (value string)

Get is a generic function that is used to retrieve the value of a Client's field

func (*Client) Initial

func (client *Client) Initial() (err error)

Initial executes the specific steps required to establish a connection with the C2 server and checkin or register an agent

func (*Client) Listen

func (client *Client) Listen() (returnMessages []messages.Base, err error)

Listen is composed of an infinite loop that waits up to 5 minutes per loop to receive a UDP connection from a peer

func (*Client) ResetListener

func (client *Client) ResetListener() (err error)

ResetListener closes the listener for BIND Agents and sets it and the client to nil to facilitate a new client connection

func (*Client) Send

func (client *Client) Send(m messages.Base) (returnMessages []messages.Base, err error)

Send takes in a Merlin message structure, performs any encoding or encryption, converts it to a delegate and writes it to the output stream The function also decodes and decrypts response messages and return a Merlin message structure. This is where the client's logic is for communicating with the server.

func (*Client) SendAndWait

func (client *Client) SendAndWait(m messages.Base) (returnMessages []messages.Base, err error)

SendAndWait takes in a Merlin message, encodes/encrypts it, and writes it to the output stream and then waits for response messages and returns them

func (*Client) Set

func (client *Client) Set(key string, value string) (err error)

Set is a generic function that is used to modify a Client's field values

func (*Client) String

func (client *Client) String() string

String returns the type of UDP client

func (*Client) Synchronous

func (client *Client) Synchronous() bool

type Config

type Config struct {
	Address      []string  // Address the interface and port the agent will bind to
	AgentID      uuid.UUID // AgentID the Agent's UUID
	AuthPackage  string    // AuthPackage the type of authentication the agent should use when communicating with the server
	ListenerID   uuid.UUID // ListenerID the UUID of the listener that this Agent is configured to communicate with
	Padding      string    // Padding the max amount of data that will be randomly selected and appended to every message
	PSK          string    // PSK the Pre-Shared Key secret the agent will use to start authentication
	Transformers string    // Transformers is an ordered comma seperated list of transforms (encoding/encryption) to apply when constructing a message
	Mode         string    // Mode the type of client or communication mode (e.g., BIND or REVERSE)
}

Config is a structure that is used to pass in all necessary information to instantiate a new Client

Jump to

Keyboard shortcuts

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