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

Skip to content

Commit 686eacd

Browse files
committed
minor update regarding --hex
1 parent bcf3255 commit 686eacd

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

lib/core/agent.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,7 @@ def nullAndCastField(self, field):
279279
@rtype: C{str}
280280
"""
281281

282-
# SQLite version 2 does not support neither CAST() nor IFNULL(),
283-
# introduced only in SQLite version 3
284-
if Backend.isDbms(DBMS.SQLITE) or conf.noCast:
285-
return field
286-
287-
if field.startswith("(CASE") or field.startswith("(IIF"):
282+
if field.startswith("(CASE") or field.startswith("(IIF") or conf.noCast:
288283
nulledCastedField = field
289284
else:
290285
_ = queries[Backend.getIdentifiedDbms()]

lib/core/common.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3117,13 +3117,14 @@ def decodeHexValue(value):
31173117
"""
31183118

31193119
def _(value):
3120-
if isinstance(value, basestring) and len(value) % 2 == 0:
3121-
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.ORACLE, DBMS.PGSQL):
3122-
value = value.decode("hex")
3123-
elif Backend.isDbms(DBMS.MSSQL):
3124-
value = value[2:].decode("hex")
3125-
if value[1] == '\x00':
3126-
value = value.decode("utf16")
3120+
if value and isinstance(value, basestring) and len(value) % 2 == 0:
3121+
if value.lower().startswith("0x"):
3122+
value = value[2:]
3123+
value = value.decode("hex")
3124+
if len(value) > 1 and value[1] == '\x00':
3125+
value = value.decode("utf-16-le")
3126+
elif value and value[0] == '\x00':
3127+
value = value.decode("utf-16-be")
31273128
return value
31283129

31293130
return applyFunctionRecursively(value, _)

xml/queries.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@
303303
<dbms value="SQLite">
304304
<cast query="CAST(%s AS VARCHAR(8000))" dbms_version="&gt;=3.0"/>
305305
<length query="LENGTH(%s)"/>
306-
<isnull query="IFNULL(%s,' ')"/>
306+
<isnull query="IFNULL(%s,' ')" dbms_version="&gt;=3.0"/>
307307
<delimiter query="||"/>
308308
<limit query="LIMIT %d,%d"/>
309309
<limitregexp query="\s+LIMIT\s+([\d]+)\s*\,\s*([\d]+)"/>
@@ -316,6 +316,7 @@
316316
<timedelay query="SELECT LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB(1000000%d))))" dbms_version="&gt;=3.0"/>
317317
<substring query="SUBSTR((%s),%d,%d)"/>
318318
<case query="SELECT (CASE WHEN (%s) THEN 1 ELSE 0 END)"/>
319+
<hex query="HEX(%s)"/>
319320
<inference query="SUBSTR((%s),%d,1) > '%c'"/>
320321
<banner query="SELECT SQLITE_VERSION()"/>
321322
<current_user/>
@@ -456,6 +457,7 @@
456457
<current_db query="SELECT DATABASE() FROM DUAL"/>
457458
<order query="ORDER BY %s ASC"/>
458459
<case query="SELECT (CASE WHEN (%s) THEN 1 ELSE 0 END)"/>
460+
<hex query="HEX(%s)"/>
459461
<inference query="SUBSTR((%s),%d,1) > '%c'"/>
460462
<delimiter query=","/>
461463
<substring query="SUBSTR((%s),%d,%d)"/>
@@ -502,6 +504,7 @@
502504
<timedelay query="WAITFOR DELAY '0:0:%d'"/>
503505
<substring query="SUBSTRING((%s),%d,%d)"/>
504506
<case query="SELECT (CASE WHEN (%s) THEN '1' ELSE '0' END)"/>
507+
<hex query="BINTOSTR(CONVERT(VARBINARY, %s))"/>
505508
<inference query="ASCII(SUBSTRING((%s),%d,1)) > %d"/>
506509
<banner query="SELECT @@VERSION"/>
507510
<current_user query="SELECT SUSER_NAME()"/>
@@ -569,6 +572,7 @@
569572
<timedelay query=""/>
570573
<substring query="SUBSTR((%s),%d,%d)"/>
571574
<case query="SELECT (CASE WHEN (%s) THEN '1' ELSE '0' END) FROM SYSIBM.SYSDUMMY1"/>
575+
<hex query="HEX(%s)"/>
572576
<inference query="SUBSTR((%s),%d,1) > '%c'"/>
573577
<!-- NOTE: We have to use the complicated UDB OLAP functions in query2 because sqlmap injects isnull query inside MAX function, else we would use: SELECT MAX(versionnumber) FROM sysibm.sysversions -->
574578
<banner query="SELECT service_level FROM TABLE (sysproc.env_get_inst_info())" query2="SELECT versionnumber FROM (SELECT ROW_NUMBER() OVER (ORDER BY versionnumber DESC) AS LIMIT, versionnumber FROM sysibm.sysversions) AS foobar WHERE LIMIT=1"/>

0 commit comments

Comments
 (0)