Skip to content

Instantly share code, notes, and snippets.

@kaldaf
Last active November 7, 2025 09:13
Show Gist options
  • Select an option

  • Save kaldaf/283fc4c78f601bbca18bfd39f683b031 to your computer and use it in GitHub Desktop.

Select an option

Save kaldaf/283fc4c78f601bbca18bfd39f683b031 to your computer and use it in GitHub Desktop.
Find available domains
# INSTALL:
#whois
#requests
#dnspythhon
#inquirer
#python-whois
import socket
import time
import whois
import sys
import requests
import dns.asyncresolver
import inquirer
from itertools import product
from string import ascii_lowercase
from re import search
def check_socket(target):
try:
domain = socket.gethostbyname(target)
if domain:
return (f"{target} ❌")
except socket.error:
return (f"{target} ✅/❓")
def check_whois(target):
flags = whois.NICClient.WHOIS_QUICK
#flags = whois.NICClient.IANAHOST - only returning who is registar
try:
whois.NET_TIMEOUT = 5.0
whois.NET_MAX_RETRIES = 2
req = whois.whois(target, flags=flags)
if req:
return (f"{target} ❌")
elif req == null:
return (f"{target} ❓")
except:
return (f"{target} ✅/❓")
def recheck(target):
try:
req = requests.head(f"http://{target}")
if r.status_code == 200:
return (f"{target} ❌")
else:
return (f"{target} ✅/❓")
except:
return (f"{target} ✅/❓")
def terminate(message="App was terminated"):
sys.exit("📢 " + message)
def backup(data, filename):
with open(f"{filename}.md", 'w', encoding='utf-8') as f:
for res in data:
f.write(f"{res} ~ [NIC.CZ](https://nic.cz/whois/domain/{res.split()[0]}) \n\r")
f.close()
n_comb = input("[\033[33m?\033[0m] No. of combinations: ")
if n_comb.isnumeric() == False and len(n_comb) != 0: terminate("Bad value, try it again")
elif len(n_comb) == 0:
print("📢 Setted default value (3)")
n_comb = 3
elif int(n_comb) >= 10: terminate()
alphabet = ascii_lowercase
combs = product(alphabet, repeat=int(n_comb))
combinations = [''.join(comb) for comb in combs]
results = []
avaiable = []
print(f"📢 No. of possible combinations from array: {len(combinations)}")
index = input("[\033[33m?\033[0m] Start index: ")
if index.isnumeric() == False and len(index) != 0: terminate("Bad value, try it again")
elif len(index) == 0 or int(index) >= len(combinations):
print("📢 Setted default value (0)")
index = 0
print(f"📢 No. of indexed combinations from array: {len(combinations) - int(index)}")
types_select = [
inquirer.List('type',
message="Type of query:",
choices=['WHOIS', 'SOCKET'],
),
]
type = inquirer.prompt(types_select)
tdl = input("\033[91m*\033[0m Select TDL: ").lower()
if len(tdl) == 0 or tdl.isnumeric():
print("📢 Setted default value (cz)")
tdl = "cz"
filename = (f"results-{tdl}")
def check_domains():
for i in range(int(index), len(combinations)):
domain = (f"{combinations[i]}.{tdl}")
if type["type"] == "WHOIS":
res = check_whois(domain)
if search("✅",res):
res = recheck(domain)
avaiable.append(res)
results.append(res)
print(res)
time.sleep(1)
elif type["type"] == "SOCKET":
res = check_socket(domain)
if search("✅",res):
res = recheck(domain)
avaiable.append(res)
results.append(res)
print(res)
time.sleep(0.5)
if len(results) == len(combinations) - int(index):
backup(results, filename)
backup(avaiable, f"{filename}-avaiable")
terminate(f"File saved as {filename}.md")
if __name__ == '__main__':
try:
check_domains()
except KeyboardInterrupt:
if results and filename:
backup(results, filename)
backup(avaiable, f"{filename}-avaiable")
terminate(f"File saved as {filename}.md")
@kaldaf
Copy link
Author

kaldaf commented Mar 10, 2023

Start

Install pip3

  • whois
  • requests
  • dnspythhon
  • inquirer
  • python-whois

python3 domain-finder.py

Fill data

  1. No. of combinations - from alphabet (default 3)
  2. Start index - start index from string array (default 0)
  3. Type of query - whois (slower, more precise) / socket (faster)
  4. Select TLD - (com, sk, net,...) (default cz)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment