C2 Guide

July 7, 2026 · View on GitHub

中文

The built-in C2 subsystem is for authorized environments only. Disable it when not needed:

c2:
  enabled: false

Objects

  • Listener: receives sessions.
  • Session: connected implant/session.
  • Task: command or operation assigned to a session.
  • Payload: generated binary or one-liner.
  • Profile: communication configuration.
  • Event: runtime event stream.
  • File: upload/download channel.

APIs live under /api/c2; disabled C2 returns 503 c2_disabled.

Lifecycle

Correct C2 operation is a lifecycle:

  1. Authorization: project, targets, time window, allowed actions.
  2. Profile design: transport, sleep, callback address.
  3. Listener start: port, network path, logs.
  4. Payload generation: hash, purpose, delivery method.
  5. Session intake: confirm host identity and privilege.
  6. Tasking: only authorized tasks.
  7. Result archival: project facts or report.
  8. Cleanup: stop listeners, delete payloads, clear stale sessions/events.

Skipping authorization and profile design makes the rest hard to audit.

Task Classification

LevelExampleApproval
L1 read-only identitywhoami, hostnameaudit agent may approve
L2 environment enuminterfaces, processesstrict review
L3 file accessread config, download resulthuman confirms path
L4 change executionupload, run script, sleep changehuman approval
L5 persistence/lateral/destructivestartup, creds, delete, spreadreject unless explicit authorization

Put this classification into HITL prompts for practical decisions.

Review Questions

  • Which listener received which session?
  • Who generated the payload and when?
  • Which authorized target does the session represent?
  • Which tasks were issued?
  • Were outputs saved into facts or reports?
  • Were listener and payload cleaned up?

Source Anchors

  • Manager: internal/c2/manager.go
  • Listener: internal/c2/listener.go
  • HTTP listener: internal/c2/listener_http.go
  • TCP listener: internal/c2/listener_tcp.go
  • Payload: internal/c2/payload_builder.go
  • Handler: internal/handler/c2.go
  • MCP tools: internal/app/c2_tools.go