server

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientMetadata added in v0.21.0

type ClientMetadata struct {
	Identifier string
	OS         string
	Hostname   string
	IP         string
}

ClientMetadata captures optional metadata sent by the client during IDENT. Fields may be empty when the client does not provide the data.

type CommandHandler

type CommandHandler interface {
	// ExecuteCommand sends a command and gets the response.
	ExecuteCommand(cmd string) (string, error)

	// IsConnected checks if the command handler has an active connection.
	IsConnected() bool
}

CommandHandler defines the interface for handling command execution on clients.

type ForwardInfo added in v0.20.0

type ForwardInfo struct {
	ID         string
	LocalAddr  string
	RemoteAddr string
	Listener   net.Listener
	Active     bool
	ConnCount  int
	// contains filtered or unexported fields
}

ForwardInfo holds information about a port forward

type ForwardManager added in v0.20.0

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

ForwardManager manages port forwarding sessions

func NewForwardManager added in v0.20.0

func NewForwardManager() *ForwardManager

NewForwardManager creates a new forward manager

func (*ForwardManager) BindAddr added in v0.24.0

func (fm *ForwardManager) BindAddr() string

BindAddr returns the bind address used for new forwards.

func (*ForwardManager) HandleForwardData added in v0.20.0

func (fm *ForwardManager) HandleForwardData(fwdID, connID, encodedData string) error

HandleForwardData handles incoming data from the remote side

func (*ForwardManager) HandleForwardStop added in v0.23.0

func (fm *ForwardManager) HandleForwardStop(fwdID, connID string) error

HandleForwardStop closes a specific forward connection

func (*ForwardManager) ListForwards added in v0.20.0

func (fm *ForwardManager) ListForwards() []*ForwardInfo

ListForwards returns a list of active forwards

func (*ForwardManager) StartForward added in v0.20.0

func (fm *ForwardManager) StartForward(id, localPort, remoteAddr string, sendFunc func(string)) error

StartForward starts a new port forward

func (*ForwardManager) StopAll added in v0.20.0

func (fm *ForwardManager) StopAll()

StopAll stops all forwards

func (*ForwardManager) StopForward added in v0.20.0

func (fm *ForwardManager) StopForward(id string) error

StopForward stops a port forward

type Listener

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

Listener represents a TLS reverse shell listener server that accepts client connections, manages them, and dispatches commands to connected clients.

func NewListener

func NewListener(port, networkInterface string, tlsConfig *tls.Config, sharedSecret string) *Listener

NewListener creates a new reverse shell listener with the given port, network interface, TLS configuration, and optional shared secret.

func (*Listener) EnterPtyMode

func (l *Listener) EnterPtyMode(clientAddr string) (chan []byte, error)

EnterPtyMode puts a client into PTY mode for interactive shell

func (*Listener) ExitPtyMode

func (l *Listener) ExitPtyMode(clientAddr string) error

ExitPtyMode exits PTY mode for a client

func (*Listener) GetClientAddressesSorted

func (l *Listener) GetClientAddressesSorted() []string

GetClientAddressSorted returns sorted client addresses for consistent ordering

func (*Listener) GetClientIdentifier

func (l *Listener) GetClientIdentifier(clientAddr string) string

GetClientIdentifier returns the short identifier for a client if present.

func (*Listener) GetClientMetadata added in v0.21.0

func (l *Listener) GetClientMetadata(clientAddr string) (ClientMetadata, bool)

GetClientMetadata returns metadata provided by the client (if any).

func (*Listener) GetClients

func (l *Listener) GetClients() []string

GetClients returns a list of currently connected client addresses.

func (*Listener) GetForwardManager added in v0.20.0

func (l *Listener) GetForwardManager() *ForwardManager

GetForwardManager returns the forward manager

func (*Listener) GetPtyDataChan

func (l *Listener) GetPtyDataChan(clientAddr string) (chan []byte, bool)

GetPtyDataChan returns the PTY data channel for a client

func (*Listener) GetResponse

func (l *Listener) GetResponse(clientAddr string, timeout time.Duration) (string, error)

GetResponse waits for and returns the response from a client within the given timeout. It returns an error if the client is not found or if the timeout is exceeded.

func (*Listener) GetSocksManager added in v0.20.0

func (l *Listener) GetSocksManager() *SocksManager

GetSocksManager returns the SOCKS manager

func (*Listener) IsAnyPtyModeActive added in v0.24.2

func (l *Listener) IsAnyPtyModeActive() bool

IsAnyPtyModeActive checks if any client is currently in PTY mode

func (*Listener) IsInPtyMode

func (l *Listener) IsInPtyMode(clientAddr string) bool

IsInPtyMode checks if a client is in PTY mode

