Command and Control (C2)

Category: Post-Exploitation / Infrastructure MITRE ATT&CK: Command and Control — TA0011 Related: Post Exploitation, Lateral Movement, Evasion Techniques, Red Teaming

Overview

Command and Control (C2) is the mechanism by which an attacker maintains persistent, covert communication with compromised hosts. Modern C2 frameworks provide encrypted channels, beaconing, pivoting, payload staging, and built-in post-exploitation modules. C2 infrastructure design directly impacts both operational capability and detection risk.

How It Works

C2 Architecture

Attacker Operator
      |
  Team Server (C2 Server)
      |  (encrypted, often HTTPS/DNS/ICMP)
  Redirector(s)   ← hides true C2 server IP
      |
  Implant/Beacon  ← running on compromised host

Redirectors: Apache/nginx with mod_rewrite, Cloudflare, or dedicated VM. True C2 IP never exposed to target network. Rules pass only valid beacon traffic to C2; everything else gets 200 OK with benign content (domain fronting, CDN abuse).

Communication Protocols

ProtocolStealthNotes
HTTPSHighMost common; blends with web traffic
DNSVery HighSlow; useful through restrictive firewalls
SMBMediumLateral comms between beacons (peer-to-peer)
ICMPMediumBlocked outbound in many environments
HTTPLowPlaintext; detected by DPI
Custom protocolVariableRequires custom malleable C2 profile

Malleable C2 Profiles (Cobalt Strike concept)

Define beacon behavior: check-in interval, jitter, HTTP headers, URIs, user-agent, response body. Mimic legitimate software (Google updates, Office telemetry) to evade network-based detection.

Beaconing & Sleep

  • Beacon interval with jitter (e.g., 60s ± 30%) to avoid periodic pattern detection.
  • Long sleep times reduce detection but slow operations.
  • Sleep while EDR is active; wake during gaps or off-hours.
FrameworkLanguageLicenseNotes
Cobalt StrikeJava/.NETCommercialIndustry standard for red teams
SliverGoOpen source (BishopFox)Strong alternative; mTLS/WireGuard
HavocC/C++Open sourceModern, extendable
Brute Ratel C4C++CommercialOPSEC-focused, detection-evasion built-in
Metasploit MeterpreterRuby/COpen sourceWidely detected but fast for CTFs
CovenantC#Open source.NET focused
PoshC2PowerShellOpen sourcePS-heavy environments
NightHawkCommercialHigh-OPSEC, expensive

Attack Methodology

  1. Set up redirector(s) with domain(s) aged ≥30 days.
  2. Configure C2 server behind redirectors; never expose direct IP.
  3. Generate payload (beacon/implant) with appropriate profile.
  4. Deploy payload via initial access vector.
  5. Operate through C2: post-ex, lateral movement, data collection.
  6. Rotate infrastructure if indicators are burned.

Detection & Evasion Notes

  • Detections: JA3/JA3S fingerprinting on TLS, beacon periodicity analysis, DNS query volume/entropy, unusual outbound ports, process injection (Sysmon 8/10).
  • Evasion:
    • Domain fronting via CDN (Cloudflare, Azure, Fastly).
    • HTTPS with legitimate-looking certificates (Let’s Encrypt for aged domains).
    • Match beacon profile to expected software on the target.
    • Use process injection into signed processes (explorer, teams, chrome).
    • Sleep obfuscation (encrypted memory during sleep — Ekko, Foliage techniques).
    • Bring-your-own beacon via trusted software (DLL sideloading).

Tools

  • Cobalt Strike — commercial; most feature-complete
  • Sliver — open-source Go C2 (BishopFox)
  • Havoc — open-source modern C2
  • Metasploit — Meterpreter; great for quick tests, high AV detection
  • apache-redirector scripts, mod_rewrite rules
  • Nginx as redirector with lua scripting
  • Malleable C2 profiles — github.com/BC-SECURITY/Malleable-C2-Profiles

References

  • “Red Team Development and Operations” — Joe Vest
  • C2 Matrix — thec2matrix.com (comparison of C2 frameworks)
  • MITRE ATT&CK TA0011
  • “Infrastructure for Red Teams” — blog.cobaltstrike.com