diff --git a/lib/core/common.py b/lib/core/common.py index 27c16b9c2..9824bef85 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -356,7 +356,7 @@ def dataToStdout(data): sys.stdout.write(data) sys.stdout.flush() except UnicodeEncodeError: - print data.encode("utf8") + print data.encode(conf.dataEncoding) def dataToSessionFile(data): if not conf.sessionFile: @@ -375,7 +375,7 @@ def dataToOutFile(data): rFile = filePathToString(conf.rFile) rFilePath = "%s%s%s" % (conf.filePath, os.sep, rFile) - rFileFP = codecs.open(rFilePath, "wb", "utf-8") + rFileFP = codecs.open(rFilePath, "wb", conf.dataEncoding) rFileFP.write(data) rFileFP.flush() @@ -416,7 +416,7 @@ def fileToStr(fileName): @rtype: C{str} """ - filePointer = codecs.open(fileName, "r", "utf-8") + filePointer = codecs.open(fileName, "r", conf.dataEncoding) fileText = filePointer.read() return fileText.replace(" ", "").replace("\t", "").replace("\r", "").replace("\n", " ") diff --git a/lib/core/dump.py b/lib/core/dump.py index 39ec728a1..5e9622e0f 100644 --- a/lib/core/dump.py +++ b/lib/core/dump.py @@ -55,7 +55,7 @@ class Dump: def setOutputFile(self): self.__outputFile = "%s%slog" % (conf.outputPath, os.sep) - self.__outputFP = codecs.open(self.__outputFile, "a", "utf-8") + self.__outputFP = codecs.open(self.__outputFile, "a", conf.dataEncoding) def string(self, header, data, sort=True): if isinstance(data, (list, tuple, set)): @@ -268,7 +268,7 @@ class Dump: os.makedirs(dumpDbPath, 0755) dumpFileName = "%s%s%s.csv" % (dumpDbPath, os.sep, table) - dumpFP = codecs.open(dumpFileName, "w", "utf-8") + dumpFP = codecs.open(dumpFileName, "w", conf.dataEncoding) count = int(tableValues["__infos__"]["count"]) separator = "" diff --git a/lib/core/option.py b/lib/core/option.py index 010106d86..762ea84e3 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -97,7 +97,7 @@ def __urllib2Opener(): urllib2.install_opener(opener) def __feedTargetsDict(reqFile, addedTargetUrls): - fp = codecs.open(reqFile, "r", "utf-8") + fp = codecs.open(reqFile, "r", conf.dataEncoding) fread = fp.read() fread = fread.replace("\r", "") @@ -884,6 +884,7 @@ def __setConfAttributes(): logger.debug(debugMsg) conf.cj = None + conf.dataEncoding = "utf-8" conf.dbmsConnector = None conf.dbmsHandler = None conf.dumpPath = None diff --git a/lib/core/target.py b/lib/core/target.py index 922964f80..d80d80677 100644 --- a/lib/core/target.py +++ b/lib/core/target.py @@ -122,7 +122,7 @@ def __setOutputResume(): if os.path.exists(conf.sessionFile): if not conf.flushSession: - readSessionFP = codecs.open(conf.sessionFile, "r", "utf-8") + readSessionFP = codecs.open(conf.sessionFile, "r", conf.dataEncoding) __url_cache = set() __expression_cache = {} @@ -171,7 +171,7 @@ def __setOutputResume(): raise sqlmapFilePathException, errMsg try: - conf.sessionFP = codecs.open(conf.sessionFile, "a", "utf-8") + conf.sessionFP = codecs.open(conf.sessionFile, "a", conf.dataEncoding) dataToSessionFile("\n[%s]\n" % time.strftime("%X %x")) except IOError: errMsg = "unable to write on the session file specified"