githubEdit

DNS (Domain Name Systems) Pentesting

DNS is often called as a phonebook for internet. A default port is 53.

Enumeration

# Nmap
nmap --script dns-nsec-enum --script-args dns-nsec-enum.domains vulnerable.com -p 53 <target-ip>
nmap --script dns-random-srcport -p 53 <target-ip>
nmap --script dns-recursion -p 53 <target-ip>
nmap --script dns-service-discovery -p 53 <target-ip>
nmap --script dns-* -p 53 <target-ip>
nmap -n --script "(default and *dns*) or fcrdns or dns-srv-enum or dns-random-txid or dns-random-srcport" <target-ip>

# Get IP address from the domain
host example.com

# Reverse Lookup (Resolves domain name from IP address)
dig -x <ip>
dig -x 8.8.8.8

Online Tools

Subdomain Discovery

Reference: Hackviserarrow-up-right

DNS Records

Zone Transfer

The zone transfer is the process of copying the zone file on a primary DNS server to a secondary DNS server.

BIND

BIND is the most commonly used DNS server.

Configuration Files

Update DNS Zone

If we found the secret key such like below, we can update DNS zone.

To update, run the following command using the key.

Resolve Domains and IP Addresses in /etc/hosts

Edit /etc/hosts file as root to add custom domains.

If you want to force the system to reflect the changes, restart hostnamed.

Set DNS Resolver in /etc/resolv.conf

Edit /etc/resolv.conf file as root to add custom nameservers.

Google Nameservers

Cloudflare Nameservers

If you want to force the system to reflect the changes, restart resolved.

DNS Spoofing

Also known as DNS cache poisoning. It corrupts Domain Name System data is introduced into the DNS resolver's cache, causing the name server to return an incorrect result record, e.g. an IP address.

Flush the DNS Cache

Clear IP addresses or DNS records from caches.

Check DNS caches are actually flushed

DNS Exfiltration

dns-exfil-infilarrow-up-right

DNS Infiltration

Coming soon...

DNS Tunneling

Iodinearrow-up-right

Last updated