From 620f3a77a1c4488c98dff28ba7eae2e43be7078c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0tampar?= Date: Mon, 20 Jul 2026 10:16:57 +0200 Subject: [PATCH] Fixing charunicodeencode tamper script --- lib/core/settings.py | 2 +- tamper/charunicodeencode.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/core/settings.py b/lib/core/settings.py index d17576fa2..4b711de52 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -20,7 +20,7 @@ from lib.core.enums import OS from thirdparty import six # sqlmap version (...) -VERSION = "1.10.7.142" +VERSION = "1.10.7.143" 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) diff --git a/tamper/charunicodeencode.py b/tamper/charunicodeencode.py index 3772b0b24..01144c91a 100644 --- a/tamper/charunicodeencode.py +++ b/tamper/charunicodeencode.py @@ -35,6 +35,8 @@ def tamper(payload, **kwargs): >>> tamper('SELECT FIELD%20FROM TABLE') '%u0053%u0045%u004C%u0045%u0043%u0054%u0020%u0046%u0049%u0045%u004C%u0044%u0020%u0046%u0052%u004F%u004D%u0020%u0054%u0041%u0042%u004C%u0045' + >>> tamper(u'\U0001F600') == '%uD83D%uDE00' + True """ retVal = payload @@ -48,7 +50,14 @@ 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: + # Note: %uXXXX is UTF-16 based, so a non-BMP char (e.g. an emoji) must be emitted + # as a surrogate pair - '%.4X' alone would produce an invalid 5-digit '%uXXXXX' + ordinal -= 0x10000 + retVal += "%%u%04X%%u%04X" % (0xD800 + (ordinal >> 10), 0xDC00 + (ordinal & 0x3FF)) + else: + retVal += '%%u%.4X' % ordinal i += 1 return retVal