TExcelTAD
Home › Windows & Active Directory Security › AD DNS, SRV Records and Name Poisoning

AD DNS, SRV Records and Name Poisoning

A Windows machine that wants to sign in to corp.lab.test doesn't have a list of domain controllers. It asks DNS: "where are the LDAP servers for domain controllers of corp.lab.test?", and DNS answers with SRV records. The whole domain depends on that answer, which makes DNS part of Tier 0. And when DNS has no answer, for a mistyped share name or a proxy auto-discovery lookup, Windows asks the local network instead, over LLMNR and NetBIOS name service, where anyone can reply. Answering those questions falsely is one of the oldest and still most effective ways to collect NTLM authentication inside a network. This lesson shows both: what the domain's DNS looks like, and how name poisoning is detected and switched off.

DNS fundamentals and spoofing are in DNS Resolution and Record Types and DNS Spoofing, Cache Poisoning and DNSSEC.

How clients find domain controllers

The DC locator (part of Netlogon) queries SRV records registered by every DC:

Record Finds
_ldap._tcp.dc._msdcs.<domain> any DC of the domain
_ldap._tcp.<site>._sites.dc._msdcs.<domain> a DC in the client's site
_kerberos._tcp.<domain> / _kerberos._udp.<domain> KDCs
_kpasswd._tcp.<domain> Kerberos password change
_ldap._tcp.gc._msdcs.<forest root> global catalog servers
_ldap._tcp.pdc._msdcs.<domain> the PDC emulator

A SRV record carries priority, weight, port and target. The session below runs a small authoritative DNS server for the lab domain in your sandbox (dnsmasq on 127.0.0.1:5353, no network, nothing outside the sandbox is contacted) with the records a single-DC domain registers, and queries it with dig the way the locator would.

bash · try it yourself
cat > corp.conf <<'CONF'
port=5353
listen-address=127.0.0.1
bind-interfaces
no-resolv
no-hosts
log-facility=/dev/null
local=/corp.lab.test/
host-record=dc01.corp.lab.test,10.10.0.20
host-record=ws01.corp.lab.test,10.10.0.21
srv-host=_ldap._tcp.dc._msdcs.corp.lab.test,dc01.corp.lab.test,389,0,100
srv-host=_kerberos._tcp.corp.lab.test,dc01.corp.lab.test,88,0,100
srv-host=_kpasswd._tcp.corp.lab.test,dc01.corp.lab.test,464,0,100
srv-host=_ldap._tcp.gc._msdcs.corp.lab.test,dc01.corp.lab.test,3268,0,100
CONF
dnsmasq --conf-file=corp.conf --pid-file="$PWD/dns.pid"
for i in $(seq 50); do dig @127.0.0.1 -p 5353 +short dc01.corp.lab.test >/dev/null && break; sleep 0.1; done
echo "== domain controllers (LDAP)";  dig @127.0.0.1 -p 5353 +short SRV _ldap._tcp.dc._msdcs.corp.lab.test
echo "== KDCs";                       dig @127.0.0.1 -p 5353 +short SRV _kerberos._tcp.corp.lab.test
echo "== global catalog";             dig @127.0.0.1 -p 5353 +short SRV _ldap._tcp.gc._msdcs.corp.lab.test
echo "== the DC itself";              dig @127.0.0.1 -p 5353 +short dc01.corp.lab.test
echo "== a name nobody registered";   dig @127.0.0.1 -p 5353 wpad.corp.lab.test | grep -E 'status|ANSWER:'
kill "$(cat dns.pid)"
== domain controllers (LDAP)
0 100 389 dc01.corp.lab.test.
== KDCs
0 100 88 dc01.corp.lab.test.
== global catalog
0 100 3268 dc01.corp.lab.test.
== the DC itself
10.10.0.20
== a name nobody registered
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 39682
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

Each SRV answer reads priority weight port target. The last query is the interesting one: wpad.corp.lab.test doesn't exist (NXDOMAIN). Web browsers and the WinHTTP stack look up wpad to discover a proxy configuration. When DNS says no, a Windows client may ask the local link next.

LLMNR and NBT-NS poisoning

LLMNR (Link-Local Multicast Name Resolution, UDP 5355, multicast 224.0.0.252) and NetBIOS Name Service (NBT-NS, UDP 137, broadcast) let machines resolve names without a DNS server. They have no authentication: whoever answers first is believed. A poisoner on the same network segment answers every such query with its own address. The victim then connects to it (to a mistyped file share \\fileserv, or to the "proxy" wpad) and, being a Windows client talking to what it thinks is an intranet server, offers NTLM authentication. The poisoner collects the NTLMv2 response for offline guessing or relays it to another server in real time (NTLM Relay). The best-known tool for this is Responder; Inveigh does the same in PowerShell and .NET. To a defender they look alike: one host answering name queries for many different names.

AD-integrated DNS as an attack surface

AD-integrated zones live in the directory, and by default any authenticated user may create new records in them (the zone grants "Create all child objects" to Authenticated Users so that machines can register themselves). Two consequences:

  • A user can register a name that doesn't exist yet, such as wpad or a wildcard *, and point it at their own machine. The DNS server's global query block list (by default wpad and isatap) stops the obvious one, but not every name.
  • A user can register names in advance for servers that are being planned.

Detecting poisoning in name-resolution logs

Network sensors record who answered which name: Zeek's DNS analyser, for example, parses LLMNR (UDP 5355), mDNS (UDP 5353) and NetBIOS name service (UDP 137) traffic into the same dns.log as ordinary DNS. The program flags responders that answer for many distinct names in a short window, and responders whose answer differs from what DNS holds for that name. The events are synthetic, from the lab segment 10.10.0.0/24.

