Visit Tim “LaNMaSteR53″ Tomes’ tools page for the latest version of the script and catch him on Episode 247 of PaulDotCom!

Recently, I (Tim Tomes) have been listening to Kevin Johnson’s (SecureIdeas) SANS SEC542 mp3s on my trips back and forth from the office just to refresh some of the basics of web app pentesting. Day 2 includes a block of instruction where Kevin talks about using advanced search engine queries to discover subdomains, replicating a dns zone transfer when zone transfers are disabled on the dns server. Basically, the technique involves making search engine requests which restrict the url and site to the target domain. Then, based on the results of the search, excluding the subdomains that are returned. Repeat until the search engine returns 0 results. The final search query excludes all of the public facing subdomains that the search engine is aware of. Conduct a dns look-up of each of the identified subdomains, and you’ve got yourself a dns zone transfer of all the subdomains with public facing web servers.

Kevin discusses a couple of tools that automate this process. Some of the tools he discusses use paid-for API keys (therefore, not openly available) while others do a lot of different things, but are not designed for this specifically. Bottom line, he doesn’t provide a tool which does this. Thus, the idea for GXFR was born.

image here

GXFR shows its strength in requiring only a few requests and having the ability to be tuned to avoid shunning. I was able to resolve 33 subdomains for (at the time) with only 8 requests and avoid shunning by employing a 5 second delay (default) between requests. GXFR also has the ability to issue requests via http or https based upon whether the ‘–no-encrypt’ option is used. If all you want to do is discover subdomains, but aren’t necessarily interested in the ip information, then exclude the ‘–dns-lookup’ option. If you want to be extra careful, or you are already shunned, you can use the ‘–proxy’ option and feed the script a list of open http/socks proxies or an ip and port of a single proxy. When using the list, the script will “proxy spray” all of your search engine queries by sending each request through a proxy randomly selected from the list. The script does some proxy validation at run-time, letting you know if the proxy is valid, and exempting it from further use if it is not. This feature provides the user will all kinds of flexibility. i.e. send requests through netcat/ssh pivots or tor, monitor requests via interception proxy, use script from behind transparent proxy, etc. The latest version of the script comes with the ability to set a custom user agent string. You’re welcome bitform! :D

There are a couple of issues. The “search engine of choice” enforces a maximum words per search limit of 32 words and a maximum search string length of 2074 characters, so GXFR is limited to identifying ~32 sub domains or less depending in which threshold you hit first. It sucks, I know. I’m currently looking for a way around these limitations without using the API. However, in the mean time, the tool still does the job of automating the task for you, as the word and character limits would still apply if the technique was done manually.

I have shared GXFR with Kevin and you can expect to see it in the SEC542 curriculum in the near future and upcoming releases of SamuraiWTF. It may also pop up in the web sections of Ed Skoudis‘ SEC504 and SEC560. As always, if we don’t share, we all fail, so please let me know if you identify any bugs while using the tool. Thanks, and enjoy!

Sample output in verbose mode: (3 proxies listed in the file ‘proxies’, 2 of which were invalid)

root@bt:~# ./ *domain-omit* --proxy proxies --dns-lookup -v
[-] domain: *domain-omit*
[-] querying search engine, please wait...
[+] sending query to
[!] subdomain found: www.
[!] subdomain found: educations.
[!] subdomain found: promotions.
[!] subdomain found: wanfest.
[+] sleeping to avoid lock-out...
[+] sending query to
[!] failed: <urlopen error Tunnel connection failed: 403 Forbidden>
[+] sending query to 1237.0.0.1:8080
[!] subdomain found: secure.
[!] subdomain found: images10.
[!] subdomain found: espanol.
[+] sleeping to avoid lock-out...
[+] sending query to 1233.171.253.70:80
[!] failed: <urlopen error Tunnel connection failed: 404 Not Found>
[+] sending query to
[!] subdomain found: twmts.
[!] subdomain found: e.
[!] subdomain found: e3wwwtest.
[!] subdomain found: m.
[!] subdomain found: biz.
[!] subdomain found: mts.
[!] subdomain found: blog.
[!] subdomain found: partner.
[!] subdomain found:
[+] sleeping to avoid lock-out...
[+] sending query to
[!] subdomain found: e4wwwtest.
[!] subdomain found: e4ssltest.
[!] subdomain found: e3ssltest.
[!] subdomain found: images17.
[+] sleeping to avoid lock-out...
[+] sending query to
[-] all available subdomains found...
[-] successful queries made: 5
[+] final query string:*domain-omit*+site%3A*domain-
[subdomains] - 20
[-] querying dns, please wait...
[+] querying dns for www.*domain-omit*...
[+] querying dns for educations.*domain-omit*...
[+] querying dns for promotions.*domain-omit*...
[+] querying dns for wanfest.*domain-omit*...
[+] querying dns for secure.*domain-omit*...
[+] querying dns for images10.*domain-omit*...
[+] querying dns for espanol.*domain-omit*...
[+] querying dns for twmts.*domain-omit*...
[+] querying dns for e.*domain-omit*...
[+] querying dns for e3wwwtest.*domain-omit*...
[+] querying dns for m.*domain-omit*...
[+] querying dns for biz.*domain-omit*...
[+] querying dns for mts.*domain-omit*...
[+] querying dns for blog.*domain-omit*...
[+] querying dns for partner.*domain-omit*...
[+] querying dns for*domain-omit*...
[+] querying dns for e4wwwtest.*domain-omit*...
[+] querying dns for e4ssltest.*domain-omit*...
[+] querying dns for e3ssltest.*domain-omit*...
[+] querying dns for images17.*domain-omit*...
[ip]            [subdomain]
1233.52.123.185  espanol.*domain-omit*
1233.52.123.188  secure.*domain-omit*
1233.52.123.185  www.*domain-omit*  e.*domain-omit*   mts.*domain-omit* blog.*domain-omit*  e3ssltest.*domain-omit*  e4wwwtest.*domain-omit*   images10.*domain-omit*   images10.*domain-omit*  e4ssltest.*domain-omit*    wanfest.*domain-omit*  biz.*domain-omit*  biz.*domain-omit*  twmts.*domain-omit*   promotions.*domain-omit*   promotions.*domain-omit*   images17.*domain-omit*   images17.*domain-omit**domain-omit*  e3wwwtest.*domain-omit*   educations.*domain-omit*   educations.*domain-omit*  m.*domain-omit*
123.140.1238.155  partner.*domain-omit*

- Tim Tomes

About the author

Leave a Reply