minor update regarding --hex

This commit is contained in:
Miroslav Stampar 2012-02-21 13:38:18 +00:00
parent bcf3255fe1
commit 686eacda9a
3 changed files with 14 additions and 14 deletions

View File

@ -279,12 +279,7 @@ class Agent:
@rtype: C{str} @rtype: C{str}
""" """
# SQLite version 2 does not support neither CAST() nor IFNULL(), if field.startswith("(CASE") or field.startswith("(IIF") or conf.noCast:
# introduced only in SQLite version 3
if Backend.isDbms(DBMS.SQLITE) or conf.noCast:
return field
if field.startswith("(CASE") or field.startswith("(IIF"):
nulledCastedField = field nulledCastedField = field
else: else:
_ = queries[Backend.getIdentifiedDbms()] _ = queries[Backend.getIdentifiedDbms()]

View File

@ -3117,13 +3117,14 @@ def decodeHexValue(value):
""" """
def _(value): def _(value):
if isinstance(value, basestring) and len(value) % 2 == 0: if value and isinstance(value, basestring) and len(value) % 2 == 0:
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.ORACLE, DBMS.PGSQL): if value.lower().startswith("0x"):
value = value.decode("hex") value = value[2:]
elif Backend.isDbms(DBMS.MSSQL): value = value.decode("hex")
value = value[2:].decode("hex") if len(value) > 1 and value[1] == '\x00':
if value[1] == '\x00': value = value.decode("utf-16-le")
value = value.decode("utf16") elif value and value[0] == '\x00':
value = value.decode("utf-16-be")
return value return value
return applyFunctionRecursively(value, _) return applyFunctionRecursively(value, _)

View File

@ -303,7 +303,7 @@
<dbms value="SQLite"> <dbms value="SQLite">
<cast query="CAST(%s AS VARCHAR(8000))" dbms_version="&gt;=3.0"/> <cast query="CAST(%s AS VARCHAR(8000))" dbms_version="&gt;=3.0"/>
<length query="LENGTH(%s)"/> <length query="LENGTH(%s)"/>
<isnull query="IFNULL(%s,' ')"/> <isnull query="IFNULL(%s,' ')" dbms_version="&gt;=3.0"/>
<delimiter query="||"/> <delimiter query="||"/>
<limit query="LIMIT %d,%d"/> <limit query="LIMIT %d,%d"/>
<limitregexp query="\s+LIMIT\s+([\d]+)\s*\,\s*([\d]+)"/> <limitregexp query="\s+LIMIT\s+([\d]+)\s*\,\s*([\d]+)"/>
@ -316,6 +316,7 @@
<timedelay query="SELECT LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB(1000000%d))))" dbms_version="&gt;=3.0"/> <timedelay query="SELECT LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB(1000000%d))))" dbms_version="&gt;=3.0"/>
<substring query="SUBSTR((%s),%d,%d)"/> <substring query="SUBSTR((%s),%d,%d)"/>
<case query="SELECT (CASE WHEN (%s) THEN 1 ELSE 0 END)"/> <case query="SELECT (CASE WHEN (%s) THEN 1 ELSE 0 END)"/>
<hex query="HEX(%s)"/>
<inference query="SUBSTR((%s),%d,1) > '%c'"/> <inference query="SUBSTR((%s),%d,1) > '%c'"/>
<banner query="SELECT SQLITE_VERSION()"/> <banner query="SELECT SQLITE_VERSION()"/>
<current_user/> <current_user/>
@ -456,6 +457,7 @@
<current_db query="SELECT DATABASE() FROM DUAL"/> <current_db query="SELECT DATABASE() FROM DUAL"/>
<order query="ORDER BY %s ASC"/> <order query="ORDER BY %s ASC"/>
<case query="SELECT (CASE WHEN (%s) THEN 1 ELSE 0 END)"/> <case query="SELECT (CASE WHEN (%s) THEN 1 ELSE 0 END)"/>
<hex query="HEX(%s)"/>
<inference query="SUBSTR((%s),%d,1) > '%c'"/> <inference query="SUBSTR((%s),%d,1) > '%c'"/>
<delimiter query=","/> <delimiter query=","/>
<substring query="SUBSTR((%s),%d,%d)"/> <substring query="SUBSTR((%s),%d,%d)"/>
@ -502,6 +504,7 @@
<timedelay query="WAITFOR DELAY '0:0:%d'"/> <timedelay query="WAITFOR DELAY '0:0:%d'"/>
<substring query="SUBSTRING((%s),%d,%d)"/> <substring query="SUBSTRING((%s),%d,%d)"/>
<case query="SELECT (CASE WHEN (%s) THEN '1' ELSE '0' END)"/> <case query="SELECT (CASE WHEN (%s) THEN '1' ELSE '0' END)"/>
<hex query="BINTOSTR(CONVERT(VARBINARY, %s))"/>
<inference query="ASCII(SUBSTRING((%s),%d,1)) > %d"/> <inference query="ASCII(SUBSTRING((%s),%d,1)) > %d"/>
<banner query="SELECT @@VERSION"/> <banner query="SELECT @@VERSION"/>
<current_user query="SELECT SUSER_NAME()"/> <current_user query="SELECT SUSER_NAME()"/>
@ -569,6 +572,7 @@
<timedelay query=""/> <timedelay query=""/>
<substring query="SUBSTR((%s),%d,%d)"/> <substring query="SUBSTR((%s),%d,%d)"/>
<case query="SELECT (CASE WHEN (%s) THEN '1' ELSE '0' END) FROM SYSIBM.SYSDUMMY1"/> <case query="SELECT (CASE WHEN (%s) THEN '1' ELSE '0' END) FROM SYSIBM.SYSDUMMY1"/>
<hex query="HEX(%s)"/>
<inference query="SUBSTR((%s),%d,1) > '%c'"/> <inference query="SUBSTR((%s),%d,1) > '%c'"/>
<!-- 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 --> <!-- 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 -->
<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"/> <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"/>