Documentation
¶
Overview ¶
Package listener implements TCP callback receivers (回连接收器) for red team operations: catch reverse-shell callbacks and OOB connections while the agent does other work, and record every session as evidence.
设计边界(刻意不做):
- 不做交互式 shell 管理器(那是 C2 框架的事,Sliver/Mythic 是集成对象不是 竞争对象)。监听器负责「接住连接 + 留证据」;交互式操作由 agent 用 Bash 里的 nc/socat 自行完成。
- 捕获有上限(每会话 64KB 预览),防止目标把监听器当数据泵灌爆内存。
- 端口白名单默认 1024-65535(绑低端口需要 root,服务用户没有;真要 80/443 走 hostd 或端口转发)。
并发模型:每个 listener 一个 accept goroutine + 每连接一个读 goroutine; Manager.mu 保护 listeners map。Stop 优雅关闭(关 accept、关全部连接)。
Index ¶
Constants ¶
const ( // MaxCapturePerSession 是单个会话捕获的字节上限(防灌爆)。 MaxCapturePerSession = 64 * 1024 // MinPort/MaxPort 是允许绑定的端口范围。 MinPort = 1024 MaxPort = 65535 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Listener ¶
type Listener struct {
Name string `json:"name"`
Port int `json:"port"`
StartedAt time.Time `json:"started_at"`
Sessions []*Session `json:"sessions"`
// contains filtered or unexported fields
}
Listener 是一个运行中的回连接收器。
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 管理全部监听器(进程级单例,由 server 持有)。
type Session ¶
type Session struct {
ID string `json:"id"`
Remote string `json:"remote"`
ConnectedAt time.Time `json:"connected_at"`
LastActive time.Time `json:"last_active"`
BytesIn int64 `json:"bytes_in"`
// Preview 是捕获的前 MaxCapturePerSession 字节(UTF-8 容错解码)。
// 反弹 shell 的初始输出、OOB 请求行、banner 都在这里。
Preview string `json:"preview"`
Open bool `json:"open"`
}
Session 是一次回连的记录。