-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwildcards.py
executable file
·42 lines (33 loc) · 1.07 KB
/
wildcards.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
#!/usr/bin/python3
import sys
import re
import dns.resolver
from randstr import randstr
def is_domain_alive(domain):
my_resolver = dns.resolver.Resolver()
my_resolver.nameservers = ['8.8.8.8', '1.1.1.1', '8.8.4.4']
try:
answer = my_resolver.resolve(domain, tcp=True)
ips = re.findall("IN A (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})", answer.response.to_text())
return ips
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer, dns.resolver.NoNameservers,
dns.resolver.LifetimeTimeout) as e:
return None
stat = {}
for line in open(sys.argv[1]):
line = line.strip()
if not len(line):
continue
domain = line
stat[domain] = set()
wildcard_cnt = 0
for _ in range(10):
subdomain = randstr(12) + "." + domain
ips = is_domain_alive(subdomain)
if ips is None and wildcard_cnt == 0:
break
if ips is not None:
stat[domain].update(ips)
wildcard_cnt += 1
if wildcard_cnt > 5:
print("*." + domain + "\t" + ",".join(stat[domain]))