-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpassive_checks.py
200 lines (175 loc) · 7.1 KB
/
passive_checks.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
# -*- coding: utf-8 -*-
__author__ = 'videns'
import code
import re
import array
from burp import IBurpExtender, IScannerInsertionPointProvider, IScannerInsertionPoint, IParameter, IScannerCheck, IScanIssue, IHttpService, IHttpListener
scope_only = True
errors = [r'\.php on line [0-9]+',
r'Fatal error:',
r'\.php:[0-9]+',
r'\[(ODBC SQL Server Driver|SQL Server)\]',
r'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near',
r'\.java:[0-9]+',
r'\.java\((Inlined )?Compiled Code\)',
r'[A-Za-z\.]+\(([A-Za-z0-9, ]+)?\) \+[0-9]+',
r'at (\/[A-Za-z0-9\\.]+)*\.pm line [0-9]+',
r'File \"[A-Za-z0-9\-_\./]*\", line [0-9]+, in',
r'in [^\s]\.cs:[0-9]+', #aspnet
r'\.rb:[0-9 ]+:in ', #ruby
r'[\w\/]+\.js:[0-9]+:[0-9]+' #nodejs
#next search strings are taken from fuzzdb
r'A syntax error has occurred',
r'ADODB.Field error',
r'ASP.NET is configured to show verbose error messages',
r'ASP.NET_SessionId',
r'Active Server Pages error',
r'An illegal character has been found in the statement',
r'An unexpected token "END-OF-STATEMENT" was found',
r'CLI Driver',
r'Can\'t connect to local',
r'Custom Error Message',
r'DB2 Driver',
r'DB2 Error',
r'DB2 ODBC',
r'Died at',
r'Disallowed Parent Path',
r'Error Diagnostic Information',
r'Error Message : Error loading required libraries.',
r'Error Report',
r'Error converting data type varchar to numeric',
r'Fatal error',
r'Incorrect syntax near',
r'Index of',
r'Internal Server Error',
r'Invalid Path Character',
r'Invalid procedure call or argument',
r'Invision Power Board Database Error',
r'JDBC Driver',
r'JDBC Error',
r'JDBC MySQL',
r'JDBC Oracle',
r'JDBC SQL',
r'Microsoft OLE DB Provider for ODBC Drivers',
r'Microsoft VBScript compilation error',
r'Microsoft VBScript error',
r'MySQL Driver',
r'MySQL Error',
r'MySQL ODBC',
r'ODBC DB2',
r'ODBC Driver',
r'ODBC Error',
r'ODBC Microsoft Access',
r'ODBC Oracle',
r'ODBC SQL',
r'ODBC SQL Server',
r'OLE/DB provider returned message',
r'ORA-0',
r'ORA-1',
r'Oracle DB2',
r'Oracle Driver',
r'Oracle Error',
r'Oracle ODBC',
r'PHP Error',
r'PHP Parse error',
r'PHP Warning',
r'Parent Directory',
r'Permission denied: \'GetObject\'',
r'PostgreSQL query failed: ERROR: parser: parse error',
r'SQL Server Driver\]\[SQL Server',
r'SQL command not properly ended',
r'SQLException',
r'Supplied argument is not a valid PostgreSQL result',
r'Syntax error in query expression',
r'The error occurred in',
r'The script whose uid is',
r'Type mismatch',
r'Unable to jump to row',
r'Unclosed quotation mark before the character string',
r'Unterminated string constant',
r'Warning: Cannot modify header information - headers already sent',
r'Warning: Supplied argument is not a valid File-Handle resource in',
r'Warning: mysql_query()',
r'Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL',
r'You have an error in your SQL syntax near',
r'data source=',
r'detected an internal error \[IBM\]\[CLI Driver\]\[DB2/6000\]',
r'include_path',
r'invalid query',
r'is not allowed to access',
r'missing expression',
r'mySQL error with query',
r'mysql error',
r'on MySQL result index',
r'on line',
r'server at',
r'server object error',
r'supplied argument is not a valid MySQL result resource',
r'unexpected end of SQL command']
error_regexp = [re.compile(x, re.IGNORECASE) for x in errors]
version = "0.0.5"
class BurpExtender(IBurpExtender):
def registerExtenderCallbacks(self, this_callbacks):
global callbacks
callbacks = this_callbacks
callbacks.setExtensionName("passive checks")
callbacks.registerHttpListener(HTTPListener(callbacks))
print "Successfully loaded checks v" + version
return
class HTTPListener(IHttpListener):
def __init__(self, callbacks):
self._helpers = callbacks.getHelpers()
def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo):
if messageIsRequest == 0:
url = self._helpers.analyzeRequest(messageInfo).getUrl()
if (not scope_only) or (scope_only and callbacks.isInScope(url)):
response = self._helpers.analyzeResponse(messageInfo.getResponse())
if response.getStatusCode() == 404:
return
raw_response = self._helpers.bytesToString(messageInfo.getResponse())
for one_error_regexp in error_regexp:
match = one_error_regexp.search(raw_response)
if match:
match_res = match.group(0)
start_pos = raw_response.find(match_res)
markers = [array.array('i', [start_pos, start_pos + len(match_res)])]
new_messages = callbacks.applyMarkers(messageInfo, None, markers)
callbacks.addScanIssue(CustomScanIssue(messageInfo.getHttpService(),
url,
[new_messages],
"Detailed error",
"Detailed error found, <b>%s</b>" % match_res,
"Firm",
"High"))
class CustomScanIssue(IScanIssue):
def __init__(self, httpService, url, httpMessages, name, detail, confidence, severity):
self._http_service = httpService
self._url = url
self._http_messages = httpMessages
self._name = name
self._detail = detail + '<br/><br/><div style="font-size:8px">This issue was reported by Passive Checks Plugin</div>'
self._severity = severity
self._confidence = confidence
return
def getUrl(self):
return self._url
def getIssueName(self):
return self._name
def getIssueType(self):
return 134217728
def getSeverity(self):
return self._severity
def getConfidence(self):
return self._confidence
def getIssueBackground(self):
return None
def getRemediationBackground(self):
return None
def getIssueDetail(self):
return self._detail
def getRemediationDetail(self):
return None
def getHttpMessages(self):
return self._http_messages
def getHttpService(self):
return self._http_service