Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save peterfroehlich/5590f1dfbad41b0754efbf861555acd2 to your computer and use it in GitHub Desktop.
Save peterfroehlich/5590f1dfbad41b0754efbf861555acd2 to your computer and use it in GitHub Desktop.
Fake email domain crawler
#!/usr/bin/env python3
""" Fake email domain crawler
uses search page of known temp mail provider to crawl domains
These domains are getting used on, among others:
https://generator.email/
https://emailfake.com/
https://email-fake.com/
1.) slowly retrives results for strings aaa-zzz, validates DNS and stores in set
2.) fetches public tld list from icann
3.) writes entry with one "." and known tld into outfile
"""
import requests
import dns.resolver
from string import ascii_lowercase
from time import sleep
baseurl = "https://generator.email/search.php?key="
tld_list = "https://data.iana.org/TLD/tlds-alpha-by-domain.txt"
output = "./domains.lst"
domains = set()
def generator_silables():
for c in ascii_lowercase:
for a in ascii_lowercase:
for r in ascii_lowercase:
yield c+a+r
def tld_array():
t = requests.get(tld_list)
return [ i.lower() for i in t.text.split("\n")[1:-1] ]
def has_mx(domain):
try:
records = dns.resolver.resolve(domain, 'MX', raise_on_no_answer=False)
if len(records) > 0:
return True
except dns.resolver.NXDOMAIN:
pass
except dns.exception.Timeout:
pass
print("%s is invalid, filtered" % domain)
return False
try:
#for i in ["ook", "rub", "aaa", "duc", "all"]:
for i in generator_silables():
response = requests.get(baseurl + i)
if response.status_code == 200:
print("%s - %s" % (i, str(response.json())))
for r in response.json():
if has_mx(r):
domains.update([r])
except Exception as e:
print(e)
print(domains)
tlds = tld_array()
outfile = open(output, "w")
try:
for j in domains:
if j.count(".") == 1 and j.split(".")[-1] in tlds:
outfile.write(j+"\n")
finally:
print("Done writing '%s'" % output)
outfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment