agent

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AgentVersion string = "paragon-v0.1.1"

AgentVersion represents a unique agent version string to identify the agent.

Variables

View Source
var ErrNoTransports = fmt.Errorf("all available transports failed to send message")

ErrNoTransports occurs if all transports fail to send a message or if none are available.

Functions

func CollectMetadata

func CollectMetadata(agent *Agent)

CollectMetadata about the system and populate the agent with the gathered information.

Types

type Agent

type Agent struct {
	Receiver
	Log        *zap.Logger
	Metadata   *c2.AgentMetadata
	Transports []Transport

	MaxIdleTime time.Duration
	// contains filtered or unexported fields
}

An Agent communicates with server(s) using the configured transport.

func (Agent) Run

func (agent Agent) Run(ctx context.Context) error

Run the agent, sending agent messages to a server using configured transports.

func (Agent) Send

func (agent Agent) Send(w ServerMessageWriter, msg Message) error

Send messages to a server using the configured transports. Returns ErrNoTransports if all fail or if none are configured.

type Message

type Message c2.AgentMessage

Message is an alias for c2.AgentMessage with some extended functionality.

func (Message) IsEmpty

func (msg Message) IsEmpty() bool

IsEmpty checks if the message has no significant contents

func (*Message) Write

func (msg *Message) Write(output []byte) (int, error)

Write log output to be included in a message to a server.

func (*Message) WriteResult

func (msg *Message) WriteResult(result *c2.TaskResult)

WriteResult writes execution output to be included in a message to a server.

func (*Message) WriteString

func (msg *Message) WriteString(output string) (int, error)

WriteString writes log output to be included in a message to a server.

type MessageWriter

type MessageWriter interface {
	io.Writer
	io.StringWriter
	WriteResult(*c2.TaskResult)
}

MessageWriter is responsible for writing output to be collected as a message from the agent.

type Receiver

type Receiver interface {
	Receive(MessageWriter, ServerMessage)
}

A Receiver is responsible for handling messages received from a server.

type Sender

type Sender interface {
	Send(ServerMessageWriter, Message) error
}

A Sender is responsible for transporting messages to a server.

type ServerMessage

type ServerMessage c2.ServerMessage

ServerMessage is an alias for c2.ServerMessage with some extended functionality.

func (*ServerMessage) WriteServerMessage

func (msg *ServerMessage) WriteServerMessage(srvMsg *ServerMessage)

WriteServerMessage replaces this message with the provided message.

type ServerMessageWriter

type ServerMessageWriter interface {
	WriteServerMessage(*ServerMessage)
}

ServerMessageWriter is responsible for writing output to be collected as a message from the server.

type Transport

type Transport struct {
	Sender
	Log *zap.Logger

	Name     string
	Interval time.Duration
	Jitter   time.Duration
}

A Transport wraps an implementation of Sender with metadata used for operation.

func (Transport) Sleep

func (t Transport) Sleep()

Sleep for the transport's configured interval & jitter duration. If Jitter is non-zero, a random duration <= Jitter is added to the transports interval.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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