From c14c471490d7e0d734817b3e489da96d64401f3a Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sun, 19 May 2019 07:52:38 +0200 Subject: [PATCH] Fixes #3681 --- lib/core/patch.py | 3 +++ lib/core/settings.py | 2 +- lib/utils/sqlalchemy.py | 11 +++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/core/patch.py b/lib/core/patch.py index d252f1220..e5bf06f19 100644 --- a/lib/core/patch.py +++ b/lib/core/patch.py @@ -14,11 +14,13 @@ import lib.core.convert import lib.core.option import lib.request.connect import lib.utils.search +import lib.utils.sqlalchemy import thirdparty.ansistrm.ansistrm from lib.request.templates import getPageTemplate from lib.core.common import filterNone +from lib.core.common import getSafeExString from lib.core.common import isListLike from lib.core.common import singleTimeWarnMessage from lib.core.common import readInput @@ -67,6 +69,7 @@ def resolveCrossReferences(): lib.utils.search.setHTTPHandlers = _setHTTPHandlers lib.controller.checks.setVerbosity = setVerbosity lib.controller.checks.setWafFunctions = _setWafFunctions + lib.utils.sqlalchemy.getSafeExString = getSafeExString thirdparty.ansistrm.ansistrm.stdoutencode = stdoutencode def pympTempLeakPatch(tempDir): diff --git a/lib/core/settings.py b/lib/core/settings.py index 4be103861..8fe18a3bf 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.5.107" +VERSION = "1.3.5.108" 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/lib/utils/sqlalchemy.py b/lib/utils/sqlalchemy.py index 484b421ae..13d836105 100644 --- a/lib/utils/sqlalchemy.py +++ b/lib/utils/sqlalchemy.py @@ -35,6 +35,9 @@ from lib.core.exception import SqlmapFilePathException from lib.core.exception import SqlmapMissingDependence from plugins.generic.connector import Connector as GenericConnector +def getSafeExString(ex, encoding=None): # Cross-referenced function + raise NotImplementedError + class SQLAlchemy(GenericConnector): def __init__(self, dialect=None): GenericConnector.__init__(self) @@ -77,7 +80,7 @@ class SQLAlchemy(GenericConnector): except SqlmapFilePathException: raise except Exception as ex: - raise SqlmapConnectionException("SQLAlchemy connection issue ('%s')" % ex.msg) + raise SqlmapConnectionException("SQLAlchemy connection issue ('%s')" % getSafeExString(ex)) self.printConnected() else: @@ -90,16 +93,16 @@ class SQLAlchemy(GenericConnector): retVal.append(tuple(row)) return retVal except _sqlalchemy.exc.ProgrammingError as ex: - logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % ex.message if hasattr(ex, "message") else ex) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(ex)) return None def execute(self, query): try: self.cursor = self.connector.execute(query) except (_sqlalchemy.exc.OperationalError, _sqlalchemy.exc.ProgrammingError) as ex: - logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % ex.message if hasattr(ex, "message") else ex) + logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % getSafeExString(ex)) except _sqlalchemy.exc.InternalError as ex: - raise SqlmapConnectionException(ex[1]) + raise SqlmapConnectionException(getSafeExString(ex)) def select(self, query): self.execute(query)