Skip to content

Instantly share code, notes, and snippets.

@mat-1
Created May 15, 2021 06:32
Show Gist options
  • Save mat-1/ba9e9b4234ed88c388ee3d8ef7582315 to your computer and use it in GitHub Desktop.
Save mat-1/ba9e9b4234ed88c388ee3d8ef7582315 to your computer and use it in GitHub Desktop.
Find wacky websites without a second level domain
import requests
from threading import Thread
tlds = [tld for tld in requests.get('https://data.iana.org/TLD/tlds-alpha-by-domain.txt').text.splitlines() if not tld.startswith('#')]
def check_domain(tld):
r = requests.get(f'https://cloudflare-dns.com/dns-query?name={tld}&type=A', headers={
'accept': 'application/dns-json'
})
data = r.json()
if data['Status'] == 0 and 'Answer' in data and not data['Answer'][0]['data'].startswith('127.'):
print(tld)
threads = []
for tld in tlds:
t = Thread(None, lambda: check_domain(tld))
t.start()
threads.append(t)
if len(threads) > 100:
for thread in threads:
thread.join()
threads = []
for thread in threads:
thread.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment