-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreverse.py
87 lines (73 loc) · 2.36 KB
/
reverse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
# file: reverse.py
# Reverse Whois Search
# Version: v0.1
import requests
import sys
import json
import argparse
from config import api_url,api_key
from pyfiglet import figlet_format
def banner():
print(figlet_format("Reverse Whois"))
print("Horizontal Domain Enumeration")
print("Github: @kbehroz")
print("Twitter: @behroznathwani\n\n")
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--target", help="Name of Organization", nargs='+', required=True)
parser.add_argument("-o", "--output", help="Output File name")
return parser.parse_args()
def parse(api_key,org):
try:
response = requests.get(F"https://user.whoisxmlapi.com/service/account-balance?apiKey={api_key}").json()
if 'data' not in response: # Validating Api Key
print("Invaild Api Key. Please set correct API Key in config.py")
elif response['data'][3]['credits'] < 0: # Checking credits
print("You don't have API call credits")
else:
domainlist(org)
except requests.exceptions.RequestException as e:
print(e)
def domainlist(org):
payload = {
'apiKey': api_key,
'searchType': 'current',
'mode': 'preview',
'basicSearchTerms':{
'include': [
org
]
}
}
try:
print("[+] Trying to Fetch Domains")
content = requests.post(api_url, json=payload).json()
if content['domainsCount'] > 0:
print(f"[+] {content['domainsCount']} domain Found.")
output_domain(payload,org)
else:
print("[+] No domain found")
except requests.exceptions.RequestException as e:
print(e)
def output_domain(post_data,org):
post_data['mode'] = 'purchase'
try:
domains = requests.post(api_url, json=post_data).json()
for domain in domains['domainsList']:
print(domain)
if parse_args().output:
with open(parse_args().output,"a") as file:
file.write(domain)
file.write("\n")
except requests.exceptions.RequestException as e:
print(e)
def main():
banner()
org = ' '.join(parse_args().target)
parse(api_key,org)
try:
main()
except KeyboardInterrupt:
print('Keyboard Interruption....')
sys.exit(0)