Skip to content

Instantly share code, notes, and snippets.

@joebasirico
Created July 6, 2010 19:01
Show Gist options
  • Save joebasirico/465781 to your computer and use it in GitHub Desktop.
Save joebasirico/465781 to your computer and use it in GitHub Desktop.
#!/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