Custom C2 Framework
A custom Command and Control research framework built with a Python/Flask team server and cross-compiled Go agents, featuring encrypted tasking, SPKI-pinned HTTPS, a VLESS + REALITY + uTLS transport verified with live packet captures, and durable result delivery.
- Active · Part 4
- November 30, 2026
- c2golangpythonred-teammalware-dev
- github.com/hassan-hamadi/C2-Project ↗
Read about it
- Part 1: C2 Development from Scratch: Phase 1 Teardown →
- Part 2: C2 Development from Scratch: Fixing Every IOC - Phase 2 Walkthrough →
- Part 3: Borrowing from Internet Censorship Bypass Techniques: Adding VLESS, REALITY, and uTLS to C2 Egress →
- Part 4: Implementing VLESS, REALITY, and uTLS in a Go C2 (and What Wireshark Still Catches) →
Read the build log: This project is documented across a four-part blog series covering the initial prototype, OPSEC fixes, censorship-bypass transport design, and live packet analysis. Links to all four posts are listed at the bottom of this page.
Overview
This is a custom Command and Control research framework I built from scratch to understand C2 architecture, network evasion, and detection engineering at the implementation level instead of treating existing frameworks as black boxes.
It uses a pull-based model with a Python/Flask team server, a SQLite database, a browser-based operator dashboard, and standalone Go agents cross-compiled on demand for Windows, Linux, and macOS. Each generated binary bakes in its own transport settings, timing profile, persistence option, browser headers, randomized route slugs, and encryption key.
Rather than stopping at “it compiles and connects,” the main focus of the project has been building a feature, tearing it apart from a defender’s perspective, and testing what actually holds up in a lab.
Architecture
I’m still not an artist, so I let AI try it’s best.
┌─────────────────────┐
│ Operator │
│ Dashboard │
└──────────┬──────────┘
│
Authenticated session
│
▼
┌─────────────────────┐
│ Flask Server │
│ │
│ Tasks / Results │
│ Builds / Files │
│ Agent Identity │
│ TLS Management │
└───────┬─────┬───────┘
│ │
SQLite │
│
┌────────────────────┼────────────────────┐
│ │ │
▼ ▼ ▼
Direct HTTP Pinned HTTPS REALITY + VLESS
│
▼
External Xray
│
▼
Generated Go Agent
All three transports carry the exact same AES-256-GCM encrypted application protocol. Separating the application layer from the network transport meant I could add REALITY, VLESS, and uTLS without rewriting tasking, authentication, or file transfer logic.
- Direct HTTP: Simple callback mode for isolated lab testing.
- Pinned HTTPS: Connects over TLS and checks the server certificate’s SPKI SHA-256 hash baked into the binary, hard-failing on any mismatch.
- REALITY + VLESS + uTLS: Uses a stripped-down Go client adapted from xray-core (adding ~1.5 MB to the agent binary) to spoof a browser-family TLS ClientHello, authenticate inside the handshake to an external Xray edge, and tunnel the existing HTTP protocol over VLESS to Flask on loopback. The framework does not install or manage Xray itself.
Core Capabilities
Transport and Network Evasion
- Selectable HTTP, SPKI-pinned HTTPS, or REALITY/VLESS/uTLS transports at build time.
- Five selectable Chrome, Firefox, and Safari request profiles paired with matching uTLS browser families in REALITY mode.
- Range-based beacon jitter, randomized agent endpoint slugs per server installation, and server-side decoy certificate sizing checks before building REALITY agents.
Execution, Files, and Persistence
- Direct process execution (
exec) by default to keepcmd.exeand/bin/shout of the process tree, with opt-inshellmode when pipes or redirection are needed. - Stateful working directory tracking, authenticated file uploads (
get), and agent-bound staged file downloads (download) with symlink protections. - User-scope persistence selected at build time: Windows Run key or Task Scheduler (via the COM API to avoid spawning
schtasks.exe), and Linux cron or systemd user service. macOS builds run without persistence. - Resumable self-destruct that strips persistence first, deletes local state and the binary, and uses a 24-hour server tombstone so a lost final acknowledgement can still be handled cleanly.
Security and Reliability
- Per-build AES-256-GCM encryption keys paired with a separate per-agent random secret bound on enrollment, plus replay-nonce tracking to reject resubmitted ciphertexts.
- Encrypted local result outbox protected by a per-installation OS process lock so completed task output survives restarts and stays queued until the server returns an authenticated acknowledgement.
- Server-side operator authentication using HTTP-only
SameSite=Strictcookies for the dashboard andX-API-Keyfor API clients, along with owner-only permissions for builds, loot, certificates, and database files.
Testing and Live Observations
The codebase is backed by automated Python server and integration tests, Go unit/race/vet checks, Node dashboard tests, Chromium UI checks, and cross-compilation checks for Windows and macOS.
Beyond automated tests, the REALITY transport has been verified end to end against Xray-core 26.10.29 on both Windows 11 and Linux endpoints, followed by passive Wireshark captures comparing the agent against Google Chrome and curl on the same Windows VM:
- TLS fingerprinting: The agent’s ClientHello matched Chrome on cipher suites, GREASE values, per-connection extension shuffling, ECH, ALPN, and hybrid post-quantum key exchange (
X25519MLKEM768), whilecurlstood out on every measured field. ServerHello negotiation also matched Chrome. - Version drift: Captures surfaced two concrete gaps against Chrome 152+ (the
trust_anchorsextension and ML-DSA signature algorithms) that the uTLS preset does not yet emit, showing that exact browser mimicry requires ongoing maintenance as browsers ship updates. - SNI and active probing: Every agent connection carried the decoy domain in SNI so the C2 hostname never appeared on the wire. During live deployment, an external scanner hit the listener and Xray transparently relayed it to the real decoy site.
Known Limitations and What’s Next
Getting the handshake to look like a browser does not make the traffic invisible. The framework keeps track of remaining detection surfaces explicitly rather than pretending they are solved:
| Area | Current Limitation | Planned Direction |
|---|---|---|
| Beacon timing | Bounded uniform jitter and consistent packet sizes per check-in still stand out over time. | Long-tailed timing distributions, idle backoff, and chunked file transfers. |
| Missing DNS lookups | REALITY builds connect straight to the edge IP with a decoy SNI and no preceding DNS query. | Resolve the decoy domain at connect time before dialing the edge. |
| Request timeouts | Agent HTTP requests currently lack per-request deadlines, allowing stalled connections to hang. | Per-request context deadlines split between check-ins and file transfers. |
| Endpoint artifacts | Unsigned parent process parentage in exec mode, Windows scheduled-task/systemd telemetry, and a temporary .bat cleanup file on Windows self-destruct. |
Remove the .bat disk artifact via an inline cmd.exe /c cleanup loop; evaluate PPID spoofing and quieter task registration. |
| Enterprise proxies | Forward proxies performing TLS interception cannot complete the X25519 REALITY handshake (reasoned analysis, untested live). | Documented architectural trade-off of REALITY. |
| Unimplemented features | No macOS persistence, interactive TTY shells, or peer-to-peer agent chaining. | Separate future milestones as needed. |
Technical Stack
- Team Server: Python 3.13+, Flask, SQLite,
cryptography - Agent: Go 1.27, statically cross-compiled for Windows, Linux, and macOS
- REALITY Transport: uTLS, adapted xray-core REALITY handshake (X25519/HKDF), VLESS v0 TCP framing
- Frontend: HTML5, CSS, vanilla JavaScript
- Testing: Python
unittest, Gotest/-race/vet, Node.js, Chromium
License
The project is licensed under GPLv3. The focused REALITY handshake in agent/funcs/reality/reality.go is adapted from xray-core and remains under the Mozilla Public License 2.0, with attribution documented in THIRD_PARTY_NOTICES.md.