Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b56bdf

Browse files
committed
Patch for MsSQL column name injection
1 parent c37014b commit 2b56bdf

4 files changed

Lines changed: 19 additions & 8 deletions

File tree

lib/core/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.2.9.9"
22+
VERSION = "1.2.9.10"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
@@ -324,6 +324,7 @@
324324

325325
# Regular expressions used for parsing error messages (--parse-errors)
326326
ERROR_PARSING_REGEXES = (
327+
r"\[Microsoft\]\[ODBC SQL Server Driver\]\[SQL Server\](?P<result>[^<]+)",
327328
r"<b>[^<]*(fatal|error|warning|exception)[^<]*</b>:?\s*(?P<result>.+?)<br\s*/?\s*>",
328329
r"(?m)^\s*(fatal|error|warning|exception):?\s*(?P<result>[^\n]+?)$",
329330
r"(?P<result>[^\n>]*SQL Syntax[^\n<]+)",

thirdparty/ansistrm/ansistrm.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,25 @@ def colorize(self, message, levelno):
182182
message = message.replace(counter, ''.join((self.csi, str(self.color_map["yellow"] + 30), 'm', counter, reset)), 1)
183183

184184
if level != "PAYLOAD":
185-
for match in re.finditer(r"[^\w]'([^']+)'", message): # single-quoted
186-
string = match.group(1)
185+
if any(_ in message for _ in ("parsed DBMS error message",)):
186+
string = re.search(r": '(.+)'", message).group(1)
187187
if not message.endswith(self.reset):
188188
reset = self.reset
189189
elif self.bold in message: # bold
190190
reset = self.reset + self.bold
191191
else:
192192
reset = self.reset
193193
message = message.replace("'%s'" % string, "'%s'" % ''.join((self.csi, str(self.color_map["white"] + 30), 'm', string, reset)), 1)
194+
else:
195+
for match in re.finditer(r"[^\w]'([^']+)'", message): # single-quoted
196+
string = match.group(1)
197+
if not message.endswith(self.reset):
198+
reset = self.reset
199+
elif self.bold in message: # bold
200+
reset = self.reset + self.bold
201+
else:
202+
reset = self.reset
203+
message = message.replace("'%s'" % string, "'%s'" % ''.join((self.csi, str(self.color_map["white"] + 30), 'm', string, reset)), 1)
194204
else:
195205
message = ''.join((self.csi, ';'.join(params), 'm', message, self.reset))
196206

txt/checksum.md5

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
5050
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
5151
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
5252
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
53-
c762da4ab30d1e245ca359df355ff7a7 lib/core/settings.py
53+
021d606c9405fd23d630108bf5c39853 lib/core/settings.py
5454
dd68a9d02fccb4fa1428b20e15b0db5d lib/core/shell.py
5555
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
5656
815d1cf27f0f8738d81531e73149867d lib/core/target.py
@@ -287,7 +287,7 @@ f2b9eac52d346315f5705f71beeda791 tamper/varnish.py
287287
0e40966a51d1eb5d42a2159d2015a8a4 tamper/versionedkeywords.py
288288
0fba004bf1be6edbefbda89f23f4e518 tamper/versionedmorekeywords.py
289289
de532c4e3160039335010c499129d54f tamper/xforwardedfor.py
290-
1996d6afa985a526df02efa1bf121976 thirdparty/ansistrm/ansistrm.py
290+
b422795c5e589decec725963e480ffba thirdparty/ansistrm/ansistrm.py
291291
d41d8cd98f00b204e9800998ecf8427e thirdparty/ansistrm/__init__.py
292292
8e775c25bc9e84891ad6fcb4f0005c23 thirdparty/beautifulsoup/beautifulsoup.py
293293
cb2e1fe7c404dff41a2ae9132828f532 thirdparty/beautifulsoup/__init__.py
@@ -469,7 +469,7 @@ d48c971769c6131e35bd52d2315a8d58 xml/banner/servlet-engine.xml
469469
d989813ee377252bca2103cea524c06b xml/banner/sharepoint.xml
470470
350605448f049cd982554123a75f11e1 xml/banner/x-aspnet-version.xml
471471
817078783e1edaa492773d3b34d8eef0 xml/banner/x-powered-by.xml
472-
b306c99a038b03421beea655dc804b64 xml/boundaries.xml
472+
de871ef9c982799a7f7f84621f103f26 xml/boundaries.xml
473473
6cffc395cd0280f5c1a84542da6642e5 xml/errors.xml
474474
a279656ea3fcb85c727249b02f828383 xml/livetests.xml
475475
fe2a865a8579f2045d2be057a00f5b49 xml/payloads/boolean_blind.xml

xml/boundaries.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ Formats:
513513
<clause>8</clause>
514514
<where>1</where>
515515
<ptype>6</ptype>
516-
<prefix>]=[[ORIGINAL]]</prefix>
517-
<suffix> AND [[ORIGINAL]]=[[ORIGINAL]</suffix>
516+
<prefix>]-(SELECT 0 WHERE [RANDNUM]=[RANDNUM]</prefix>
517+
<suffix>)|[[ORIGINAL]</suffix>
518518
</boundary>
519519
<!-- End of escaped column name boundaries -->
520520

0 commit comments

Comments
 (0)