mirror of
https://github.com/0xdade/HackerStuff.git
synced 2025-10-29 16:59:27 +00:00
Add in an A-record query, print output like amass
This commit is contained in:
parent
0ea7d165e2
commit
637498e28c
@ -8,23 +8,23 @@ Requires:
|
|||||||
- pip install dnspython
|
- pip install dnspython
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
import dns.rdatatype
|
import dns.rdatatype
|
||||||
import dns.query
|
import dns.query
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
targetDomain = sys.argv[1] # pass in a target domain to walk
|
targetDomain = sys.argv[1] # pass in a target domain to walk
|
||||||
|
|
||||||
# If the provided domain doesn't end with a '.', add one so that we can compare against the actual DNS records
|
# If the provided domain doesn't end with a '.', add one so that we can compare against the actual DNS records
|
||||||
if not targetDomain.endswith('.'):
|
if not targetDomain.endswith('.'):
|
||||||
targetDomain+='.'
|
targetDomain+='.'
|
||||||
print("Target Domain: %s" % targetDomain)
|
#print("Target Domain: %s" % targetDomain)
|
||||||
|
|
||||||
# we set nextDomain so that we can loop starting at the beginning
|
# we set nextDomain so that we can loop starting at the beginning
|
||||||
nextDomain = targetDomain
|
nextDomain = targetDomain
|
||||||
resolv = dns.resolver.Resolver()
|
resolv = dns.resolver.Resolver()
|
||||||
|
|
||||||
# Get and then set the authoritative nameservers
|
# Get and then set the authoritative nameservers
|
||||||
nsnames = resolv.query(targetDomain, dns.rdatatype.NS).rrset
|
nsnames = resolv.query(targetDomain, dns.rdatatype.NS).rrset
|
||||||
nsaddrs = []
|
nsaddrs = []
|
||||||
@ -32,24 +32,37 @@ def main():
|
|||||||
# take the first A record for the name and append it to our nameserver list
|
# take the first A record for the name and append it to our nameserver list
|
||||||
nsaddrs.append(resolv.query(str(name), dns.rdatatype.A).rrset[0].to_text())
|
nsaddrs.append(resolv.query(str(name), dns.rdatatype.A).rrset[0].to_text())
|
||||||
resolv.nameservers = nsaddrs
|
resolv.nameservers = nsaddrs
|
||||||
|
|
||||||
try:
|
while nextDomain:
|
||||||
while nextDomain:
|
outstr = str(nextDomain)[:-1] + " "
|
||||||
|
try:
|
||||||
|
arec = resolv.query(nextDomain, 'A')
|
||||||
|
for rdata in arec:
|
||||||
|
outstr += str(rdata) + ","
|
||||||
|
except dns.resolver.NoAnswer:
|
||||||
|
pass
|
||||||
|
except dns.resolver.NXDOMAIN:
|
||||||
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
raise
|
||||||
|
print(outstr[:-1])
|
||||||
|
|
||||||
|
try:
|
||||||
ans = resolv.query(nextDomain, 'NSEC')
|
ans = resolv.query(nextDomain, 'NSEC')
|
||||||
for item in ans.response.answer:
|
for item in ans.response.answer:
|
||||||
for sub in item:
|
for sub in item:
|
||||||
# since it's a cyclical list, stop when we reach the beginning
|
# since it's a cyclical list, stop when we reach the beginning
|
||||||
if str(sub.next) != targetDomain:
|
if str(sub.next) != targetDomain:
|
||||||
print(sub.next)
|
#print(sub.next)
|
||||||
nextDomain = sub.next
|
nextDomain = sub.next
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
except dns.resolver.NoAnswer:
|
except dns.resolver.NoAnswer:
|
||||||
return
|
pass
|
||||||
except dns.resolver.NXDOMAIN:
|
except dns.resolver.NXDOMAIN:
|
||||||
return
|
pass
|
||||||
except:
|
except Exception as e:
|
||||||
return
|
raise
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user