transport

package
v0.0.0-...-72a322c Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSelfSignedCert

func GenerateSelfSignedCert(host string) (tls.Certificate, error)

GenerateSelfSignedCert creates an ECDSA P-256 self-signed certificate.

func NewClientTLSConfig

func NewClientTLSConfig() *tls.Config

NewClientTLSConfig creates a TLS config for agents.

func NewTLSConfig

func NewTLSConfig(cert tls.Certificate) *tls.Config

NewTLSConfig creates a TLS config for the server.

func SaveCertToFile

func SaveCertToFile(cert tls.Certificate, certFile, keyFile string) error

SaveCertToFile saves certificate and key to files.

Types

type Conn

type Conn struct {
	net.Conn
	Transport  string
	TLSEnabled bool
	TLSState   *tls.ConnectionState
	ProxyUsed  bool
}

Conn wraps a network connection with transport metadata.

func WrapConn

func WrapConn(conn net.Conn, transport string) *Conn

WrapConn creates a Conn wrapper.

func WrapTLSConn

func WrapTLSConn(conn *tls.Conn, transport string) *Conn

WrapTLSConn creates a TLS-wrapped Conn.

type DNSListener

type DNSListener struct {
	// contains filtered or unexported fields
}

DNSListener implements encrypted DNS tunneling. Agents encode encrypted data in A/AAAA queries, server responds via TXT records.

func NewDNSListener

func NewDNSListener(addr string, domains []string, encKey []byte) (*DNSListener, error)

NewDNSListener creates an encrypted DNS tunneling listener.

func (*DNSListener) Accept

func (l *DNSListener) Accept() (net.Conn, error)

Accept returns the next DNS tunneling connection.

func (*DNSListener) Addr

func (l *DNSListener) Addr() net.Addr

Addr returns the listener's address.

func (*DNSListener) Close

func (l *DNSListener) Close() error

Close shuts down the DNS listener.

func (*DNSListener) Start

func (l *DNSListener) Start()

Start begins processing DNS queries.

type HTTPAgent

type HTTPAgent struct {
	// contains filtered or unexported fields
}

HTTPAgent connects to C2 via HTTP long-polling.

func NewHTTPAgent

func NewHTTPAgent(serverURL, userAgent string) *HTTPAgent

NewHTTPAgent creates a new HTTP long-poll agent transport.

func (*HTTPAgent) Send

func (a *HTTPAgent) Send(data []byte) ([]byte, error)

Send sends data via HTTP POST and returns the server response.

func (*HTTPAgent) SessionID

func (a *HTTPAgent) SessionID() string

SessionID returns the current HTTP session ID.

type HTTPListener

type HTTPListener struct {
	// contains filtered or unexported fields
}

HTTPListener implements a long-poll HTTP/S listener for C2.

func NewHTTPListener

func NewHTTPListener(addr string) *HTTPListener

NewHTTPListener creates a new HTTP long-poll listener.

func NewHTTPSListener

func NewHTTPSListener(addr string, tlsConfig *tls.Config) *HTTPListener

NewHTTPSListener creates a new HTTPS long-poll listener.

func (*HTTPListener) Accept

func (l *HTTPListener) Accept() (net.Conn, error)

Accept returns the next agent connection via HTTP long-poll.

func (*HTTPListener) Addr

func (l *HTTPListener) Addr() net.Addr

Addr returns the listener's address.

func (*HTTPListener) Close

func (l *HTTPListener) Close() error

Close shuts down the HTTP listener.

func (*HTTPListener) SendToSession

func (l *HTTPListener) SendToSession(sessionID string, data []byte) error

SendToSession sends data to a specific HTTP session.

func (*HTTPListener) Start

func (l *HTTPListener) Start() error

Start begins the HTTP/S listener.

type Profile

type Profile struct {
	Name       string   `json:"name"`        // e.g., "corporate", "direct"
	Priority   int      `json:"priority"`    // Lower = tried first
	Transports []string `json:"transports"`  // e.g., ["wss", "https", "dns"]
	ProxyURL   string   `json:"proxy_url"`   // Optional SOCKS5/HTTP proxy
	UserAgent  string   `json:"user_agent"`  // e.g., "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
	HostHeader string   `json:"host_header"` // Domain fronting header
	MaxRetries int      `json:"max_retries"`
}

Profile defines a transport profile for an agent.

func DefaultProfiles

func DefaultProfiles(serverAddr string) []Profile

DefaultProfiles returns standard transport profiles.

type WSAgent

type WSAgent struct {
	// contains filtered or unexported fields
}

WSAgent connects to C2 via WebSocket.

func NewWSAgent

func NewWSAgent(url, userAgent string) *WSAgent

NewWSAgent creates a new WebSocket agent transport.

func (*WSAgent) Close

func (a *WSAgent) Close() error

Close closes the WebSocket connection.

func (*WSAgent) Connect

func (a *WSAgent) Connect() error

Connect performs the WebSocket upgrade handshake.

func (*WSAgent) Read

func (a *WSAgent) Read(b []byte) (int, error)

Read reads a WebSocket frame.

func (*WSAgent) Write

func (a *WSAgent) Write(b []byte) (int, error)

Write sends data in a WebSocket binary frame with masking.

type WSListener

type WSListener struct {
	// contains filtered or unexported fields
}

WSListener implements a WebSocket upgrade listener.

func NewWSListener

func NewWSListener(addr string) *WSListener

NewWSListener creates a WebSocket listener.

func NewWSSListener

func NewWSSListener(addr string, tlsConfig *tls.Config) *WSListener

NewWSSListener creates a secure WebSocket listener.

func (*WSListener) Accept

func (l *WSListener) Accept() (net.Conn, error)

Accept returns the next WebSocket connection.

func (*WSListener) Addr

func (l *WSListener) Addr() net.Addr

Addr returns the listener's address.

func (*WSListener) Close

func (l *WSListener) Close() error

Close shuts down the WebSocket listener.

func (*WSListener) Start

func (l *WSListener) Start() error

Start begins the WebSocket listener.

Jump to

Keyboard shortcuts

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