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: 8.15.7.123
- IP address #2: 63.251.179.23
- aa.cnn.com
- IP address #1: 8.15.7.123
- IP address #2: 63.251.179.23
- ab.cnn.com
- IP address #1: 8.15.7.123
- IP address #2: 63.251.179.23
- ac.cnn.com
- IP address #1: 8.15.7.123
- IP address #2: 63.251.179.23
- access.cnn.com
- IP address #1: 64.20.247.69
- accounting.cnn.com
- IP address #1: 8.15.7.123
- IP address #2: 63.251.179.23
- accounts.cnn.com
- IP address #1: 8.15.7.123
- IP address #2: 63.251.179.23
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: 8.15.7.123
- IP address #2: 63.251.179.23
- aa.cnn.com
- IP address #1: 8.15.7.123
- IP address #2: 63.251.179.23
- ab.cnn.com
- IP address #1: 8.15.7.123
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
- 1.1.1.1
- 127.0.0.1
- 157.166.173.183
- 157.166.217.28
- 157.166.224.104
- 157.166.224.105
- 157.166.224.111
- 157.166.224.164
- 157.166.224.172
- 157.166.224.184
- 157.166.224.186
- 157.166.224.25
- 157.166.224.26
- 157.166.226.104
- 157.166.226.105
- 157.166.226.111
- 157.166.226.164
- 157.166.226.184
- 157.166.226.186
- 157.166.226.25
- 157.166.226.26
- 157.166.236.106
- 157.166.255.172
- 157.166.255.18
- 157.166.255.19
- 157.166.255.22
- 157.166.255.23
- 205.188.146.88
- 207.25.71.114
- 207.25.71.230
- 207.25.71.91
- 207.25.71.97
- 207.25.79.134
- 207.25.79.135
- 6.9.6.9
- 63.251.179.23
- 64.20.247.69
- 64.236.16.20
- 64.236.17.108
- 64.236.18.7
- 64.236.22.11
- 64.236.22.12
- 64.236.24.12
- 64.236.24.4
- 64.236.26.21
- 64.236.29.11
- 64.236.29.12
- 66.9.53.137
- 8.15.7.123
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.
There are two more ways to find the subdomains. AXFR and search engine results.
You can find subdomains using this page:
*LINK REMOVED FOR SPAM*
If zone transfer is not possible, this tool will use search engine results.
Thanks for the insight. There are lots of ways to find sub domains but this series of articles is meant to focus on the tools in Backtrack-Linux.
I think you are referring to gxfr.py. It’s a script that uses google search results to find sub domains passively. Here is a tutorial on how to install and use it:
URL: itswapshop.com/tutorial/gxfrpy-sub-domain-discovering-script-using-google-queries
If you are trying to find sub domains, use dnsmap and gxfr.py to get the most results.