Pentesting dns

From xalgord/xalgorix · View interactive version

Pentesting dns is an AI agent skill from the GitHub repository xalgord/xalgorix. Testing DNS services (default 53/TCP+UDP, 5353/UDP mDNS) for zone transfers (AXFR), version/banner disclosure, subdomain and reverse-lookup enumeration, open recursion/amplification, DNSSEC and CAA misconfiguration, and Active Directory SRV record discovery during authorized engagements.

How to use this skill

Skill file

Pentesting DNS (port 53)

When to Use

Quick Enumeration

# Version banner (works on most BIND servers)
dig version.bind CHAOS TXT @<DNS_IP>
nmap -p53 --script dns-nsid <DNS_IP>      # also grabs NSID/version

# Default DNS NSE sweep
nmap -n --script "(default and *dns*) or fcrdns or dns-srv-enum or dns-random-txid or dns-random-srcport" <IP>

# Record lookups
dig ANY  @<DNS_IP> <DOMAIN>     # everything the server will disclose
dig A    @<DNS_IP> <DOMAIN>
dig AAAA @<DNS_IP> <DOMAIN>
dig TXT  @<DNS_IP> <DOMAIN>
dig MX   @<DNS_IP> <DOMAIN>
dig NS   @<DNS_IP> <DOMAIN>
dig -x 192.168.0.2 @<DNS_IP>    # reverse lookup

# Interactive
nslookup
> SERVER <DNS_IP>
> <IP_MACHINE>                   # reverse lookup

Critical: Checks Most Often Missed

dig axfr @<DNS_IP>                 # try without a domain
dig axfr @<DNS_IP> <DOMAIN>        # try guessing the domain
fierce --domain <DOMAIN> --dns-servers <DNS_IP>   # AXFR against every NS, then dict attack
dnsrecon -d active.htb -a -n <DNS_IP>             # zone transfer

How to CONFIRM

Workflow

Step 1: Enumerate

Fingerprint with dig version.bind CHAOS TXT @<DNS_IP> / fpdns / nmap --script dns-nsid. Run the default *dns* NSE sweep. Identify whether the server is authoritative, recursive, or caching.

Step 2: Authenticate / unauth access

DNS queries are unauthenticated. Test the trust boundary instead: attempt AXFR (relies on a permissive allow-transfer), and test recursion (allow-recursion/allow-query) by querying an external domain and checking the ra flag.

Step 3: Exploit / Extract

for sub in $(cat <WORDLIST>); do dig $sub.<DOMAIN> @<DNS_IP> | grep -v ';\|SOA' | sed -r '/^\s*$/d' | grep $sub | tee -a subdomains.txt; done
dnsenum --dnsserver <DNS_IP> --enum -p 0 -s 0 -o subdomains.txt -f <WORDLIST> <DOMAIN>
dnsrecon -D subdomains-1000.txt -d <DOMAIN> -n <DNS_IP>
dnsrecon -r 127.0.0.0/24 -n <DNS_IP>     # reverse sweep
dnsdict6 -s -t <domain>                   # IPv6 (AAAA) brute force
dig -t _gc._tcp.lab.domain.com
dig -t _ldap._tcp.lab.domain.com
dig -t _kerberos._tcp.lab.domain.com
nmap --script dns-srv-enum --script-args "dns-srv-enum.domain='domain.com'"
nmap -sSU -p53 --script dns-nsec-enum --script-args dns-nsec-enum.domains=<DOMAIN> <NS_IP>  # NSEC walk

Step 4: Post-access / pivot

Use recovered hostnames/IPs (especially internal-IP subdomains) to reach internal services; if a subdomain resolves to an internal IP, do reverse-DNS brute forcing of that range against the zone's NS. Send mail to a non-existent address at the domain to harvest internal server names/IPs from the NDN bounce headers.

Key Concepts

| Concept | Description |

|---------|-------------|

| AXFR | Asynchronous Full Transfer Zone — dumps an entire zone if allow-transfer is permissive |

| Authoritative vs recursive/caching | Authoritative answers for its zones; recursive resolves for clients (recursion = amplification risk) |

| ra flag | "Recursion available" in the response; indicates open recursion |

| SRV records | _service._proto records locating servers (AD DCs via _kerberos/_ldap/_gc) |

| DNSSEC / NSEC | Signed zones; NSEC chains can be walked to enumerate names |

| CAA | Authorizes which CAs may issue certs; over-broad policy widens cert-abuse surface |

Tools & Systems

| Tool | Purpose |

|------|---------|

| dig | All record types, AXFR, version.bind, recursion/DNSSEC checks |

| nslookup | Interactive queries / reverse lookups |

| fierce | AXFR attempts against every NS then dictionary brute force |

| dnsrecon | Zone transfer, reverse sweeps, subdomain brute force |

| dnsenum | Subdomain enumeration with wordlists |

| dnscan / dnsdict6 | Recursive and IPv6 subdomain brute forcing |

| nmap dns-* NSE | dns-nsid, dns-srv-enum, dns-nsec-enum, recursion checks |

| Metasploit | auxiliary/gather/enum_dns, auxiliary/scanner/dns/dns_amp |

Common Scenarios

Scenario 1: Open AXFR

dig axfr @<DNS_IP> <DOMAIN> succeeds and dumps the full zone, exposing every internal hostname and IP — instant attack-surface map.

Scenario 2: AD domain controller discovery

SRV queries for _ldap._tcp and _kerberos._tcp return the FQDNs and ports of domain controllers, seeding AD attacks.

Scenario 3: Open recursion amplifier

dig google.com A @<IP> shows the ra flag; the resolver can be abused for ANY/DNSSEC reflection amplification.

Output Format

## DNS Finding

**Service**: DNS (53/tcp+udp)
**Severity**: <High|Medium|Low>
**Target**: <DNS_IP>  Software: <BIND x.y | Microsoft DNS ...>

### Evidence
- AXFR allowed: dig axfr @<IP> <DOMAIN> returned full zone (<N> records)
- Recursion available (ra flag) -> amplification risk
- AD SRV records disclosed DCs: <hostnames>
- version.bind: <version string>

### Reproduction
dig axfr @<DNS_IP> <DOMAIN>
dig google.com A @<DNS_IP>     # check ra flag

### Recommendation
1. Restrict `allow-transfer` to secondary NS only; block AXFR from untrusted IPs
2. Disable recursion on authoritative servers (`allow-recursion`/`recursion no`)
3. Hide version (`version "";` in BIND options)
4. Tighten CAA, ensure DNSSEC key rollover (DS/CDS) is consistent
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.