python · try it yourself
import pandas as pd

answers = pd.DataFrame([
    # time, protocol, query name, responder, answered address
    ("10:00:01", "llmnr", "fileserv", "10.10.0.66", "10.10.0.66"),
    ("10:00:03", "nbns",  "FILESERV", "10.10.0.66", "10.10.0.66"),
    ("10:00:09", "llmnr", "wpad",     "10.10.0.66", "10.10.0.66"),
    ("10:00:15", "llmnr", "printer2", "10.10.0.66", "10.10.0.66"),
    ("10:00:20", "llmnr", "ws02",     "10.10.0.22", "10.10.0.22"),
    ("10:00:31", "llmnr", "sharepnt", "10.10.0.66", "10.10.0.66"),
    ("10:00:40", "llmnr", "fs01",     "10.10.0.66", "10.10.0.66"),
], columns=["time", "proto", "name", "responder", "answer"])
dns = {"fs01": "10.10.0.23", "ws02": "10.10.0.22"}        # what AD DNS holds

answers["name"] = answers["name"].str.lower()
per_responder = answers.groupby("responder")["name"].nunique()
print("distinct names answered per responder:")
print(per_responder.to_string())
suspects = per_responder[per_responder >= 3].index.tolist()
print("ALERT many-name responders:", suspects)

conflict = answers[answers["name"].map(dns).notna() & (answers["answer"] != answers["name"].map(dns))]
for _, r in conflict.iterrows():
    print(f"ALERT {r['time']} {r['proto']} answer for {r['name']} = {r['answer']}, DNS says {dns[r['name']]}")
distinct names answered per responder:
responder
10.10.0.22    1
10.10.0.66    5
ALERT many-name responders: ['10.10.0.66']
ALERT 10:00:40 llmnr answer for fs01 = 10.10.0.66, DNS says 10.10.0.23

10.10.0.66 answered five different names, including fs01, for which it also contradicts DNS. A real host answers only for its own name, as ws02 does.

More ways to detect it

  • Network: any LLMNR or NBT-NS response on a network where both are disabled is an alert by itself; IDS rules match responses from hosts that aren't the queried name.
  • Endpoints: 4648 or NTLM authentication (4624 type 3, package NTLM) from workstations to an unexpected IP; Sysmon 22 (DNS query) shows the lookups that fell through.
  • Canaries: a script on a monitoring host periodically asks LLMNR for a name that doesn't exist (fileserver-canary); any answer reveals a poisoner. Some EDR and NDR products ship this check.
  • DNS changes: new wpad, wildcard or unusual records in AD-integrated zones show as 5136/5137 on dnsNode objects (with a SACL on the zone) and in the DNS server audit log (Microsoft-Windows-DNSServer/Audit).

How it is fixed or prevented

  • Turn LLMNR off with Group Policy ("Turn off multicast name resolution", the EnableMulticast = 0 value of Registry Settings) and NetBIOS over TCP/IP off on every interface (DHCP option or adapter setting). Check that nothing still depends on them.
  • Disable WPAD where no proxy auto-discovery is used, or publish a legitimate wpad record and PAC file.
  • Require SMB signing and restrict NTLM, so that collected authentication can't be relayed and is less useful (NTLM Relay, Removing NTLM); strong passwords make offline guessing of NTLMv2 responses impractical.
  • Restrict who may create records in AD-integrated zones, or pre-create sensitive names; keep the global query block list.
  • Secure dynamic updates only; scavenging of stale records; DNSSEC for zones where clients validate.

Pitfalls

  • Disabling LLMNR but not NBT-NS (or the reverse). Both must go; mDNS is a third, smaller channel on newer Windows.
  • VPN and Wi-Fi adapters with NetBIOS still enabled after the wired adapters were fixed.
  • Treating DNS servers as infrastructure, not Tier 0. Whoever controls DC records controls where clients authenticate.
  • Assuming segmentation helps within a VLAN. Poisoning works on the local segment, which is exactly where users are.

Practice

1. Which SRV record does a client in site HQ look up first to find a nearby DC of corp.lab.test?

_ldap._tcp.HQ._sites.dc._msdcs.corp.lab.test, falling back to _ldap._tcp.dc._msdcs.corp.lab.test.

2. A user mistypes \\fs10\share. Walk through what happens with and without LLMNR enabled.

With LLMNR: DNS returns NXDOMAIN, the client multicasts an LLMNR query, a poisoner answers, the client connects to it over SMB and offers NTLM authentication. Without LLMNR and NBT-NS: the lookup fails and the user sees an error; nothing is sent.

3. Change the detection threshold to 2 names. What new false positive could appear on a real network, and how would you avoid it?

A legitimate host that answers for its own name plus an alias, or a dual-homed server. Keep an allow-list of known multi-name hosts and compare answers with DNS, which is the stronger signal.

Test yourself

Which DNS record type lets Windows clients locate domain controllers?

  1. MX
  2. SRV
  3. PTR
  4. TXT

Why is LLMNR poisoning effective?

  1. LLMNR uses weak encryption
  2. LLMNR and NBT-NS have no authentication: the first answer is believed, and the client then offers NTLM authentication to the poisoner
  3. It requires domain admin
  4. It only works on DCs

By default, who can create new records in an AD-integrated DNS zone?

  1. Only Domain Admins
  2. Any authenticated user
  3. Nobody
  4. Only DCs

Which UDP port does LLMNR use?

  1. 53
  2. 137
  3. 5355
  4. 88