mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-08-04 14:55:40 +00:00
Fixing tamper unicode/overlong encoding for characters beyond BMP/U+07FF
This commit is contained in:
parent
90fe32f386
commit
1b09b028ba
4 changed files with 20 additions and 4 deletions
|
|
@ -20,7 +20,7 @@ from lib.core.enums import OS
|
|||
from thirdparty import six
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.10.7.228"
|
||||
VERSION = "1.10.7.229"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,13 @@ def tamper(payload, **kwargs):
|
|||
retVal += "\\u00%s" % payload[i + 1:i + 3]
|
||||
i += 3
|
||||
else:
|
||||
retVal += '\\u%.4X' % ord(payload[i])
|
||||
ordinal = ord(payload[i])
|
||||
if ordinal > 0xFFFF:
|
||||
# non-BMP: emit a UTF-16 surrogate pair (a bare 5-hex '\uXXXXX' is invalid)
|
||||
ordinal -= 0x10000
|
||||
retVal += "\\u%04X\\u%04X" % (0xD800 + (ordinal >> 10), 0xDC00 + (ordinal & 0x3FF))
|
||||
else:
|
||||
retVal += "\\u%04X" % ordinal
|
||||
i += 1
|
||||
|
||||
return retVal
|
||||
|
|
|
|||
|
|
@ -38,7 +38,12 @@ def tamper(payload, **kwargs):
|
|||
i += 3
|
||||
else:
|
||||
if payload[i] not in (string.ascii_letters + string.digits):
|
||||
retVal += "%%%.2X%%%.2X" % (0xc0 + (ord(payload[i]) >> 6), 0x80 + (ord(payload[i]) & 0x3f))
|
||||
ordinal = ord(payload[i])
|
||||
if ordinal <= 0x7FF:
|
||||
retVal += "%%%.2X%%%.2X" % (0xc0 + (ordinal >> 6), 0x80 + (ordinal & 0x3f))
|
||||
else:
|
||||
# the 2-byte overlong form can't hold code points > U+07FF; fall back to real UTF-8
|
||||
retVal += "".join("%%%.2X" % _ for _ in bytearray(payload[i].encode("utf8")))
|
||||
else:
|
||||
retVal += payload[i]
|
||||
i += 1
|
||||
|
|
|
|||
|
|
@ -37,7 +37,12 @@ def tamper(payload, **kwargs):
|
|||
retVal += payload[i:i + 3]
|
||||
i += 3
|
||||
else:
|
||||
retVal += "%%%.2X%%%.2X" % (0xc0 + (ord(payload[i]) >> 6), 0x80 + (ord(payload[i]) & 0x3f))
|
||||
ordinal = ord(payload[i])
|
||||
if ordinal <= 0x7FF:
|
||||
retVal += "%%%.2X%%%.2X" % (0xc0 + (ordinal >> 6), 0x80 + (ordinal & 0x3f))
|
||||
else:
|
||||
# the 2-byte overlong form can't hold code points > U+07FF; fall back to real UTF-8
|
||||
retVal += "".join("%%%.2X" % _ for _ in bytearray(payload[i].encode("utf8")))
|
||||
i += 1
|
||||
|
||||
return retVal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue