DNS
CPTS Notes
- Start Here
- General Framework
- Enumeration
- Enumeration with Nmap
- Services
- FTP
- SMB
- NFS
- DNS
- SMTP
- IMAP
- POP3
- Reference
- Port References
- Linux Commands Cheatsheet
- DNS Resolution
- The Mail Pipeline
- SMB & NetBIOS
TL;DR
DNS (Domain Name System). Resolves names to addresses. UDP and TCP 53. UDP serves normal queries. TCP serves zone transfers and any response over 512 bytes. A zone transfer (AXFR) is how a secondary server syncs the full zone from the primary, which is why a misconfigured one hands the whole zone to anyone who asks.
First checks: a zone transfer, the records, and subdomains. DNS enumeration needs a domain name.
On a box you often guess it (bank.htb) or read it from a certificate or another service, then set
$DOMAIN and add it to /etc/hosts.
Protocol background is in DNS Resolution.
Records
| Record | Returns |
|---|---|
| A / AAAA | IPv4 / IPv6 address. |
| NS | The zone’s nameservers. |
| MX | Mail servers. |
| TXT | Free text: SPF, DKIM, domain-verification tokens, sometimes secrets. |
| CNAME | Alias to another name. |
| SOA | Zone info and the admin email (the first . stands for @). |
| PTR | Reverse lookup, IP to name. |
| SRV | Service locations (_ldap, _kerberos). |
Enumeration
Workflow: query records with dig, try a zone transfer, then brute subdomains.
Query records.
dig any $DOMAIN @$TARGETdig ns $DOMAIN @$TARGETdig mx $DOMAIN @$TARGETdig txt $DOMAIN @$TARGETdig soa $DOMAIN @$TARGETdig ch txt version.bind @$TARGET@$TARGET sends the query to that server. any asks for every record type, which many servers now
refuse. soa returns the admin contact and primary nameserver. ch txt version.bind asks the
CHAOS-class record that leaks the BIND version when the server exposes it.
Zone transfer (AXFR). The jackpot. A misconfigured server dumps every record:
dig axfr $DOMAIN @$TARGETaxfr requests a full zone transfer: internal hostnames, IPs, and subdomains in one reply.
Brute subdomains when AXFR fails.
subfinder -d $DOMAIN -silent | dnsx -silentpuredns bruteforce wordlist.txt $DOMAIN -r resolvers.txtsubfinder pulls subdomains from passive sources. dnsx resolves a list fast. puredns
brute-forces a wordlist and resolves each name against live resolvers (-r). The all-in-one classics are
dnsenum $DOMAIN and dnsrecon -d $DOMAIN.
nmap.
sudo nmap -p53 -sV --script dns-recursion,dns-nsid,dns-zone-transfer --script-args dns-zone-transfer.domain=$DOMAIN -oA scans/dns $TARGETCommon misconfigurations
- Zone transfer (AXFR) allowed to any client.
- Internal records answered to external queries (split-horizon leak).
- Dynamic updates allowed without authentication.
- DNSSEC NSEC records let an attacker walk the whole zone.
- Open recursion, which enables cache poisoning and amplification.
Attack playbook
DNS is reconnaissance, not a target. Mine it to map the environment.
- Zone transfer.
dig axfrfirst. One misconfig dumps the whole internal namespace. Transfer any internal zones it reveals too (dig axfr internal.$DOMAIN @$TARGET), which leak domain controllers, VPN, and workstation hosts. - Brute subdomains. When AXFR fails, brute and resolve. New names are vhosts, dev and staging
hosts, and internal services. Add each to
/etc/hosts, then enumerate the web and other services on it. - Harvest records. MX names the mail server. TXT leaks SPF entries, keys, and verification
tokens. SRV locates services (
_ldap,_kerberospoint to Active Directory). NS names the authoritative servers. - Zone walking. DNSSEC NSEC chains leak every name even without AXFR:
ldns-walk @$TARGET $DOMAINPractice boxes
| Box | Difficulty | DNS’s role |
|---|---|---|
| Cronos | Easy | Zone transfer reveals admin.cronos.htb, the foothold. |
| FriendZone | Easy | Zone transfer reveals subdomains leading to an LFI-to-RCE panel. |
| Bank | Easy | Zone transfer reveals the bank.htb vhost to enumerate. |
DNS is almost always recon, not the foothold itself. The win is the hostnames and subdomains it leaks, which point you at the real target.