Skip to main content
Be Bitwise

How C2 Frameworks Work

Red Team Tooling Internals · Advanced Exploitation track

6 min read

In this module

Command and Control Architecture

A Command and Control (C2) framework is the communication infrastructure that lets an attacker — or a red team operator — issue instructions to compromised machines and collect results. If you're building detection, you need to understand what you're detecting. This lesson covers C2 architecture at the protocol and binary level, from a defender's vantage point.

The Beacon/Implant Model

Modern C2 frameworks use a beacon (or implant) model. The beacon is a small program running on the compromised host that periodically contacts the C2 server to check for commands.

The communication flow:

  1. Check-in: The beacon connects to the C2 server at configurable intervals
  2. Task retrieval: The server sends any queued commands (run a command, download a file, inject into a process)
  3. Task execution: The beacon executes the command locally
  4. Result return: The beacon sends the output back to the server on its next check-in

This pull-based model means the C2 server never initiates connections. To a network monitor, the traffic looks like ordinary outbound web browsing.

Sleep and Jitter

The interval between check-ins is the sleep time. A beacon sleeping for 60 seconds checks in once per minute. Jitter adds randomness to the sleep time - with 25% jitter and 60-second sleep, the actual interval varies between 45 and 75 seconds.

Sleep and jitter are what separates detectable beacons from invisible ones:

  • No jitter (fixed interval): Creates a clockwork pattern that network flow analysis will spot immediately.
  • With jitter: The intervals become irregular, much harder to distinguish from normal browsing cadence.
  • Long sleep: Less traffic, so a defender collects fewer intervals per day and needs a longer observation window before any statistics mean much. Some beacons go dark for hours between check-ins.
Sleep Evasion

During sleep, the beacon is dormant in memory. Some advanced beacons encrypt their own memory during sleep (leaving no readable strings or patterns) and use techniques like timer-based execution to avoid having a persistent thread. Defenders use memory scanning tools that look for encrypted beacon configurations or call stack anomalies in sleeping threads.

Protocol Choices

C2 traffic must blend in with normal network traffic:

HTTPS: The most common choice. Encrypted traffic prevents content inspection, and HTTPS is ubiquitous in any network. The C2 server mimics a legitimate web server, and the beacon's requests look like normal web browsing.

DNS: DNS queries and responses are almost never blocked. DNS-based C2 encodes data in DNS queries (subdomain labels) and responses (TXT records). Bandwidth is very low (tens of bytes per query) but extremely stealthy.

Domain fronting: The beacon connects to a legitimate CDN (like a cloud provider) via HTTPS. The TLS SNI and the HTTP Host header point to different domains - the SNI shows the CDN's domain (which passes network filtering) while the Host header routes the request to the C2 server behind the CDN. It's now largely historical: Google and AWS CloudFront started rejecting mismatched SNI and Host in 2018, and Azure followed, so you'll mostly meet it in older reports and in smaller CDNs.

Redirectors and legitimate cloud services: What replaced fronting is less exotic. Operators put redirectors in front of the real server: cheap VPSes, or serverless functions and CDN workers on a reputable cloud domain, which pass approved beacon traffic through and send everyone else to a harmless site. Others skip their own infrastructure altogether and use a service the target already trusts as the C2 channel, posting tasks and results through the Microsoft Graph API (OneDrive, Outlook), Slack, Telegram or Dropbox. Blocking the destination would break the business, so defenders have to look at which process is talking and how it behaves.

Custom protocols: Some C2 frameworks use protocols that mimic legitimate traffic patterns (like fake video streaming or file synchronisation) to avoid protocol-based detection.

Malleable C2 Profiles

Frameworks like Cobalt Strike use malleable C2 profiles that customise every aspect of the network communication to mimic specific legitimate applications:

  • HTTP headers (User-Agent, Accept, Content-Type)
  • URI patterns and query parameters
  • Data encoding (Base64 in cookies, XOR in POST body, data embedded in images)
  • TLS certificate properties

A profile can make beacon traffic indistinguishable from Microsoft Teams check-ins or Chrome update requests. You can't signature-match your way out of that; you need behavioural analysis.

Detection Strategies

Effective C2 detection combines multiple approaches:

  • Beaconing detection: Statistical analysis of connection intervals to find periodic patterns, even with jitter
  • JA3/JA4 fingerprinting: Identify the TLS client implementation (C2 frameworks often have distinctive TLS fingerprints). Pair it with the server-side fingerprint, JA3S (or JA4S), taken from the ServerHello: a given server answers a given client the same way every time, so the client-and-server pair singles out a C2 deployment far better than either hash alone
  • Domain reputation: Flag connections to newly registered domains, dynamic DNS, or domains with unusual registration patterns
  • Traffic volume analysis: C2 check-ins have characteristic small-request/small-response patterns
  • Certificate analysis: Detect self-signed certificates or certificates with unusual properties
  • DNS anomaly detection: Detect DNS tunneling through query length analysis, query frequency, and entropy of subdomain labels

Try the first one. The runner builds an hour of synthetic connection logs for three internal hosts talking to outside servers, then computes, per host, the median gap between connections and the share of gaps within 30% of that median. Before you run it, decide which statistic gives the beacon away despite its 25% jitter, and which host is periodic but harmless.

Try itRun it, then raise JITTER to 0.9 and see whether the beacon still stands out, and from which column.
C (GCC 9.2.0)

Both the beacon and the monitoring agent look periodic, which is why beaconing scores are a lead rather than a verdict: the next questions are where each host connects to and whether that destination is something your organisation actually runs.

Defence Requires Offense Knowledge

You cannot detect what you do not understand. Defenders who understand C2 architecture know what network patterns to look for, what host artifacts beacons leave, and what evasion techniques to expect. This is why red team exercises and C2 framework analysis are essential components of a mature security program - not to attack, but to know what to defend against.