forked from dvopsway/datasploit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
domainOsint.py
executable file
·253 lines (197 loc) · 7.37 KB
/
domainOsint.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#input domain name
#domain_osint
#pip lxml json
#http://searchdns.netcraft.com/?restriction=site+contains&host=olacabs.com&lookup=wait..&position=limited
#completed
#punkspider, shodan, whois,
#show whois , dns, buildwith, wappalyzer, punkspider info
# subdomain find. knocy.py / google
# server profiling of subdomains
# check for .git/htaccess/web.config/extractc.
#https://github.com/ivanlei/threatbutt
# harvest emails
# find files
# extract info from files
# find information, harvest email.
# check on fb, relate to username.
# show possible graph search links
# twiter graph on the username
# namecheck with usernamejjjj
# hibp
import time
import whois
import requests
import socket
import sys
import json
from Wappalyzer import Wappalyzer, WebPage
from bs4 import BeautifulSoup
import dns.resolver
import config as cfg
import re
from urlparse import urlparse
import hashlib
import urllib
from domain_whois import whoisnew
from domain_dnsrecords import fetch_dns_records,parse_dns_records
from ip_shodan import shodansearch
from domain_zoomeye import get_accesstoken_zoomeye,search_zoomeye
from domain_checkpunkspider import checkpunkspider
from domain_wappalyzer import wappalyzeit
from domain_subdomains import check_and_append_subdomains,subdomains,find_subdomains_from_wolfram,subdomains_from_netcraft,subdomain_list
from domain_sslinfo import check_ssl_htbsecurity
from domain_pagelinks import pagelinks
from domain_history import netcraft_domain_history
from domain_emailhunter import emailhunter,collected_emails
from domain_github import github_search
from domain_forumsearch import boardsearch_forumsearch
from domain_wikileaks import wikileaks
from domain_censys import view,censys_search,censys_list
from domain_shodan import shodandomainsearch
'''
collected_emails = []
subdomain_list = []
censys_list = []
'''
######
## Proram starts here ##
######
def main():
domain = sys.argv[1]
API_URL = "https://www.censys.io/api/v1"
#print cfg.zoomeyeuser
#print WhoIs information
print whoisnew(domain)
print "\n-----------------------------\n"
#print DNS Information
dns_records = parse_dns_records(domain)
for x in dns_records.keys():
print x
if "No" in dns_records[x] and "Found" in dns_records[x]:
print "\t%s" % (dns_records[x])
else:
for y in dns_records[x]:
print "\t%s" % (y)
#print type(dns_records[x])
print "\n-----------------------------\n"
#convert domain to reverse_domain for passing to checkpunkspider()
reversed_domain = ""
for x in reversed(domain.split(".")):
reversed_domain = reversed_domain + "." + x
reversed_domain = reversed_domain[1:]
checkpunkspider(reversed_domain)
print "\n-----------------------------\n"
#make proper URL with domain. Check on ssl as well as 80.
print "\t\t\t[+] Wapplyzing " + domain
print "Hitting HTTP:\n",
try:
targeturl = "http://" + domain
wappalyzeit(targeturl)
except:
print "[-] HTTP connection was unavailable"
print "Hitting HTTPS:\n",
try:
targeturl = "https://" + domain
wappalyzeit(targeturl)
except:
print "[-] HTTPS connection was unavailable"
print "\n-----------------------------\n"
#make Search github code for the given domain.
print github_search(domain, 'Code')
print "\n-----------------------------\n"
#collecting emails for the domain and adding information in master email list.
emailhunter(domain)
print "\t\t\t[+] Finding Email Ids\n"
for x in collected_emails:
print str(x) + ", ",
print "\n-----------------------------\n"
dns_history = netcraft_domain_history(domain)
for x in dns_history.keys():
print "%s: %s" % (dns_history[x], x)
print "\n-----------------------------\n"
#subdomains [to be called before pagelinks so as to avoid repititions.]
print "\t\t\t[+] Finding Subdomains and appending\n"
subdomains(domain)
##print "\t\t\t[+] Check_subdomains from wolframalpha"
##find_subdomains_from_wolfram(domain)
print "\n-----------------------------\n"
#domain pagelinks
print "\t\t\t[+] Pagelinks\n"
links=pagelinks(domain)
for x in links:
print x
print "\n-----------------------------\n"
#calling and printing subdomains after pagelinks.
subdomains_from_netcraft(domain)
print "\n\t\t\t[+] List of subdomains found\n"
for sub in subdomain_list:
print sub
#wikileaks
print "\t\t\t[+] Associated WikiLeaks\n"
leaklinks=wikileaks(domain)
for tl,lnk in leaklinks.items():
print "%s (%s)" % (lnk, tl)
print "For all results, visit: "+ 'https://search.wikileaks.org/?query=&exact_phrase=%s&include_external_sources=True&order_by=newest_document_date'%(domain)
print "\n-----------------------------\n"
print "\t\t\t[+] Associated Forum Links\n"
links=boardsearch_forumsearch(domain)
for tl,lnk in links.items():
print "%s (%s)" % (lnk, tl)
print "\n-----------------------------\n"
results = check_ssl_htbsecurity(domain)
if 'ERROR' in results.keys():
print results['ERROR']
elif 'TOKEN' in results.keys():
print 'Picking up One IP from bunch of IPs returned: %s' % results['MULTIPLE_IPS'][0]
results_new = check_ssl_htbsecurity(results['MULTIPLE_IPS'][0])
print "OverAll Rating: %s" % results_new['GRADE']
print 'Check https://www.htbridge.com/ssl/ for more information'
for x in results_new['VALUE'].keys():
if str("[5]") in str(results_new['VALUE'][x]) or str("[3]") in str(results_new['VALUE'][x]):
if x == 'httpHeaders':
pass
else:
print results_new['VALUE'][x]
else:
print "OverAll Rating: %s" % results['GRADE']
for x in results['VALUE'].keys():
if str("[5]") in str(results['VALUE'][x]) or str("[3]") in str(results['VALUE'][x]):
if x == 'httpHeaders':
pass
else:
print results['VALUE'][x]
print "\n-----------------------------\n"
#checks results from zoomeye
#filters need to be applied
zoomeye_results = search_zoomeye(domain)
dict_zoomeye_results = json.loads(zoomeye_results)
if 'matches' in dict_zoomeye_results.keys():
for x in dict_zoomeye_results['matches']:
if x['site'].split('.')[-2] == domain.split('.')[-2]:
print "IP: %s\nSite: %s\nTitle: %s\nHeaders: %s\nLocation: %s\n" % (x['ip'], x['site'], x['title'], x['headers'].replace("\n",""), x['geoinfo'])
print "\n-----------------------------\n"
print "[+]\t Kicking off Censys Search. This may take a while.."
censys_search(domain)
for x in censys_list:
print x
print "\n-----------------------------\n"
#checks for host ip and other details in shodan.
'''
#Code for shodan Ip search. now we are doing Hostname search.
#converts domain to IP. Prints a statement for the same.
ip_addr = socket.gethostbyname(domain)
#checks for information at shodan, and comes back with whatever available.
## need to apply filter here (lot of noise coming in)
res_from_shodan = json.loads(shodansearch(ip_addr))
#print res_from_shodan
for iterate_shodan_list in res_from_shodan['data']:
print "ISP: %s \n Hosts: %s \n IP: %s \n Data: %s\n" % (iterate_shodan_list['isp'], iterate_shodan_list['hostnames'], iterate_shodan_list['ip_str'], iterate_shodan_list['data'].strip("\n"))
print "\n-----------------------------\n"
'''
res_from_shodan = json.loads(shodandomainsearch(domain))
if 'matches' in res_from_shodan.keys():
for x in res_from_shodan['matches']:
print "IP: %s\nHosts: %s\nDomain: %s\nPort: %s\nData: %s\nLocation: %s\n" % (x['ip_str'], x['hostnames'], x['domains'], x['port'], x['data'].replace("\n",""), x['location'])
print "-----------------------------\n"
if __name__ == "__main__":
main()