#!/usr/bin/python
"""
DNS Dumper: Dumps name servers for a line separated file
of domains. Just pass the file containing line separated
domains.
Author: Daniel Smith (https://github.com/ifnull/)
Usage:
dns_dumper.py --src <argument>
Options:
-h --help Show this screen.
--version Show version.
--src=<src> Specify the full domain list.
"""
from docopt import docopt
import dns.resolver
def main():
arguments = docopt(__doc__, version='DNS Dumper 0.1')
src = arguments['--src']
parse(src)
def parse(src):
data = []
file = open(src, 'r')
for line in file:
domain = line.strip()
info = resovler(domain)
data.append(info)
print info
return data
def resovler(domain):
"""
Get NS records
"""
ns = []
try:
answers = dns.resolver.query(domain, 'NS')
for server in answers:
response = server.to_text()[:-1]
ns.append(response)
return ", ".join(ns)
except:
return "FAILED"
if __name__ == "__main__":
main()