tcp

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package tcp contains a configurable client used for TCP-based peer-to-peer Agent communications

Index

Constants

View Source
const (
	BIND    = 0
	REVERSE = 1
)

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 waits for incoming data on an established TCP connection, deconstructs the data into a Base messages, and returns them

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. This function DOES not wait or listen for response messages.

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 TCP client

func (*Client) Synchronous

func (client *Client) Synchronous() bool

Synchronous identifies if the client connection is synchronous or asynchronous, used to determine how and when messages can be sent/received.

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