Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Active Directory and Windows attacks

Lab · Hard · 2.5 hoursFree account

NTLM Relay Attacks

Find relay targets, coerce auth with PetitPotam, relay to SMB, LDAP (RBCD) and AD CS (ESC8), then verify the defences.

  • ntlm-relay
  • responder
  • ntlmrelayx
  • active-directory
  • smb
On this page 15 sections
  1. ·Overview
  2. ·Prerequisites
  3. ·Lab setup
  4. ·Build the target
  5. 1Map the relay targets
  6. 2Configure Responder for relay mode
  7. Locked: Relay an SMB authentication and dump the SAM
  8. Locked: Coerce authentication from the Domain Controller
  9. Locked: Relay to LDAP and configure RBCD
  10. Locked: Relay to AD CS web enrollment (ESC8)
  11. Locked: Confirm the domain compromise
  12. Locked: Turn on the defences and watch each relay fail
  13. Locked: Check
  14. Locked: Clean-up
  15. Locked: Command reference

NTLM relay attacks let an attacker borrow a live authentication and spend it on a different service, without ever learning a password. A single unsigned SMB share or an exposed AD CS web page turns one coerced login into Domain Controller rights, as many real intrusions prove. This lab coerces a Domain Controller, relays the authentication to SMB, LDAP and AD CS, then applies the three defences that break each path.

Lab Objectives

  • Map which hosts in a domain accept a relay, by testing for SMB signing
  • Configure Responder and ntlmrelayx so one tool poisons name resolution and the other holds the authentication
  • Coerce a Domain Controller into authenticating to your Kali box with PetitPotam and the printer bug
  • Relay coerced NTLM to LDAP to configure Resource-Based Constrained Delegation (RBCD)
  • Relay coerced NTLM to AD CS web enrollment (ESC8) and turn the certificate into a Domain Controller compromise
  • Apply SMB signing, LDAP channel binding and AD CS Extended Protection, then prove each one stops the matching relay

Overview

NTLM authentication proves who you are to a server, but it does not prove which server you meant to talk to. A relay attack stands in the middle. The target authenticates to your machine, and your machine forwards that same authentication, unchanged, to a third service that trusts it. You never see the password. You never crack a hash. You borrow the authentication while it is live and spend it somewhere else.

Two things make this a full domain-compromise path, not a trick. First, you can force a machine to authenticate on demand, so you do not wait for a user to connect. This is called coercion. Second, you can relay that forced authentication to high-value services such as LDAP and AD CS, not only to a file share. This lab builds the attack one service at a time, and ends by turning on the defences and watching each one break the step it protects.

Prerequisites

  • Finish Active Directory Basics first. This lab assumes you already know a Domain Controller, LDAP, a machine account and an SPN (Service Principal Name).
  • SMB Enumeration teaches the SMB signing setting this whole attack turns on. Signing is the single configuration that decides whether an SMB relay works.
  • AD Enumeration with CrackMapExec covers the tool you use in Step 1 to find relay targets across a subnet.
  • AD Certificate Services (ADCS) Attacks covers ESC8 in full. This lab reaches ESC8 through a relay; that lab explains the certificate template abuse behind it.
  • Kerberos Attacks covers the S4U ticket requests you use in Step 5 to cash in the delegation you set up.

Lab setup

ItemPurpose
responderPoisons LLMNR, NBT-NS and mDNS name resolution to make a target connect to your Kali box
impacket (ntlmrelayx, getST, secretsdump)Relays the captured NTLM authentication to SMB, LDAP and HTTP, and cashes in the result
crackmapexecTests SMB signing across a subnet and writes a relay-target list
PetitPotam.py and printerbug.pyCoerce a target into authenticating to a listener you choose
certipyTurns a relayed AD CS certificate into a Kerberos ticket and an NT hash

Build the target

KaliRange hosts no targets, no virtual machines and no lab files. You run this lab on your own machine, against a domain that you build. The names and 10.10.20.x addresses below are the example addresses of this lab. Replace them with the addresses of your own domain.

Your lab domain must have these hosts:

HostAddressRole
DC0110.10.20.10Domain Controller of CORP.LOCAL, LDAP, requires SMB signing
SRV0210.10.20.21Domain-joined file server, SMB signing off
CA0110.10.20.30AD Certificate Services, web enrollment enabled
KALI10.10.20.50Your own attack box

