Minor patch

This commit is contained in:
Miroslav Stampar 2020-03-06 12:21:26 +01:00
parent 8cc516dc5f
commit 97ccf4ca66
4 changed files with 10 additions and 10 deletions

View File

@ -938,9 +938,10 @@ def setColor(message, color=None, bold=False, level=None, istty=None):
""" """
retVal = message retVal = message
level = level or extractRegexResult(r"\[(?P<result>%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message)
if message and (IS_TTY or istty) and not conf.get("disableColoring"): # colorizing handler if message and (IS_TTY or istty) and not conf.get("disableColoring"): # colorizing handler
level = level or extractRegexResult(r"\[(?P<result>%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message)
if bold or color: if bold or color:
retVal = colored(message, color=color, on_color=None, attrs=("bold",) if bold else None) retVal = colored(message, color=color, on_color=None, attrs=("bold",) if bold else None)
elif level: elif level:
@ -974,7 +975,7 @@ def clearColors(message):
return retVal return retVal
def dataToStdout(data, forceOutput=False, bold=False, content_type=None, status=CONTENT_STATUS.IN_PROGRESS): def dataToStdout(data, forceOutput=False, bold=False, contentType=None, status=CONTENT_STATUS.IN_PROGRESS, coloring=True):
""" """
Writes text to the stdout (console) stream Writes text to the stdout (console) stream
""" """
@ -987,9 +988,9 @@ def dataToStdout(data, forceOutput=False, bold=False, content_type=None, status=
try: try:
if conf.get("api"): if conf.get("api"):
sys.stdout.write(stdoutEncode(clearColors(data)), status, content_type) sys.stdout.write(stdoutEncode(clearColors(data)), status, contentType)
else: else:
sys.stdout.write(stdoutEncode(setColor(data, bold=bold))) sys.stdout.write(stdoutEncode(setColor(data, bold=bold) if coloring else clearColors(data)))
sys.stdout.flush() sys.stdout.flush()
except IOError: except IOError:

View File

@ -72,7 +72,7 @@ class Dump(object):
text = "%s%s" % (data, "\n" if newline else " ") text = "%s%s" % (data, "\n" if newline else " ")
if conf.api: if conf.api:
dataToStdout(data, content_type=content_type, status=CONTENT_STATUS.COMPLETE) dataToStdout(data, contentType=content_type, status=CONTENT_STATUS.COMPLETE)
elif console: elif console:
dataToStdout(text) dataToStdout(text)

View File

@ -18,7 +18,7 @@ from lib.core.enums import OS
from thirdparty.six import unichr as _unichr from thirdparty.six import unichr as _unichr
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.4.3.1" VERSION = "1.4.3.2"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} 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) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -18,7 +18,6 @@ import threading
import time import time
from extra.vulnserver import vulnserver from extra.vulnserver import vulnserver
from lib.core.common import clearColors
from lib.core.common import clearConsoleLine from lib.core.common import clearConsoleLine
from lib.core.common import dataToStdout from lib.core.common import dataToStdout
from lib.core.common import randomInt from lib.core.common import randomInt
@ -132,7 +131,7 @@ def vulnTest():
if not all((check in output if not check.startswith('~') else check[1:] not in output) for check in checks) or "unhandled exception" in output: if not all((check in output if not check.startswith('~') else check[1:] not in output) for check in checks) or "unhandled exception" in output:
dataToStdout("---\n\n$ %s\n" % cmd) dataToStdout("---\n\n$ %s\n" % cmd)
dataToStdout("%s---\n" % clearColors(output)) dataToStdout("%s---\n" % output, coloring=False)
retVal = False retVal = False
count += 1 count += 1
@ -233,7 +232,7 @@ def bedTest():
if check not in output: if check not in output:
print(cmd, check) print(cmd, check)
dataToStdout("---\n\n$ %s\n" % cmd) dataToStdout("---\n\n$ %s\n" % cmd)
dataToStdout("%s---\n" % clearColors(output)) dataToStdout("%s---\n" % output, coloring=False)
retVal = False retVal = False
count += 1 count += 1
@ -297,7 +296,7 @@ def fuzzTest():
if "Traceback" in output: if "Traceback" in output:
dataToStdout("---\n\n$ %s\n" % cmd) dataToStdout("---\n\n$ %s\n" % cmd)
dataToStdout("%s---\n" % clearColors(output)) dataToStdout("%s---\n" % output, coloring=False)
handle, config = tempfile.mkstemp(prefix="sqlmapcrash", suffix=".conf") handle, config = tempfile.mkstemp(prefix="sqlmapcrash", suffix=".conf")
os.close(handle) os.close(handle)