From 20d875a8cea906c0cb94b180d7a3557520cc4057 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sat, 30 Nov 2019 23:10:20 +0100 Subject: [PATCH] Fixes #4020 --- lib/controller/checks.py | 3 ++- lib/core/common.py | 2 +- lib/core/convert.py | 7 ++++++- lib/core/settings.py | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index 02d8989ed..fab3f29e9 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -45,6 +45,7 @@ from lib.core.common import unArrayizeValue from lib.core.common import wasLastResponseDBMSError from lib.core.common import wasLastResponseHTTPError from lib.core.compat import xrange +from lib.core.convert import getBytes from lib.core.convert import getUnicode from lib.core.data import conf from lib.core.data import kb @@ -788,7 +789,7 @@ def checkSqlInjection(place, parameter, value): logger.info(infoMsg) try: - process = subprocess.Popen(conf.alert.encode(sys.getfilesystemencoding() or UNICODE_ENCODING), shell=True) + process = subprocess.Popen(getBytes(conf.alert, sys.getfilesystemencoding() or UNICODE_ENCODING), shell=True) process.wait() except Exception as ex: errMsg = "error occurred while executing '%s' ('%s')" % (conf.alert, getSafeExString(ex)) diff --git a/lib/core/common.py b/lib/core/common.py index 944c208c3..7f08066a5 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1970,7 +1970,7 @@ def safeFilepathEncode(filepath): retVal = filepath if filepath and six.PY2 and isinstance(filepath, six.text_type): - retVal = filepath.encode(sys.getfilesystemencoding() or UNICODE_ENCODING) + retVal = getBytes(filepath, sys.getfilesystemencoding() or UNICODE_ENCODING) return retVal diff --git a/lib/core/convert.py b/lib/core/convert.py index 51e7d7b85..1655d3d43 100644 --- a/lib/core/convert.py +++ b/lib/core/convert.py @@ -231,6 +231,11 @@ def getBytes(value, encoding=UNICODE_ENCODING, errors="strict", unsafe=True): retVal = value + try: + codecs.lookup(encoding) + except LookupError: + encoding = UNICODE_ENCODING + if isinstance(value, six.text_type): if INVALID_UNICODE_PRIVATE_AREA: if unsafe: @@ -391,4 +396,4 @@ def getConsoleLength(value): else: retVal = len(value) - return retVal \ No newline at end of file + return retVal diff --git a/lib/core/settings.py b/lib/core/settings.py index 9fa6825f4..c49b5d5b2 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.3.11.117" +VERSION = "1.3.11.118" 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)