#this program will parse alexas top 1 million domains for responses larger than 500 bytes. it tests every type of query available on 10 of the fastest dns servers on the planet.
#enjoy. FUCK RFC 8482 !!!
#coded by Freak @ Kek Security
#pip2 install dnslib
#updated at 1.12.2021 added multithreading for faster list generation
import socket,os,random,select,time,threading
from dnslib import DNSRecord
#qtypes = {'a': '\x01', 'txt' : '\x10', 'cname' : '\x05', 'ns' : '\x02', 'mx', '\x0f', 'ptr' : '\x0c', 'any' : '\xff', 'axfr' : '\xfc', 'soa' : '\x06', 'HINFO' : '\r'}
def make_dns_query_domain(domain):
def f(s):
return chr(len(s)) + s
parts = domain.split('.')
parts = list(map(f, parts))
return ''.join(parts)
def make_dns_request_data(dns_query, qtype):
req = os.urandom(2) + "\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00"
req += dns_query
req += '\x00\x00' + qtype + '\x00\x01'
return req
if raw_input("Download domain list? (y/n): ").lower().startswith("y"):
os.popen("wget -q http://s3.amazonaws.com/alexa-static/top-1m.csv.zip;unzip top-1m.csv.zip; awk -F ',' '{print $2}' top-1m.csv>top1m.txt")
domains=open("top1m.txt","r").read().replace("\r", "").split("\n")
servers=["1.1.1.1", "1.0.0.1", "8.8.8.8", "8.8.4.4", "8.26.56.26", "8.20.247.20", "9.9.9.9", "149.112.112.112", "64.6.64.6", "64.6.65.6"]
responses=[]
global running
running = 0
def stringproc(s):
ch = (ord(c) for c in s)
return ''.join(('\\x%02x' % c) if c <= 255 else ('\\u%04x' % c) for c in ch)
fh=open("queries.txt","w")
def getdata(qname,fh):
global running
running += 1
for qtype in ['\x01', '\x10', '\x05','\x02', '\x0f', '\x0c', '\xff', '\xfc', '\x06','\r']:
try:
forward_addr = (random.choice(servers), 53) # dns and port
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client.setblocking(0)
dnspkt=make_dns_request_data(make_dns_query_domain(qname), qtype)
client.sendto(dnspkt, forward_addr)
ready = select.select([client], [], [], 0.3)
if ready[0]:
data, _ = client.recvfrom(1024*1024*1024)
if len(data) > 500:
print DNSRecord.parse(dnspkt)
print DNSRecord.parse(data)
print "Response size: " + str(len(data))
# responses.append([len(data),qname,qtype])
fh.write("['"+stringproc(qtype)+"','"+qname+"'],") #add size here if you'd like
fh.flush()
except:
pass
running -= 1
for qname in domains:
try:
while running >= 512:
time.sleep(0.4)
threading.Thread(target=getdata,args=(qname,fh,)).start()
except KeyboardInterrupt:
os.kill(os.getpid(),9)
Comments
0 B
|👍
/👎