func (*Listener) SendCommand

func (l *Listener) SendCommand(clientAddr, cmd string) error

SendCommand sends a command to a specific client identified by its address. It returns an error if the client is not found or if the send times out.

func (*Listener) Start

func (l *Listener) Start() (net.Listener, error)

Start begins listening for client connections on the configured port and interface. It returns the underlying net.Listener and starts accepting connections in a background goroutine.

type ListenerInterface

type ListenerInterface interface {
	// Start begins listening for incoming client connections.
	// Returns the underlying net.Listener and any error that occurred.
	Start() (net.Listener, error)

	// GetClients returns a list of currently connected client addresses.
	GetClients() []string

	// SendCommand sends a command to a specific client by its address.
	// Returns an error if the client is not connected or the send fails.
	SendCommand(clientAddr, cmd string) error

	// GetResponse waits for and retrieves the response from a specific client.
	// Blocks until a response is available or timeout is exceeded.
	GetResponse(clientAddr string, timeout time.Duration) (string, error)

	// GetClientAddressesSorted returns a sorted list of connected client addresses.
	GetClientAddressesSorted() []string

	// GetClientIdentifier returns the short identifier for a client if present.
	// Returns empty string when no identifier was announced.
	GetClientIdentifier(clientAddr string) string

	// GetClientMetadata returns metadata sent during IDENT, if available.
	GetClientMetadata(clientAddr string) (ClientMetadata, bool)

	// EnterPtyMode enters interactive PTY mode with a specific client.
	// Returns a channel that receives PTY data, or an error if mode entry fails.
	EnterPtyMode(clientAddr string) (chan []byte, error)

	// ExitPtyMode exits interactive PTY mode with a specific client.
	ExitPtyMode(clientAddr string) error

	// IsInPtyMode checks if a specific client is in PTY mode.
	IsInPtyMode(clientAddr string) bool

	// GetPtyDataChan retrieves the data channel for a client in PTY mode.
	GetPtyDataChan(clientAddr string) (chan []byte, bool)

	// IsAnyPtyModeActive checks if any client is currently in PTY mode.
	IsAnyPtyModeActive() bool
}

ListenerInterface defines the interface for a TLS listener that manages reverse shell client connections. It handles accepting client connections, managing the client pool, and executing commands on clients.

type ListenerStats

type ListenerStats interface {
	// GetClientCount returns the number of currently connected clients.
	GetClientCount() int

	// GetTotalConnections returns the total number of connections made since startup.
	GetTotalConnections() int

	// GetLastError returns the last error that occurred.
	GetLastError() error
}

ListenerStats defines the interface for retrieving listener statistics.

type SocksConnection added in v0.20.0

type SocksConnection struct {
	ID         string
	TargetAddr string
	Active     bool
}

SocksConnection represents a single SOCKS5 connection

type SocksManager added in v0.20.0

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

SocksManager manages SOCKS5 proxies

func NewSocksManager added in v0.20.0

func NewSocksManager() *SocksManager

NewSocksManager creates a new SOCKS manager

func (*SocksManager) BindAddr added in v0.24.0

func (sm *SocksManager) BindAddr() string

BindAddr returns the bind address used for new SOCKS proxies.

func (*SocksManager) HandleSocksClose added in v0.20.0

func (sm *SocksManager) HandleSocksClose(socksID, connID string)

HandleSocksClose handles connection close from remote side

func (*SocksManager) HandleSocksData added in v0.20.0

func (sm *SocksManager) HandleSocksData(socksID, connID, encodedData string) error

HandleSocksData handles incoming data from the remote side

func (*SocksManager) ListSocks added in v0.20.0

func (sm *SocksManager) ListSocks() []*SocksProxy

ListSocks returns a list of active SOCKS proxies

func (*SocksManager) SignalSocksReady added in v0.20.0

func (sm *SocksManager) SignalSocksReady(socksID, connID string)

SignalSocksReady signals that a remote connection is established

func (*SocksManager) StartSocks added in v0.20.0

func (sm *SocksManager) StartSocks(id, localPort string, sendFunc func(string)) error

StartSocks starts a new SOCKS5 proxy

func (*SocksManager) StopAll added in v0.20.0

func (sm *SocksManager) StopAll()

StopAll stops all SOCKS proxies

func (*SocksManager) StopSocks added in v0.20.0

func (sm *SocksManager) StopSocks(id string) error

StopSocks stops a SOCKS proxy

type SocksProxy added in v0.20.0

type SocksProxy struct {
	ID        string
	LocalAddr string
	Listener  net.Listener
	Active    bool
	// contains filtered or unexported fields
}

SocksProxy manages SOCKS5 proxy connections

Jump to

Keyboard shortcuts

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