forked from dvopsway/datasploit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
domain_dnsrecords.py
42 lines (36 loc) · 1.2 KB
/
domain_dnsrecords.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys
import dns.resolver
def fetch_dns_records(domain,rec_type):
try:
answers = dns.resolver.query(domain, rec_type)
rec_list = []
for rdata in answers:
rec_list.append(rdata)
return rec_list
except:
return "No Records Found"
def parse_dns_records(domain):
print "\t\t\t[+] Fetching all DNS Records"
dict_dns_record = {}
dict_dns_record['SOA Records'] = fetch_dns_records(domain,"SOA")
dict_dns_record['MX Records'] = fetch_dns_records(domain,"MX")
dict_dns_record['TXT Records'] = fetch_dns_records(domain,"TXT")
dict_dns_record['A Records'] = fetch_dns_records(domain,"A")
dict_dns_record['Name Server Records'] = fetch_dns_records(domain,"NS")
dict_dns_record['CNAME Records'] = fetch_dns_records(domain,"CNAME")
dict_dns_record['AAAA Records'] = fetch_dns_records(domain,"AAAA")
return dict_dns_record
def main():
domain = sys.argv[1]
dns_records = parse_dns_records(domain)
for x in dns_records.keys():
print x
if "No" in dns_records[x] and "Found" in dns_records[x]:
print "\t%s" % (dns_records[x])
else:
for y in dns_records[x]:
print "\t%s" % (y)
#print type(dns_records[x])
print "\n-----------------------------\n"
if __name__ == "__main__":
main()