Executive Summary
Command & Control (C2) is the nervous system of an intrusion. After initial compromise, adversaries establish remote communication to issue commands, move laterally, and exfiltrate data. Modern C2 blends into normal traffic using HTTP(S) beacons, DNS tunneling, and encrypted WebSockets, often routed through cloud/CDN infrastructure. Defenders win by controlling egress, monitoring anomalies, and profiling traffic behavior rather than chasing static indicators.
Threat Model & Goal
- Goal: Maintain reliable, covert, and resilient links between attacker infrastructure and compromised hosts.
- Adversary objectives enabled by C2: tasking, staging payloads, credential theft, lateral movement, data theft, and ransomware detonation.
Common Architectures
- Pull / Beaconing (most common): Host “checks in” at intervals with jitter (randomized sleep) to evade periodicity detection.
- Push / Long-lived channels: Single persistent session (e.g., WebSockets) for low-latency control.
- Multi-hop & redirectors: Traffic relayed via VPS/CDN/NGINX redirectors to hide origin and rotate infrastructure.
- Living-off-the-land C2: Abuse of legit services (OneDrive, Slack, Telegram, GitHub Gists) as the command mailbox.
Techniques in the Wild
1) HTTP(S) Beacons (ATT&CK: T1071.001)
- How it works: Periodic POST/GET to attacker URIs; data camouflaged as cookies, headers, JSON, or images.
- Evasion: TLS 1.3, malleable user-agents, status codes like 200/204/404, small fixed response sizes, host routing via domain frontends or CDNs.
- Defender focus: TLS fingerprinting (JA3/JA4), header/URI oddities, beacon periodicity, SNI/Host inconsistencies.
2) DNS Tunneling / DoH (T1071.004, T1572)
- How it works: Commands/data encoded in subdomain labels (e.g.,
<chunk>.<id>.example.com) or carried over DNS-over-HTTPS to public resolvers. - Evasion: High-entropy labels, TXT/NULL records, NXDOMAIN padding, rotating subdomains or DGAs.
- Defender focus: Enforce internal DNS only, block external resolvers/DoH endpoints, watch query rate, label length, entropy, and TXT volume.
3) Encrypted WebSockets (T1071.001 + upgrade)
- How it works: HTTP(S) Upgrade: websocket → persistent encrypted channel on 443.
- Evasion: Blends with web apps using WS; low, heartbeat-like frames.
- Defender focus: Flag long-lived outbound WS to rare hosts, non-browser processes opening WS, and unusual paths (e.g.,
/chat/gatewayfrom servers).
Additional C2 Paths to Track
- SMB/Named Pipes in LAN, WinRM/PowerShell Remoting, SSH over non-standard ports, QUIC/HTTP-3, and MQTT/CoAP in OT/IoT networks.
- Proxy/VPN abuse and cloud mailbox C2 (SharePoint/Drive objects as dead drops).
Evasion Tradecraft You Should Expect
- Jittered intervals (e.g., 30–90 s) + sleep masks to hide in memory
- Process injection & masquerade (
svchost.exe, signed-binary DLL sideloading) - Certificate tricks: short-lived Let’s Encrypt, reused SANs, odd org fields
- Traffic shaping: constant-size packets, keep-alives, low byte volume
- Rotation: redirectors, fast-flux DNS, cloud IP churn
Detection & Hunting Playbook
Network Analytics (NetFlow/Proxy/TLS logs)
- Beaconing periodicity: repeated connections from one host to one rare domain/IP at near-regular intervals with jitter.
- JA3/JA4 anomalies: rare TLS fingerprints to popular ports; mismatched SNI vs. certificate CN/SAN.
- HTTP oddities: identical content-length across many responses; ancient or tool-like user-agents; suspicious paths (
/jquery,/login.php,/news.php) with machine-like cadence. - DNS tunneling signs:
- Avg. label length > 40, high Shannon entropy, many TXT queries
- NXDOMAIN spikes or many subdomains per host per minute
- Direct DoH to public endpoints from servers (block or alert)
Host & EDR Telemetry
- Non-browser processes using WinHTTP/WinInet to talk 443 externally
- DLL sideloading around signed binaries; ETW/AMSI bypass attempts
- Long-lived handles to
\Device\Afd\sockets from unusual services - Persistence (scheduled tasks, Run keys, WMI subscriptions) paired with steady egress
Quick Queries (examples)
Splunk – periodic beacons (proxy logs):
index=proxy OR index=fw dest_port=80 OR dest_port=443
| bin _time span=1m
| stats count by src_ip, dest, _time
| eventstats stdev(count) as sdev avg(count) as avg by src_ip, dest
| where sdev < 0.5 AND avg > 0 /* low variance = beacon-like */
| sort - avg
Elastic (KQL) – long-lived WebSockets from servers:
(event.dataset : "proxy" and http.request.headers.upgrade : "websocket")
and source.ip : (assets.servers)
and not destination.domain : ("*.microsoft.com","*.google.com","*.slack.com")
Sigma – suspicious DNS tunneling
title: High-Entropy Long DNS Labels
logsource: { category: dns }
detection:
sel:
query_length|gte: 100
qtype: [TXT, NULL]
condition: sel
level: high
Prevent & Contain: Controls That Work
Quick Wins
- Egress filtering by policy: Only allow outbound to required ports/destinations; block direct 53/DoH, force all DNS to internal resolvers.
- Authenticated web proxy with TLS inspection (where legally/contractually permissible).
- Deny WebSockets by default except for approved domains.
- TI-backed blocks for known C2 kits (Cobalt Strike/Sliver/Havoc profiles & certs).
Hardening
- Application allow-listing (WDAC/AppLocker) to stop rogue binaries & DLL sideloading.
- PowerShell Constrained Language Mode, AMSI on, disable Office macros from the internet.
- Network segmentation: no direct internet from Tier-0/servers; use egress brokers.
- DNS security: RPZ/response policy zones, tunneling heuristics, and sinkhole.
Incident Response Playbook (Condensed)
- Isolate host (EDR network containment).
- Capture memory → extract beacon config if possible (keys, URIs).
- Pivot on infra (JA3/JA4, SNI, cert, URI) to find siblings.
- Kill persistence, rotate creds/tokens, and block egress indicators at the edge.
- Hunt 30–90 days back for same infra profile across the fleet.
MITRE ATT&CK Mapping (selected)
- T1071.001 Web Protocols (HTTP/S)
- T1071.004 DNS; T1572 Protocol Tunneling; T1090.003 Multi-hop Proxy
- T1571 Non-Standard Port; T1132 Data Encoding; T1041 Exfil over C2
CyberDudeBivash Expert Note
“You don’t need to read the attacker’s packets to beat them—just own your egress and profile behavior. Beacon cadence, TLS fingerprints, and DNS hygiene will catch more real intrusions than any one IOC feed.” — CyberDudeBivash
Published by CyberDudeBivash — Your trusted partner for real-time threat intel and pragmatic defense.
🔗 cyberdudebivash.com • Follow: #CyberDudeBivash #ThreatWire #C2 #DNS #WebSockets #NetworkSecurity #ThreatHunting #IncidentResponse
Leave a comment