Backtrack 4: Information Gathering: DNS: Dnsmap – Subdomain brute-forcing
Today I will be reviewing Dnsmap from the Backtrack 4 Distribution. Dnsmap was originally released back in 2006 and has become a standard tool included is every backtrack release. There are other tools which preform the same tasks but I am a firm believer that a pentester/hacker should have the choice of as many tools as possible. My only small issue with this tool is speed, meaning it is not multi threaded however the author says in the readme.txt that he is addressing that issue. Dnsmap is mainly meant to be used by pentesters during the information gathering/enumeration phase of infrastructure security assessments. During the enumeration stage, the security consultant would typically discover the target
company’s IP netblocks, domain names, phone numbers, etc …
Subdomain brute-forcing is another technique that should be used in the enumeration stage, as it’s especially useful when other domain enumeration techniques such as zone transfers don’t work.
Here are some things that Dnsmap can be used for:
1. Finding interesting remote access servers (e.g.: https://extranet.example.com)
2. Finding badly configured and/or unpatched servers (e.g.: test.example.com)
3. Finding new domain names which will allow you to map non-obvious/hard-to-find netblocks
4. Sometimes you find that some bruteforced subdomains resolve to internal IP addresses
(RFC 1918). This is great as sometimes they are real up-to-date “A” records which means
that it *is* possible to enumerate internal servers of a target organization from the
Internet by only using standard DNS resolving (as oppossed to zone transfers for instance).
5. Discover embedded devices configured using Dynamic DNS services (e.g.: linksys-cam.com).
This method is an alternative to finding devices via Google hacking techniques
Bruteforcing can be done either with dnsmap’s built-in wordlist or a user-supplied wordlist. Results can be saved in CSV and human-readable format for further processing. dnsmap does NOT require root privileges to be run.
Most of the preceding information came from the README.txt that the author supplied with the tool, I didn’t think there was any reason to rewrite it all and reinvent the wheel. I will just be showing you a sample session of how I would use Dnsmap in a penetration test.
First lets check out the usage:
root@666:/pentest/enumeration/dns/dnsmap# ./dnsmap dnsmap 0.30 - DNS Network Mapper by pagvac (gnucitizen.org) usage: dnsmap <target-domain> [options] options: -w <wordlist-file> -r <regular-results-file> -c <csv-results-file> -d <delay-millisecs> -i <ips-to-ignore> (useful if you're obtaining false positives) e.g.: dnsmap target-domain.foo dnsmap target-domain.foo -w yourwordlist.txt -r /tmp/domainbf_results.txt dnsmap target-fomain.foo -r /tmp/ -d 3000 dnsmap target-fomain.foo -r ./domainbf_results.txt
Pretty simple tool so lets show a example session:
root@666:/pentest/enumeration/dns/dnsmap# ./dnsmap cnn.com -r results.txt dnsmap 0.30 - DNS Network Mapper by pagvac (gnucitizen.org) [+] searching (sub)domains for cnn.com using built-in wordlist [+] using maximum random delay of 10 millisecond(s) between requests a.cnn.com IP address #1: 18.104.22.168 IP address #2: 22.214.171.124 aa.cnn.com IP address #1: 126.96.36.199 IP address #2: 188.8.131.52 ab.cnn.com IP address #1: 184.108.40.206 IP address #2: 220.127.116.11 ac.cnn.com IP address #1: 18.104.22.168 IP address #2: 22.214.171.124 access.cnn.com IP address #1: 126.96.36.199 accounting.cnn.com IP address #1: 188.8.131.52 IP address #2: 184.108.40.206 accounts.cnn.com IP address #1: 220.127.116.11 IP address #2: 18.104.22.168
What we are doing here is attempting to bruteforce all of the subdomains of cnn.com and saving them to a file called results.txt. I have truncated the output since its very long.
If you have a custom wordlist of subdomains you can use that as well simply by specifying the -w argument and then the path to the wordlist.
Once Dnsmap has completed its run we can look in the file and see all the subdomains and IPs in the list:
root@666:/pentest/enumeration/dns/dnsmap# head results.txt a.cnn.com IP address #1: 22.214.171.124 IP address #2: 126.96.36.199 aa.cnn.com IP address #1: 188.8.131.52 IP address #2: 184.108.40.206 ab.cnn.com IP address #1: 220.127.116.11
Now, for you this may be a good format but what I want is a list of IPs to add to my list of possible targets when I move on to a more active scanning phase of the pentest.
So lets apply a little bashfoo to clean up this list:
root@666:/pentest/enumeration/dns/dnsmap# cat results.txt | sed '/^$/d' | sed '/cnn.com/d' | cut -d ':' -f 2 | sort -u | sed '$d' > ips.txt
And now we have a nice tidy list of IP addresses for the next phase of our attack:
root@666:/pentest/enumeration/dns/dnsmap# cat ips.txt 18.104.22.168 127.0.0.1 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11
There is also a script to bruteforce a list of domains if you are looking at a very large attack surface:
usage: dnsmap-bulk.sh <domains-file> [results-path] e.g.: dnsmap-bulk.sh domains.txt dnsmap-bulk.sh domains.txt /tmp/
I hope this review of dnsmap is helpful and I would like to give a big thanks to GNUCitizen for Dnsmap and all the rest of the stuff they do for the opensource community.