server

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 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) GetClients

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

GetClients returns a list of currently connected client addresses.

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) 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

	// 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)
}

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.

Jump to

Keyboard shortcuts

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