Created
October 28, 2014 20:56
-
-
Save ifnull/554b0e58c60aa927638e to your computer and use it in GitHub Desktop.
DNS Dumper: Dumps name servers for a line separated file of domains. Just pass the file containing line separated domains.
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/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment