Skip to content

Commit c1f98d0

Browse files
committed
Couple of important patches
1 parent fddc818 commit c1f98d0

File tree

6 files changed

+21
-7
lines changed

6 files changed

+21
-7
lines changed

data/xml/queries.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<root>
44
<!-- MySQL -->
55
<dbms value="MySQL">
6-
<cast query="CAST(%s AS CHAR)"/>
6+
<!-- http://dba.fyicenter.com/faq/mysql/Difference-between-CHAR-and-NCHAR.html -->
7+
<cast query="CAST(%s AS NCHAR)"/>
78
<length query="CHAR_LENGTH(%s)"/>
89
<isnull query="IFNULL(%s,' ')"/>
910
<delimiter query=","/>
@@ -242,6 +243,9 @@
242243
<concatenate query="%s||%s"/>
243244
<case query="SELECT (CASE WHEN (%s) THEN 1 ELSE 0 END)"/>
244245
<hex query="RAWTOHEX(%s)"/>
246+
<!--
247+
NOTE: ASCIISTR (https://www.techonthenet.com/oracle/functions/asciistr.php)
248+
-->
245249
<inference query="ASCII(SUBSTRC((%s),%d,1))>%d"/>
246250
<banner query="SELECT banner FROM v$version WHERE ROWNUM=1"/>
247251
<current_user query="SELECT USER FROM DUAL"/>

extra/vulnserver/vulnserver.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
import threading
1717
import traceback
1818

19-
if sys.version_info >= (3, 0):
19+
PY3 = sys.version_info >= (3, 0)
20+
21+
if PY3:
2022
from http.client import INTERNAL_SERVER_ERROR
2123
from http.client import NOT_FOUND
2224
from http.client import OK
@@ -169,7 +171,7 @@ def do_REQUEST(self):
169171
self.end_headers()
170172
else:
171173
self.end_headers()
172-
self.wfile.write(output.encode("utf8"))
174+
self.wfile.write(output.encode("utf8") if PY3 else output)
173175
else:
174176
self.send_response(NOT_FOUND)
175177
self.send_header("Connection", "close")

lib/core/common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3617,16 +3617,20 @@ def decodeIntToUnicode(value):
36173617
try:
36183618
if value > 255:
36193619
_ = "%x" % value
3620+
36203621
if len(_) % 2 == 1:
36213622
_ = "0%s" % _
3623+
36223624
raw = decodeHex(_)
36233625

36243626
if Backend.isDbms(DBMS.MYSQL):
3627+
# Reference: https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_ord
36253628
# Note: https://github.com/sqlmapproject/sqlmap/issues/1531
36263629
retVal = getUnicode(raw, conf.encoding or UNICODE_ENCODING)
36273630
elif Backend.isDbms(DBMS.MSSQL):
3628-
retVal = getUnicode(raw, "UTF-16-BE") # References: https://docs.microsoft.com/en-us/sql/relational-databases/collations/collation-and-unicode-support?view=sql-server-2017 and https://stackoverflow.com/a/14488478
3629-
elif Backend.getIdentifiedDbms() in (DBMS.PGSQL, DBMS.ORACLE):
3631+
# Reference: https://docs.microsoft.com/en-us/sql/relational-databases/collations/collation-and-unicode-support?view=sql-server-2017 and https://stackoverflow.com/a/14488478
3632+
retVal = getUnicode(raw, "UTF-16-BE")
3633+
elif Backend.getIdentifiedDbms() in (DBMS.PGSQL, DBMS.ORACLE, DBMS.SQLITE): # Note: cases with Unicode code points (e.g. http://www.postgresqltutorial.com/postgresql-ascii/)
36303634
retVal = _unichr(value)
36313635
else:
36323636
retVal = getUnicode(raw, conf.encoding)

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.11.114"
21+
VERSION = "1.3.11.115"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/core/testing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def vulnTest():
6565
"""
6666

6767
TESTS = (
68+
(u"-u <url> --flush-session --sql-query=\"SELECT '\u0161u\u0107uraj'\" --technique=U", (u": '\u0161u\u0107uraj'",)),
69+
(u"-u <url> --flush-session --sql-query=\"SELECT '\u0161u\u0107uraj'\" --technique=B --no-escape", (u": '\u0161u\u0107uraj'",)),
6870
("--list-tampers", ("between", "MySQL", "xforwardedfor")),
6971
("-r <request> --flush-session -v 5", ("CloudFlare", "possible DBMS: 'SQLite'", "User-agent: foobar")),
7072
("-l <log> --flush-session --skip-waf -v 3 --technique=U --union-from=users --banner --parse-errors", ("banner: '3.", "ORDER BY term out of range", "~xp_cmdshell")),

plugins/generic/syntax.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
import re
99

10+
from lib.core.common import Backend
1011
from lib.core.convert import getBytes
1112
from lib.core.data import conf
13+
from lib.core.enums import DBMS
1214
from lib.core.exception import SqlmapUndefinedMethod
1315

1416
class Syntax(object):
@@ -31,7 +33,7 @@ def _escape(expression, quote=True, escaper=None):
3133

3234
if replacement != original:
3335
retVal = retVal.replace(item, replacement)
34-
elif len(original) != len(getBytes(original)) and "n'%s'" % original not in retVal:
36+
elif len(original) != len(getBytes(original)) and "n'%s'" % original not in retVal and Backend.getDbms() in (DBMS.MYSQL, DBMS.PGSQL, DBMS.ORACLE, DBMS.MSSQL):
3537
retVal = retVal.replace("'%s'" % original, "n'%s'" % original)
3638
else:
3739
retVal = escaper(expression)

0 commit comments

Comments
 (0)