From bcb25823e6d03196a605c8876c0737198f98ccdf Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 30 Jul 2015 23:19:38 +0200 Subject: [PATCH] Fixes #1320 --- lib/core/common.py | 4 ++-- lib/core/dump.py | 4 ++-- lib/core/option.py | 2 +- lib/core/replication.py | 2 +- lib/parse/cmdline.py | 2 +- lib/utils/hash.py | 3 ++- plugins/generic/entries.py | 4 ++-- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 3ca8dad31..5b914b159 100755 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -876,7 +876,7 @@ def dataToOutFile(filename, data): f.write(data) except IOError, ex: errMsg = "something went wrong while trying to write " - errMsg += "to the output file ('%s')" % ex + errMsg += "to the output file ('%s')" % getUnicode(ex) raise SqlmapGenericException(errMsg) return retVal @@ -3662,7 +3662,7 @@ def evaluateCode(code, variables=None): except KeyboardInterrupt: raise except Exception, ex: - errMsg = "an error occurred while evaluating provided code ('%s'). " % ex + errMsg = "an error occurred while evaluating provided code ('%s') " % getUnicode(ex) raise SqlmapGenericException(errMsg) def serializeObject(object_): diff --git a/lib/core/dump.py b/lib/core/dump.py index d3b9cc799..08410602d 100644 --- a/lib/core/dump.py +++ b/lib/core/dump.py @@ -74,7 +74,7 @@ class Dump(object): try: self._outputFP.write(text) except IOError, ex: - errMsg = "error occurred while writing to log file ('%s')" % ex + errMsg = "error occurred while writing to log file ('%s')" % getUnicode(ex) raise SqlmapGenericException(errMsg) if kb.get("multiThreadMode"): @@ -94,7 +94,7 @@ class Dump(object): try: self._outputFP = openFile(self._outputFile, "ab" if not conf.flushSession else "wb") except IOError, ex: - errMsg = "error occurred while opening log file ('%s')" % ex + errMsg = "error occurred while opening log file ('%s')" % getUnicode(ex) raise SqlmapGenericException(errMsg) def getOutputFile(self): diff --git a/lib/core/option.py b/lib/core/option.py index dcef83c03..f5edb95b4 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1521,7 +1521,7 @@ def _createTemporaryDirectory(): os.makedirs(tempfile.gettempdir()) except IOError, ex: errMsg = "there has been a problem while accessing " - errMsg += "system's temporary directory location(s) ('%s'). Please " % ex + errMsg += "system's temporary directory location(s) ('%s'). Please " % getUnicode(ex) errMsg += "make sure that there is enough disk space left. If problem persists, " errMsg += "try to set environment variable 'TEMP' to a location " errMsg += "writeable by the current user" diff --git a/lib/core/replication.py b/lib/core/replication.py index b65f818de..c5bbd24cc 100644 --- a/lib/core/replication.py +++ b/lib/core/replication.py @@ -70,7 +70,7 @@ class Replication(object): try: self.parent.cursor.execute(sql, parameters) except sqlite3.OperationalError, ex: - errMsg = "problem occurred ('%s') while accessing sqlite database " % ex + errMsg = "problem occurred ('%s') while accessing sqlite database " % unicode(ex) errMsg += "located at '%s'. Please make sure that " % self.parent.dbpath errMsg += "it's not used by some other program" raise SqlmapGenericException(errMsg) diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 23add4a9d..ef2f535f7 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -862,7 +862,7 @@ def cmdLineParser(): for arg in shlex.split(command): argv.append(getUnicode(arg, encoding=sys.stdin.encoding)) except ValueError, ex: - raise SqlmapSyntaxException, "something went wrong during command line parsing ('%s')" % ex + raise SqlmapSyntaxException, "something went wrong during command line parsing ('%s')" % getUnicode(ex) # Hide non-basic options in basic help case for i in xrange(len(argv)): diff --git a/lib/utils/hash.py b/lib/utils/hash.py index 123b93ee7..b1459b032 100644 --- a/lib/utils/hash.py +++ b/lib/utils/hash.py @@ -44,6 +44,7 @@ from lib.core.common import clearConsoleLine from lib.core.common import dataToStdout from lib.core.common import getFileItems from lib.core.common import getPublicTypeMembers +from lib.core.common import getUnicode from lib.core.common import hashDBRetrieve from lib.core.common import hashDBWrite from lib.core.common import normalizeUnicode @@ -769,7 +770,7 @@ def dictionaryAttack(attack_dict): except Exception, ex: warnMsg = "there was a problem while loading dictionaries" - warnMsg += " ('%s')" % ex + warnMsg += " ('%s')" % getUnicode(ex) logger.critical(warnMsg) message = "do you want to use common password suffixes? (slow!) [y/N] " diff --git a/plugins/generic/entries.py b/plugins/generic/entries.py index 628f01049..598bf3a01 100644 --- a/plugins/generic/entries.py +++ b/plugins/generic/entries.py @@ -341,13 +341,13 @@ class Entries: attackDumpedTable() except (IOError, OSError), ex: errMsg = "an error occurred while attacking " - errMsg += "table dump ('%s')" % ex + errMsg += "table dump ('%s')" % getUnicode(ex) logger.critical(errMsg) conf.dumper.dbTableValues(kb.data.dumpedTable) except SqlmapConnectionException, ex: errMsg = "connection exception detected in dumping phase " - errMsg += "('%s')" % ex + errMsg += "('%s')" % getUnicode(ex) logger.critical(errMsg) finally: