From 74148e121a74c60ad7098c477cbac0e4f521092c Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 3 May 2019 13:48:41 +0200 Subject: [PATCH] Minor patch --- lib/core/common.py | 2 +- lib/core/settings.py | 2 +- lib/takeover/web.py | 12 +++++++----- plugins/generic/filesystem.py | 4 +++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 1e8b85b33..f9820e337 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -922,7 +922,7 @@ def setColor(message, color=None, bold=False, level=None, istty=None): elif level: try: level = getattr(logging, level, None) - except UnicodeError: + except: level = None retVal = LOGGER_HANDLER.colorize(message, level) diff --git a/lib/core/settings.py b/lib/core/settings.py index ad7265885..13a65690f 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty import six # sqlmap version (...) -VERSION = "1.3.5.12" +VERSION = "1.3.5.13" 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/takeover/web.py b/lib/takeover/web.py index 13d65c688..08d5c00e2 100644 --- a/lib/takeover/web.py +++ b/lib/takeover/web.py @@ -25,6 +25,7 @@ from lib.core.common import ntToPosixSlashes from lib.core.common import isTechniqueAvailable from lib.core.common import isWindowsDriveLetterPath from lib.core.common import normalizePath +from lib.core.common import openFile from lib.core.common import parseFilePaths from lib.core.common import posixToNtSlashes from lib.core.common import randomInt @@ -34,6 +35,7 @@ from lib.core.common import singleTimeWarnMessage from lib.core.compat import xrange from lib.core.convert import encodeHex from lib.core.convert import getBytes +from lib.core.convert import getText from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger @@ -274,9 +276,9 @@ class Web: directories = _ backdoorName = "tmpb%s.%s" % (randomStr(lowercase=True), self.webPlatform) - backdoorContent = decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "backdoors", "backdoor.%s_" % self.webPlatform)) + backdoorContent = getText(decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "backdoors", "backdoor.%s_" % self.webPlatform))) - stagerContent = decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.%s_" % self.webPlatform)) + stagerContent = getText(decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.%s_" % self.webPlatform))) for directory in directories: if not directory: @@ -330,9 +332,9 @@ class Web: handle, filename = tempfile.mkstemp() os.close(handle) - with open(filename, "w+b") as f: - _ = decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.%s_" % self.webPlatform)) - _ = _.replace(SHELL_WRITABLE_DIR_TAG, getBytes(directory.replace('/', '\\\\') if Backend.isOs(OS.WINDOWS) else directory)) + with openFile(filename, "w+b") as f: + _ = getText(decloak(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.%s_" % self.webPlatform))) + _ = _.replace(SHELL_WRITABLE_DIR_TAG, directory.replace('/', '\\\\') if Backend.isOs(OS.WINDOWS) else directory) f.write(_) self.unionWriteFile(filename, self.webStagerFilePath, "text", forceCheck=True) diff --git a/plugins/generic/filesystem.py b/plugins/generic/filesystem.py index f8044c611..4efd64437 100644 --- a/plugins/generic/filesystem.py +++ b/plugins/generic/filesystem.py @@ -5,6 +5,7 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +import codecs import os import sys @@ -21,6 +22,7 @@ from lib.core.common import isStackingAvailable from lib.core.common import isTechniqueAvailable from lib.core.common import readInput from lib.core.compat import xrange +from lib.core.convert import getText from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger @@ -133,7 +135,7 @@ class Filesystem: retVal = [] if encoding: - content = content.encode(encoding).replace("\n", "") + content = getText(codecs.encode(content, encoding)).replace("\n", "") if not single: if len(content) > chunkSize: