DNS Pentest
DNS enumeration, subdomain recon and attacks
Enumeration
Finding addresses with host
command
host
commandThe host
command is a DNS lookup utility which can be used to find the IP address associated with a hostname. Host is a simple utility for performing DNS lookups. It is normally used to convert names to IP addresses and vice versa.
When no arguments or options are given, host prints a short summary of its command-line arguments and options.
Using whois
whois
WHOIS is a request and response protocol that follows the RFC 3912 specification. A WHOIS server listens on TCP port 43
for incoming requests.
The domain registrar is responsible for maintaining the WHOIS records for the domain names it is leasing. whois
will query the WHOIS server to provide all saved records.
After a whois
lookup, we might get lucky and find names, email addresses, postal addresses, and phone numbers, in addition to other technical information.
At the end of the whois
query, we find the authoritative name servers for the domain in question.
Using dig
command
dig
commandThe dig command or (domain information groper can be used to dig into the DNS records.
DNS Enumeration with Zone Transfer Records
Using zone transfer, an attacker attempts to retrieve a copy of the entire zone file for a domain from the DNS server.
Using the ANSWER section domain names we can search for Zone transfers.
DNS Cache snooping with dig
NS cache snooping is a DNS enumeration technique whereby an attacker queries the DNS server for a specific cached DNS record.
Non-recursive: Attackers send a non-recursive query by setting the Recursion Desired (RD) bit in the query header to zero.
Recursive: Attackers send a recursive query to determine the time the DNS record resides in the cache.
Finding CNAME records
Finding TXT and SPF records
More dig commands
Using nslookup
command
nslookup
commandFinding SOA
We can find the SOA record of a nameserver using nslookup
. Consider google.com as an example:
We get a response specifying the primary name server and associated information:
Basic enum with authoritative answers or Find IPs to which a domain resolves
An authoritative answer is a response we get directly from the primary DNS server holding the master copy of the zone file. To find the authoritative answer for google.com, we execute a new nslookup
query in which we specify the primary name server as ns1.google.com
.
Upon executing the command, we’ll get the following response, which gives us the addresses of the authoritative server for the specified domain.
Reverse DNS lookup
You can also do the reverse DNS look-up by providing the IP Address as an argument to nslookup.
DNS Zone Transfer with nslookup
Using fierce for Zone transfer
Will try to perform a zone transfer against every authoritative name server and if this doesn't work, will launch a dictionary attack
Using DNS recon
To find zone transfer
Reverse DNS Brute Force
DNSSEC Zone Walking
Domain Name System Security Extensions (DNSSEC) zone walking is a type of DNS enumeration technique in which an attacker attempts to obtain internal records if the DNS zone is not properly configured. The enumerated zone information can assist the attacker in building a host network map
An example is as follows:
Using nmap
nmap
Basic Service Discovery with DNS details
Retrieve all the subdomains associated with the target host
Check whether DNS recursion is enabled on the target server
DNS Security Extensions (DNSSEC) Enumeration Using Nmap
Enumerate DNSSEC using dns-nsec-enum.nse
or dns-nsec3-enum.nse
NSE scripts to obtain information related to domains and their subdomains.
Passive Subdomain Enumeration
Exploitation
DNS Exfiltration
DNS Infiltration
DNS tunnelling
DNS Spoofing
DNS spoofing, or DNS cache poisoning, involves using altered DNS records to redirect online traffic to a fraudulent site that impersonates the intended destination. Once users reach the fraudulent destination, they are prompted to login into their account.
Subdomain takeovers
What is a Subdomain takeover?
If the process of provisioning or deprovisioning (removing) a virtual host is not handled properly, there can be an opportunity for an attacker to take over a subdomain.
A subdomain takeover occurs when an attacker gains control over a subdomain of a target domain. Typically, this happens when the subdomain has a canonical name (CNAME) in the Domain Name System (DNS), but no host is providing content for it.
This can happen because either a virtual host hasn't been published yet or a virtual host has been removed.
An attacker can take over that subdomain by providing their own virtual host and then hosting their own content for it.
How do they happen?
If the process of provisioning or deprovisioning (removing) a virtual host is not handled properly, there can be an opportunity for an attacker to take over a subdomain.
Last updated