Documentation
¶
Overview ¶
Package p2p is used for Agent based peer-to-peer communications
Index ¶
- Constants
- func String(linkType int) string
- type Link
- func (l *Link) AddIn(base messages.Base)
- func (l *Link) AddOut(base messages.Base)
- func (l *Link) Conn() interface{}
- func (l *Link) GetIn() messages.Base
- func (l *Link) GetOut() messages.Base
- func (l *Link) ID() uuid.UUID
- func (l *Link) Listener() uuid.UUID
- func (l *Link) Remote() net.Addr
- func (l *Link) String() string
- func (l *Link) Type() int
- func (l *Link) UpdateConn(conn interface{}, remote net.Addr)
- type Repository
Constants ¶
const ( TCPBIND = 0 TCPREVERSE = 1 UDPBIND = 2 UDPREVERSE = 3 SMBBIND = 4 SMBREVERSE = 5 )
Types of peer-to-peer links/connections
const ( // MaxSizeUDP is the maximum size of a UDP fragment // http://ithare.com/udp-from-mog-perspective/ MaxSizeUDP = 1450 // MaxSizeSMB is the maximum size of an SMB fragment // The WriteFileEx Windows API function says: // "Pipe write operations across a network are limited to 65,535 bytes per write" // https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-writefileex MaxSizeSMB = 65535 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Link ¶
type Link struct { sync.Mutex // Mutex is used to lock the Link object for thread safety // contains filtered or unexported fields }
Link holds information about peer-to-peer linked agents
func NewLink ¶
func NewLink(id uuid.UUID, listener uuid.UUID, conn interface{}, linkType int, remote net.Addr) *Link
NewLink is a factory to build and return a Link structure
func (*Link) AddIn ¶
func (l *Link) AddIn(base messages.Base)
AddIn takes in a base message from a parent Agent or the Merlin server and adds it to the incoming message channel, so it can be sent to the child Agent
func (*Link) AddOut ¶
func (l *Link) AddOut(base messages.Base)
AddOut takes in a base message from a child Agent and adds it to the outgoing message channel, so it can be sent to the Merlin server
func (*Link) Conn ¶
func (l *Link) Conn() interface{}
Conn returns the peer-to-peer network connection used to read and write network traffic
func (*Link) GetIn ¶
func (l *Link) GetIn() messages.Base
GetIn blocks waiting for a Base message from the incoming message channel and returns it
func (*Link) GetOut ¶
func (l *Link) GetOut() messages.Base
GetOut blocks waiting for a Base message from the outgoing message channel and returns it
func (*Link) Type ¶
Type returns what type of peer-to-peer Link this is (e.g., TCP reverse or SMB bind)
func (*Link) UpdateConn ¶
UpdateConn updates the peer-to-peer Link's network connection The updated object must be subsequently stored in the repository
type Repository ¶
type Repository interface { // Delete removes the peer-to-peer Link from the in-memory datastore Delete(id uuid.UUID) // Get finds the peer-to-peer Link by the provided id and returns it Get(id uuid.UUID) (link *Link, err error) // GetAll returns all peer-to-peer Links in the in-memory datastore GetAll() (links []*Link) // Store saves the provided peer-to-peer link into the in-memory datastore Store(link *Link) // UpdateConn updates the peer-to-peer Link's embedded conn field with the provided network connection UpdateConn(id uuid.UUID, conn interface{}, remote net.Addr) error }