Created
July 6, 2010 19:01
-
-
Save joebasirico/465781 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
## Attempts to get a domain transfer from the nameservers for the given domain | |
## Requires dnspython http://www.dnspython.org/ | |
import sys | |
import socket | |
from dns import resolver, query, exception | |
def do_axfr(nameserver, domain): | |
ns = str(resolver.query(nameserver, 'A')[0]) | |
try: | |
q = query.xfr(ns, domain, relativize=False) | |
for m in q: | |
print str(m) | |
print "%s\n" % ("-" * 50,) | |
except (exception.FormError, socket.error, EOFError): | |
print "AXFR failed\n" | |
return | |
if len(sys.argv) < 2: | |
print "Usage %s <domain>" % (sys.argv[0],) | |
sys.exit() | |
domain = sys.argv[1] | |
ans = resolver.query(domain, 'NS') | |
for ns in ans: | |
print "Querying %s" % (ns,) | |
print "-" * 50 | |
do_axfr(str(ns), domain) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment