Skip to content

Instantly share code, notes, and snippets.

@TrungNguyen1909
Created December 18, 2019 06:29
Show Gist options
  • Save TrungNguyen1909/8960f46d7cbc906f18fb90711031a486 to your computer and use it in GitHub Desktop.
Save TrungNguyen1909/8960f46d7cbc906f18fb90711031a486 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import requests
import sys
import re
import xml.etree.ElementTree as ET
tp = r'<table border="1">.*<\/table>'
print('WHOIS (pronounced as the phrase "who is") is a query and response protocol that is widely used for querying databases that store the registered users or assignees of an Internet resource.')
print('A reverse WHOIS lookup takes a registered user or assignee \'s name to find the domains that he or she owns.')
q = input("Enter Query for Reverse WHOIS lookup:")
s = requests.session()
s.headers = {
'authority': 'viewdns.info',
'cache-control': 'max-age=0',
'dnt': '1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36',
'sec-fetch-user': '?1',
'accept': 'text/html',
'sec-fetch-site': 'same-origin',
'sec-fetch-mode': 'navigate',
'referer': 'https://viewdns.info/',
'accept-language': 'vi-VN,vi;q=0.9,en-US;q=0.8,en;q=0.7',
}
s.get('https://viewdns.info/')
d = s.get("https://viewdns.info/reversewhois/",params = [('q',q)]).text
table = re.search(tp, d)
if table is None:
print("Result not found!")
exit(-1)
root = ET.fromstring('<?xml version="1.0"?>\n'+table.group(0))
for entry in list(root):
print(F'{entry[0].text}|{entry[1].text}|{entry[2].text}')
#print(root)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment