mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-11-21 07:31:32 +00:00
Minor patches
This commit is contained in:
parent
97c8b45ccc
commit
ab59a4b72a
8 changed files with 62 additions and 13 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue