Minor patches

This commit is contained in:
Miroslav Štampar 2026-07-11 15:18:42 +02:00
parent 97c8b45ccc
commit ab59a4b72a
8 changed files with 62 additions and 13 deletions

View file

@ -5,6 +5,7 @@ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import binascii
import re
import time
@ -29,6 +30,20 @@ from lib.core.settings import UNICODE_ENCODING
from lib.utils.safe2bin import safecharencode
from lib.utils.timeout import timeout
def _hexifyBinary(value):
"""
Renders a raw binary cell returned by a driver in -d mode as uppercase hex, instead of letting it reach
the text channel as a str() like '<memory at 0x...>' (PostgreSQL bytea -> psycopg2 memoryview) or a
control-character blob that gets blanked/corrupted (e.g. MSSQL varbinary -> bytes). Text columns come back
as native strings, so only genuine binary values are converted (matches HEX()-based rendering elsewhere).
"""
if isinstance(value, memoryview):
value = value.tobytes()
if isinstance(value, (bytes, bytearray)):
return getUnicode(binascii.hexlify(value)).upper()
return value
def direct(query, content=True):
select = True
query = agent.payloadDirect(query)
@ -63,6 +78,8 @@ def direct(query, content=True):
timeout(func=conf.dbmsConnector.execute, args=(query,), duration=conf.timeout, default=None)
elif not (output and ("%soutput" % conf.tablePrefix) not in query and ("%sfile" % conf.tablePrefix) not in query):
output, state = timeout(func=conf.dbmsConnector.select, args=(query,), duration=conf.timeout, default=None)
if output and isListLike(output):
output = [tuple(_hexifyBinary(_) for _ in row) if isListLike(row) else _hexifyBinary(row) for row in output]
if state == TIMEOUT_STATE.NORMAL:
hashDBWrite(query, output, True)
elif state == TIMEOUT_STATE.TIMEOUT: