Skip to content

Commit

Permalink
Update dnscan.py
Browse files Browse the repository at this point in the history
Added functionality to handle domains with multiple wildcard DNS resolvers
  • Loading branch information
jamesbercegay committed May 26, 2019
1 parent e2e771a commit 06c5c40
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions dnscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def get_name(self, domain):
for rdata in res:
address = rdata.address
if wildcard:
if address == wildcard:
return
for wildcard_ip in wildcard:
if address == wildcard_ip:
return
if args.domain_first:
print(domain + " - " + col.brown + address + col.end)
else:
Expand Down Expand Up @@ -145,15 +146,19 @@ def lookup(domain, recordtype):

def get_wildcard(target):

# List of IP's for wildcard DNS
wildcards = []
# Use current unix time as a test subdomain
epochtime = str(int(time.time()))
# Prepend a letter to work around incompetent companies like CableOne
# and their stupid attempts at DNS hijacking
res = lookup("a" + epochtime + "." + target, recordtype)
if res:
address = res[0].address
out.good(col.red + "Wildcard" + col.end + " domain found - " + col.brown + address + col.end)
return address
for res_data in res:
address = res_data.address
wildcards.append(address)
out.good(col.red + "Wildcard" + col.end + " domain found - " + col.brown + address + col.end)
return wildcards
else:
out.verbose("No wildcard domain found")

Expand Down Expand Up @@ -375,10 +380,11 @@ def setup():
get_mx(target)
wildcard = get_wildcard(target)
if wildcard:
try:
addresses.add(ipaddr(unicode(wildcard)))
except NameError:
addresses.add(ipaddr(str(wildcard)))
for wildcard_ip in wildcard:
try:
addresses.add(ipaddr(unicode(wildcard_ip)))
except NameError:
addresses.add(ipaddr(str(wildcard_ip)))
out.status("Scanning " + target + " for " + recordtype + " records")
add_target(target)

Expand Down

0 comments on commit 06c5c40

Please sign in to comment.