diff --git a/lib/core/convert.py b/lib/core/convert.py index a92f08279..71afeb0ae 100644 --- a/lib/core/convert.py +++ b/lib/core/convert.py @@ -227,7 +227,7 @@ def encodeBase64(value, binary=True, encoding=None): return retVal -def getBytes(value, encoding=UNICODE_ENCODING, errors="strict", unsafe=True): +def getBytes(value, encoding=None, errors="strict", unsafe=True): """ Returns byte representation of provided Unicode value @@ -237,9 +237,12 @@ def getBytes(value, encoding=UNICODE_ENCODING, errors="strict", unsafe=True): retVal = value + if encoding is None: + encoding = conf.encoding or UNICODE_ENCODING + try: codecs.lookup(encoding) - except LookupError: + except (LookupError, TypeError): encoding = UNICODE_ENCODING if isinstance(value, six.text_type): diff --git a/lib/core/settings.py b/lib/core/settings.py index 5695adc83..d86e27bda 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.4.1.19" +VERSION = "1.4.1.20" 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/plugins/dbms/mysql/syntax.py b/plugins/dbms/mysql/syntax.py index 8d135c93e..b9b841828 100644 --- a/plugins/dbms/mysql/syntax.py +++ b/plugins/dbms/mysql/syntax.py @@ -26,6 +26,6 @@ class Syntax(GenericSyntax): if all(_ < 128 for _ in getOrds(value)): return "0x%s" % getUnicode(binascii.hexlify(getBytes(value))) else: - return "CONVERT(0x%s USING utf8)" % getUnicode(binascii.hexlify(getBytes(value))) + return "CONVERT(0x%s USING utf8)" % getUnicode(binascii.hexlify(getBytes(value, "utf8"))) return Syntax._escape(expression, quote, escaper)