listener

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

README

shellkit/listener

A small Go reverse-shell listener and session manager.

  • Manager.Start("0.0.0.0:4444") accepts reverse shells and registers sessions.
  • Manager.Exec(sessionID, command) runs a non-interactive command using a unique echo marker (serialized per session, deadline-aware).
  • Manager.Upload writes a file in 32KB base64 chunks (POSIX shells).
  • Manager.Download reads a file as base64 (POSIX shells).
  • Manager.Sessions / Manager.Stop list or close sessions.

This is not a C2: no staging, persistence, evasion, or automatic lateral movement. It is the transport/session layer for authorized reverse shells. WebSocket/terminal UI is host-side; the host can stream Exec results or add a session stream.

Documentation

Overview

Package listener is a small Go reverse-shell session manager. It owns a TCP listener, a session registry, command execution and basic file transfer. It is intentionally not a C2: no persistence, no staging, no evasion.

Index

Constants

View Source
const (
	DefaultReadTimeout = 30 * time.Second
	UploadChunkSize    = 32 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) Download

func (m *Manager) Download(ctx context.Context, sessionID, path string) ([]byte, error)

Download reads a remote file as base64. POSIX shells only.

func (*Manager) Exec

func (m *Manager) Exec(ctx context.Context, sessionID, command string) (string, error)

Exec sends one command and reads until a unique marker is echoed. It is serialized per session. Commands should be non-interactive.

func (*Manager) Sessions

func (m *Manager) Sessions() []SessionInfo

func (*Manager) Start

func (m *Manager) Start(addr string) (string, error)

Start listens on addr (e.g. "0.0.0.0:4444") and accepts reverse shells. It returns the actual listen address.

func (*Manager) Stop

func (m *Manager) Stop() error

Stop closes the listener and every session.

func (*Manager) Upload

func (m *Manager) Upload(ctx context.Context, sessionID, path string, data []byte) (int, error)

Upload writes data to a remote path using chunked base64. POSIX shells only.

type Session

type Session struct {
	ID         string
	Conn       net.Conn
	RemoteAddr string
	CreatedAt  time.Time
	// contains filtered or unexported fields
}

type SessionInfo

type SessionInfo struct {
	ID         string    `json:"id"`
	RemoteAddr string    `json:"remote_addr"`
	CreatedAt  time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

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