-
Notifications
You must be signed in to change notification settings - Fork 99
/
oralyzer.py
executable file
·284 lines (266 loc) · 10.9 KB
/
oralyzer.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/usr/bin/env python3
#https://twitter.com/r0075h3ll
print("\033[91m\n\tOralyzer\033[00m\n")
arrow = '\033[91m->\033[00m'
#----------------------------------------------------------#
import sys
if sys.version_info.major > 2 and sys.version_info.minor > 6:
pass
else:
print("%s Oralyzer requires atleast Python 3.7.x to run." % bad)
exit()
#---------------------------------------------------------#
import argparse,re,random,warnings,ssl,requests
from core.wayback import getURLs
from core.crlf import crlfScan
from core.others import good,bad,info,requester,multitest,urlparse
from bs4 import BeautifulSoup
warnings.filterwarnings('ignore')
ssl._create_default_https_context = ssl._create_unverified_context
#----------------------------------------------------------------------------------#
parser = argparse.ArgumentParser()
parser.add_argument('-u', help='scan single target', dest="url")
parser.add_argument('-l', help='scan multiple targets from a file', dest='path')
parser.add_argument('-crlf', help='scan for CRLF Injection', action='store_true', dest='crlf')
parser.add_argument('-p', help='use payloads from a file', dest="payload", default="payloads.txt")
parser.add_argument('--proxy', help='use proxy', action='store_true' , dest='proxy')
parser.add_argument('--wayback', help='fetch URLs from archive.org', action="store_true", dest='waybacks')
args = parser.parse_args()
url = args.url
if ((args.payload != "payloads.txt") and (args.crlf or args.waybacks)): print("%s '-p' can't be used with '-crlf' or '--wayback'" % bad), exit()
#-------------------------------------------------------#
if not (args.url or args.path):
print('Made by \033[1mr0075h3ll\033[00m')
print(parser.format_help().lower())
#--------------------------------------------------------#
if not args.crlf and not args.waybacks:
try:
file = open(args.payload, encoding='utf-8').read().splitlines()
except FileNotFoundError:
print("%s Payload file not found" % bad)
exit()
if args.path:
try:
urls = open(args.path, encoding='utf-8').read().splitlines()
except FileNotFoundError: print("%s Target file not found" % bad), exit()
#-------------------------------------------------------#
def analyze(url):
multiTestCall = multitest(url,file)
print('%s Infusing payloads' % info)
if type(multiTestCall) == tuple:
for params in multiTestCall[0]:
testingBreak = request(multiTestCall[1],params)
if testingBreak:
break
else:
for url in multiTestCall:
testingBreak = request(url)
if testingBreak:
break
#--------------------------------------------------------#
def request(URI,params=''):
try:
page = requester(URI,args.proxy,params)
except requests.exceptions.Timeout:
print("[\033[91mTimeout\033[00m] %s" % url)
return True
except requests.exceptions.ConnectionError:
print("%s Connection Error" % bad)
return True
funcBreak = check(page, page.request.url)
if funcBreak:
return True
#--------------------------------------------------------------------#
def check(respOBJ,finalURL):
payload = "|".join([re.escape(i) for i in file])
redirectCodes = [red for red in range(300,311,1)]
errorCodes = [error for error in range(400, 411, 1)]
soup = BeautifulSoup(respOBJ.text,'html.parser')
google = re.search(payload, str(soup.find_all("script")), re.IGNORECASE)
metas = str(soup.find_all('meta'))
metaTagSearch = re.search(payload, metas, re.IGNORECASE)
sourcesSinks = [
"location.href",
"location.hash",
"location.search",
"location.pathname",
"document.URL",
"window.name",
"document.referrer",
"document.documentURI",
"document.baseURI",
"document.cookie",
"location.hostname",
"jQuery.globalEval",
"eval",
"Function",
"execScript",
"setTimeout",
"setInterval",
"setImmediate",
"msSetImmediate",
"script.src",
"script.textContent",
"script.text",
"script.innerText",
"script.innerHTML",
"script.appendChild",
"script.append",
"document.write",
"document.writeln",
"jQuery",
"jQuery.$",
"jQuery.constructor",
"jQuery.parseHTML",
"jQuery.has",
"jQuery.init",
"jQuery.index",
"jQuery.add",
"jQuery.append",
"jQuery.appendTo",
"jQuery.after",
"jQuery.insertAfter",
"jQuery.before",
"jQuery.insertBefore",
"jQuery.html",
"jQuery.prepend",
"jQuery.prependTo",
"jQuery.replaceWith",
"jQuery.replaceAll",
"jQuery.wrap",
"jQuery.wrapAll",
"jQuery.wrapInner",
"jQuery.prop.innerHTML",
"jQuery.prop.outerHTML",
"element.innerHTML",
"element.outerHTML",
"element.insertAdjacentHTML",
"iframe.srcdoc",
"location.replace",
"location.assign",
"window.open",
"iframe.src",
"javascriptURL",
"jQuery.attr.onclick",
"jQuery.attr.onmouseover",
"jQuery.attr.onmousedown",
"jQuery.attr.onmouseup",
"jQuery.attr.onkeydown",
"jQuery.attr.onkeypress",
"jQuery.attr.onkeyup",
"element.setAttribute.onclick",
"element.setAttribute.onmouseover",
"element.setAttribute.onmousedown",
"element.setAttribute.onmouseup",
"element.setAttribute.onkeydown",
"element.setAttribute.onkeypress",
"element.setAttribute.onkeyup",
"createContextualFragment",
"document.implementation.createHTMLDocument",
"xhr.open",
"xhr.send",
"fetch",
"fetch.body",
"xhr.setRequestHeader.name",
"xhr.setRequestHeader.value",
"jQuery.attr.href",
"jQuery.attr.src",
"jQuery.attr.data",
"jQuery.attr.action",
"jQuery.attr.formaction",
"jQuery.prop.href",
"jQuery.prop.src",
"jQuery.prop.data",
"jQuery.prop.action",
"jQuery.prop.formaction",
"form.action",
"input.formaction",
"button.formaction",
"button.value",
"element.setAttribute.href",
"element.setAttribute.src",
"element.setAttribute.data",
"element.setAttribute.action",
"element.setAttribute.formaction",
"webdatabase.executeSql",
"document.domain",
"history.pushState",
"history.replaceState",
"xhr.setRequestHeader",
"websocket",
"anchor.href",
"anchor.target",
"JSON.parse",
"localStorage.setItem.name",
"localStorage.setItem.value",
"sessionStorage.setItem.name",
"sessionStorage.setItem.value",
"element.outerText",
"element.innerText",
"element.textContent",
"element.style.cssText",
"RegExp",
"location.protocol",
"location.host",
"input.value",
"input.type",
"document.evaluate"
]
escapedSourcesSinks = [re.escape(SnS) for SnS in sourcesSinks]
sourcesMatch = list(dict.fromkeys(re.findall("|".join(escapedSourcesSinks), str(soup))))
#----------------------------------------------------------------------------------------------#
if respOBJ.status_code in redirectCodes:
if metaTagSearch and "http-equiv=\"refresh\"" in metas:
print("%s Meta Tag Redirection" % good)
return True
else:
print("%s Header Based Redirection : %s %s %s" % (good,finalURL,arrow,respOBJ.headers['Location']))
elif respOBJ.status_code==200:
if google:
#---------------------------------------------------------------------------------------------#
print("%s Javascript Based Redirection" % good)
if sourcesMatch != None:
print("%s Potentially Vulnerable Source/Sink(s) Found: \033[1m%s\033[00m" % (good, " ".join(sourcesMatch)))
return True
#------------------------------------------------------------------------------------#
if metaTagSearch and "http-equiv=\"refresh\"" in str(respOBJ.text):
print("%s Meta Tag Redirection" % good)
return True
elif "http-equiv=\"refresh\"" in str(respOBJ.text) and not metaTagSearch:
print("%s The page is only getting refreshed" % bad)
return True
#-------------------------------------------------------------------------------------#
elif respOBJ.status_code in errorCodes:
print("%s %s [\033[91m%s\033[00m]" % (bad,finalURL,respOBJ.status_code))
else:
print("%s Found nothing :: %s" % (bad,finalURL))
#-------------------------------------------------------------------------------------------------------------------------------#
try:
if args.url:
if args.crlf and not args.waybacks:
crlfScan(url, args.proxy)
elif args.waybacks and not args.crlf:
print("%s Getting juicy URLs from archive.org" % info)
getURLs(url, "wayback_data.txt")
elif not (args.crlf and args.waybacks):
analyze(url)
elif args.path:
if args.crlf and not args.waybacks:
for url in urls:
print("%s Target: %s" % (info, url))
crlfScan(url,args.proxy)
print("\n")
elif args.waybacks and not args.crlf:
print("%s Getting juicy URLs from archive.org" % info)
for url in urls:
print("%s URL: %s" % (info, url))
getURLs(url, "wayback_%d.txt" % random.randint(0,1000))
print("\n")
elif not (args.crlf and args.waybacks):
for url in urls:
print("%s Target: \033[92m%s\033[00m" % (info, url))
analyze(url)
print("\n")
except KeyboardInterrupt:
print("\nQuitting...")
exit()