Your domain must also have:

  • The foothold account j.doe@CORP.LOCAL with the password Str0ngPass!99, a plain domain user. Use your own password and put it in the commands.
  • ms-DS-MachineAccountQuota left at its default of 10, so a normal user can create a computer account. That default is itself part of what Step 5 abuses.
  • CA01 running AD CS with HTTP web enrollment enabled and no Extended Protection for Authentication, so it accepts a relayed NTLM request (Step 6), with a DomainController certificate template that DC01$ can enroll in.
  • Admin access on DC01, SRV02 and CA01 for Step 8, where you apply and test the defences yourself.

Build such a domain from free, legal parts. Install an evaluation copy of Windows Server from the Microsoft Evaluation Center (180 days) in virtual machines on your own computer, promote one to a domain controller, join the others, and add AD CS to CA01. Or start from GOAD ("Game of Active Directory"), a deliberately vulnerable Active Directory lab that Orange Cyberdefense publishes on GitHub; its domain names differ from CORP.LOCAL, so change the names in the commands. Take a snapshot of each virtual machine before Step 1.

Authorized-lab only. Run every command in this lab only against a domain that you own or have written permission to test, here the 10.10.20.0/24 hosts above, and nowhere else. Poisoning name resolution, coercing authentication and relaying it are unauthorized access and interception in most countries when done outside a lab you own or are hired to test.

Step 1: Map the relay targets

1

Find hosts with SMB signing off across the subnet

A relay to SMB only works against a host that does not require SMB signing. Test the whole subnet first and write the hosts that qualify into a target file. Signing on means the host rejects a relayed session; there is no point aiming at it.

crackmapexec smb 10.10.20.0/24 --gen-relay-list relay_targets.txt

Example output:

SMB  10.10.20.10  445  DC01   [*] Windows Server 2022 Build 20348 (signing:True)  (SMBv1:False)
SMB  10.10.20.21  445  SRV02  [*] Windows Server 2022 Build 20348 (signing:False) (SMBv1:False)
SMB  10.10.20.30  445  CA01   [*] Windows Server 2022 Build 20348 (signing:True)  (SMBv1:False)
cat relay_targets.txt

Example output:

10.10.20.21

--gen-relay-list writes only the hosts that report signing:False to the file. In this lab that is SRV02 alone. DC01 and CA01 require signing, so they can never be an SMB relay target. This is the first lesson of the lab: SMB signing is not a nice-to-have. A host with signing on cannot be an SMB relay target.

What a defender would see. A single source address opening an SMB session to every host on the subnet in seconds is a scan, not normal traffic. Event ID 4624 with logon type 3 appears on each host, all from 10.10.20.50 in one short window. Defence: this step already names it. Require SMB signing on every host, enforced by GPO, and the SMB relay path closes before it opens.

Step 2: Configure Responder for relay mode

2

Turn off Responder's own SMB and HTTP servers, then start poisoning

Responder normally answers name-resolution requests and captures the authentication itself. For a relay you want ntlmrelayx to hold the authentication, not Responder. Turn Responder's SMB and HTTP servers off in its config, so it only poisons name resolution and hands the connection on.

Edit /etc/responder/Responder.conf and set both of these to Off:

[Responder Core]
SMB = Off
HTTP = Off

Then start Responder on your lab interface:

responder -I eth0

Example output:

[+] Listening for events...
[+] Poisoning Options:
    Analyze Mode               [OFF]
    Force WPAD auth            [OFF]
[+] Servers:
    SMB server                 [OFF]
    HTTP server                [OFF]
    LLMNR/NBT-NS/mDNS Poisoner  [ON]

With both servers OFF, Responder still answers LLMNR, NBT-NS and mDNS queries and points the target at 10.10.20.50. The target then opens an SMB or HTTP connection to your box, and ntlmrelayx, running separately, accepts it. If you leave SMB and HTTP ON, Responder answers the authentication itself and there is nothing left for the relay to catch.

What a defender would see. LLMNR and NBT-NS poisoning answers a broadcast name lookup with a wrong address. A defender who injects a non-existent hostname and watches for an answer catches a poisoner at once, because a real network has no record for that name. Defence: disable LLMNR and NBT-NS by GPO. Clients then use DNS only, and this poisoning channel disappears.

Sign in to continue

9 more sections are for signed-in members. It is free: sign in with Google.

Related