Created
June 30, 2010 23:30
-
-
Save craSH/459362 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, socket | |
from dns import resolver, rdatatype, query | |
import dns.exception | |
def do_axfr(nameserver, domain): | |
print "Querying %s" % (nameserver,) | |
print "-" * 50 | |
ns = socket.gethostbyname(nameserver) | |
try: | |
q = query.xfr(ns, domain) | |
for m in q: | |
print str(m) | |
print "%s\n" % ("-" * 50,) | |
except dns.exception.FormError: | |
print "AXFR failed\n" | |
return | |
if len(sys.argv) < 2: | |
print "Usage %s <domain>" % (sys.argv[0],) | |
sys.exit() | |
domain = sys.argv[1] | |
r = resolver.Resolver() | |
ans = r.query(domain, rdatatype.NS) | |
for ns in ans: | |
do_axfr(str(ns), domain) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment