Skip to content

Instantly share code, notes, and snippets.

@x0rz
Created May 2, 2017 12:11
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save x0rz/80b4b93baa5b33ed25e1823d3494f0a8 to your computer and use it in GitHub Desktop.
Save x0rz/80b4b93baa5b33ed25e1823d3494f0a8 to your computer and use it in GitHub Desktop.
# Usage: ./dns_check.py <list_of_domain_names.txt>
import dns.resolver
import requests
import re
import json
import sys
resolver = dns.resolver.Resolver()
resolver.timeout = 5
resolver.lifetime = 5
def is_available(domain):
try:
hdr = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36'}
r = requests.get('https://njal.la/list/?search=' + domain, headers=hdr)
search = re.search('var results = \[(.*)\];', r.text)
if search:
domain = json.loads(search.group(1))
print(domain)
if domain['status'] == 'available':
return True
except:
pass
return False
def main():
with open(sys.argv[1], 'r') as dotcom_names:
for name in dotcom_names:
name = name.strip()
try:
resolver.query(name, 'NS')
print("[+] %s is taken" % name)
except Exception as e:
print("[+] %s might be available (%s)" % (name, e))
if is_available(name):
print("[!] \033[92m%s is available\033[0m" % name)
with open('available_names.txt', 'a') as f:
f.write("%s\n" % name)
if __name__ == '__main__':
main()
@evandrix
Copy link

evandrix commented Apr 8, 2018

instead of requests.get, use sess = requests.Session(); sess.get

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