diff --git a/lib/core/common.py b/lib/core/common.py index e2bb7c7a8..6ca246f7a 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -943,28 +943,31 @@ def setColor(message, color=None, bold=False, level=None, istty=None): retVal = message - if message and (IS_TTY or istty) and not conf.get("disableColoring"): # colorizing handler - if level is None: - levels = re.findall(r"\[(?P%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message) + if message: + if (IS_TTY or istty) and not conf.get("disableColoring"): # colorizing handler + if level is None: + levels = re.findall(r"\[(?P%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message) - if len(levels) == 1: - level = levels[0] + if len(levels) == 1: + level = levels[0] - if bold or color: - retVal = colored(message, color=color, on_color=None, attrs=("bold",) if bold else None) - elif level: - try: - level = getattr(logging, level, None) - except: - level = None - retVal = LOGGER_HANDLER.colorize(message, level) - else: - match = re.search(r"\(([^)]*)\s*fork\)", message) - if match: - retVal = retVal.replace(match.group(1), colored(match.group(1), color="lightgrey")) + if bold or color: + retVal = colored(message, color=color, on_color=None, attrs=("bold",) if bold else None) + elif level: + try: + level = getattr(logging, level, None) + except: + level = None + retVal = LOGGER_HANDLER.colorize(message, level) + else: + match = re.search(r"\(([^)]*)\s*fork\)", message) + if match: + retVal = retVal.replace(match.group(1), colored(match.group(1), color="lightgrey")) - for match in re.finditer(r"([^\w])'([^\n']+)'", message): # single-quoted (Note: watch-out for the banner) - retVal = retVal.replace(match.group(0), "%s'%s'" % (match.group(1), colored(match.group(2), color="lightgrey"))) + for match in re.finditer(r"([^\w])'([^\n']+)'", message): # single-quoted (Note: watch-out for the banner) + retVal = retVal.replace(match.group(0), "%s'%s'" % (match.group(1), colored(match.group(2), color="lightgrey"))) + + message = message.strip() return retVal @@ -988,6 +991,12 @@ def dataToStdout(data, forceOutput=False, bold=False, contentType=None, status=C Writes text to the stdout (console) stream """ + if not IS_TTY and isinstance(data, six.string_types) and data.startswith("\r"): + if re.search(r"\(\d+%\)", data): + data = "" + else: + data = "\n%s" % data.strip("\r") + if not kb.get("threadException"): if forceOutput or not (getCurrentThreadData().disableStdOut or kb.get("wizardMode")): multiThreadMode = isMultiThreadMode() diff --git a/lib/core/settings.py b/lib/core/settings.py index e20b1e2df..0b5ecf792 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.4.4.3" +VERSION = "1.4.4.4" 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)