forked from gwen001/pentest-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomain-finder.py
executable file
·144 lines (117 loc) · 4.13 KB
/
domain-finder.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/python3.5
# I don't believe in license.
# You can do whatever you want with this program.
import os
import sys
import requests
import argparse
from colored import fg, bg, attr
w_blacklist = [ 'privacy', 'redacted' ]
def extractDatas( t_json ):
for index in ['technical_contact','registrant_contact','administrative_contact']:
if index in t_json:
company,email = extractData( t_json[index] )
if company and company not in t_datas['companies']:
t_datas['companies'].append( company )
if email and email not in t_datas['emails']:
t_datas['emails'].append( email )
def extractData( tab ):
if not 'company_name' in tab:
company = False
else:
company = t_json['registrant_contact']['company_name']
for wbl in w_blacklist:
if wbl in company.lower():
company = False
break
if not 'email_address' in tab:
email = False
else:
email = t_json['registrant_contact']['email_address']
for wbl in w_blacklist:
if wbl in email.lower():
email = False
break
return company,email
parser = argparse.ArgumentParser()
parser.add_argument( "-e","--email",help="email you are looking for (required or -d or -c)" )
parser.add_argument( "-c","--company",help="company you are looking for (required or -d or -e)" )
parser.add_argument( "-d","--domain",help="domain you already know (required or -c)" )
parser.add_argument( "-k","--key",help="whoxy api key (required)" )
parser.add_argument( "-v","--verbose",help="enable verbose mode, default off", action="store_true" )
parser.parse_args()
args = parser.parse_args()
t_domains = []
t_datas = {
'companies': [],
'emails': []
}
if args.verbose:
_verbose = True
else:
_verbose = False
if args.company:
t_datas['companies'].append( args.company )
if args.email:
t_datas['emails'].append( args.email )
if args.domain:
_domain = args.domain
else:
_domain = False
if not _domain and not len(t_datas['companies']) and not len(t_datas['emails']):
parser.error( 'domain or company or email required' )
if args.key:
_key = args.key
else:
parser.error( 'api key is required' )
if _domain:
if _verbose:
sys.stdout.write( '%s[+] search for domain: %s%s\n' % (fg('green'),_domain,attr(0)) )
url = 'http://api.whoxy.com/?key='+_key+'&whois='+_domain
if _verbose:
print(url)
r = requests.get( url )
t_json = r.json()
# print(t_json)
extractDatas( t_json )
if _verbose:
print(t_datas)
for company in t_datas['companies']:
page = 1
company = company.replace( ' ', '+' )
if _verbose:
sys.stdout.write( '%s[+] search for company: %s%s\n' % (fg('green'),company,attr(0)) )
while True:
url = 'http://api.whoxy.com/?key='+_key+'&reverse=whois&company='+company+'&mode=micro&page='+str(page)
page = page + 1
if _verbose:
print(url)
r = requests.get( url )
t_json = r.json()
# print(t_json)
if 'search_result' in t_json and len(t_json['search_result']):
for result in t_json['search_result']:
if not result['domain_name'] in t_domains:
t_domains.append( result['domain_name'] )
print( result['domain_name'] )
else:
break
for email in t_datas['emails']:
page = 1
if _verbose:
sys.stdout.write( '%s[+] search for email: %s%s\n' % (fg('green'),email,attr(0)) )
while True:
url = 'http://api.whoxy.com/?key='+_key+'&reverse=whois&email='+email+'&mode=micro&page='+str(page)
page = page + 1
if _verbose:
print(url)
r = requests.get( url )
t_json = r.json()
# print(t_json)
if 'search_result' in t_json and len(t_json['search_result']):
for result in t_json['search_result']:
if not result['domain_name'] in t_domains:
t_domains.append( result['domain_name'] )
print( result['domain_name'] )
else:
break