Minimal Windows C2 (command-and-control) framework written in C89/C90, no external dependencies, VC2008 compatible.
This project is provided solely for authorized security research, testing, and educational use in systems and environments that you own or are explicitly permitted to assess. You are solely responsible for complying with all applicable laws, regulations, and policies. The authors and contributors disclaim liability for any misuse, damage, or legal consequences resulting from the use of this software.
| Binary | Role |
|---|---|
agent.exe |
Implant - runs on target, connects back to server |
server.exe |
Relay - routes traffic between agents and controllers |
controller.exe |
Operator CLI - issues commands to agents |
tools/keygen.exe |
Build-time key generator |
- Transport: AES-256-GCM (random 12-byte IV per packet, 16-byte auth tag)
- Key exchange: RSA-2048 OAEP (SHA-1 MGF1) - agent/controller each encrypt their AES-256 session key with their respective RSA public key; server decrypts with private key
- Keys: generated at build time by
keygen.exe, embedded as C arrays incommon/keys_agent.h,common/keys_ctrl.h,common/keys_server.h
Requires Visual C++ (VC2008 or later) and nmake.
nmake all
This will:
- Build
tools/keygen.exe - Run keygen to produce
common/keys_*.h - Build
agent.exe,server.exe,controller.exe
Clean:
nmake clean
- Run
server.exeon your C2 server (listens on ports 4444 for agents, 4445 for controllers)- The listener uses exclusive port binding on Windows. Starting a second
server.exewhile one is already bound to4444or4445now fails at startup with an explicitaddress already in useerror.
- The listener uses exclusive port binding on Windows. Starting a second
- Deploy
agent.exeon target - connects back toexample.com:4444, runs as a hidden background process (no console window) - Run
controller.exeon operator machine - connects toexample.com:4445
agents list connected agents
use <id> select agent by session id
ls [path] list directory on agent
cd [path] change agent working directory (no path: show cwd)
pwd print agent working directory
cat <path> print file contents from agent
exec <cmd> execute shell command on agent
shell open interactive shell (type ~. to detach)
upload <local> <remote> upload file to agent
download <remote> <local> download file from agent
socks <port> start local SOCKS5 proxy tunneled through agent
ping ping selected agent
exit quit
Remote relative paths are resolved against a per-controller working directory on
the agent. cd updates that directory, pwd prints it, and ls, cat,
exec, shell, upload, and download all use it.
| Port | Purpose |
|---|---|
| 4444 | Agent beacon (inbound to server) |
| 4445 | Controller connection (inbound to server) |
[4 bytes] plaintext length (big-endian)
[12 bytes] AES-GCM IV (random per packet)
[N bytes] AES-256-GCM ciphertext (PKT_HDR + payload)
[16 bytes] GCM authentication tag
The entire packet header (PKT_HDR) is included in the ciphertext. Key exchange packets (sent once at connection start) are plaintext RSA-encrypted blobs.
Detailed design documentation for each module:
| Document | Description |
|---|---|
| docs/protocol.md | Packet format, command codes, structured payloads, routing |
| docs/crypto.md | AES-256-GCM, RSA-2048 OAEP, bignum, key generation |
| docs/agent.md | Beacon loop, command handler, shell, SOCKS, filesystem |
| docs/server.md | Session management, packet router, concurrency model |
| docs/controller.md | REPL, client connection, interactive shell, SOCKS tunnel |
| docs/build.md | Build system, compiler flags, source file lists |