Created
May 15, 2021 06:32
-
-
Save mat-1/ba9e9b4234ed88c388ee3d8ef7582315 to your computer and use it in GitHub Desktop.
Find wacky websites without a second level domain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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