Fixing unhandled exception message and removing sticky level logic

This commit is contained in:
Miroslav Stampar 2019-01-30 00:45:38 +01:00
parent ed26dc0235
commit 1f375e418a
7 changed files with 14 additions and 25 deletions

View File

@ -872,9 +872,9 @@ def boldifyMessage(message):
return retVal
def setColor(message, color=None, bold=False):
def setColor(message, color=None, bold=False, level=None):
retVal = message
level = extractRegexResult(r"\[(?P<result>%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message) or kb.get("stickyLevel")
level = level or extractRegexResult(r"\[(?P<result>%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message)
if isinstance(level, unicode):
level = unicodeencode(level)
@ -884,11 +884,7 @@ def setColor(message, color=None, bold=False):
retVal = colored(message, color=color, on_color=None, attrs=("bold",) if bold else None)
elif level:
level = getattr(logging, level, None) if isinstance(level, basestring) else level
if message != '.':
retVal = LOGGER_HANDLER.colorize(message, level)
kb.stickyLevel = level if message and message[-1] != "\n" else None
else:
kb.stickyLevel = None
retVal = LOGGER_HANDLER.colorize(message, level)
return retVal
@ -999,7 +995,6 @@ def readInput(message, default=None, checkBatch=True, boolean=False):
"""
retVal = None
kb.stickyLevel = None
message = getUnicode(message)
@ -2039,7 +2034,6 @@ def clearConsoleLine(forceOutput=False):
dataToStdout("\r%s\r" % (" " * (getConsoleWidth() - 1)), forceOutput)
kb.prependFlag = False
kb.stickyLevel = None
def parseXmlFile(xmlFile, handler):
"""
@ -3358,8 +3352,7 @@ def unhandledExceptionMessage():
errMsg += "repository at '%s'. If the exception persists, please open a new issue " % GIT_PAGE
errMsg += "at '%s' " % ISSUES_PAGE
errMsg += "with the following text and any other information required to "
errMsg += "reproduce the bug. The "
errMsg += "developers will try to reproduce the bug, fix it accordingly "
errMsg += "reproduce the bug. Developers will try to reproduce the bug, fix it accordingly "
errMsg += "and get back to you\n"
errMsg += "Running version: %s\n" % VERSION_STRING[VERSION_STRING.find('/') + 1:]
errMsg += "Python version: %s\n" % PYVERSION
@ -3495,7 +3488,7 @@ def maskSensitiveData(msg):
retVal = retVal.replace(match.group(3), '*' * len(match.group(3)))
# Fail-safe substitution
retVal = re.sub(r"(?i)\bhttps?://[^ ]+", lambda match: '*' * len(match.group(0)), retVal)
retVal = re.sub(r"(?i)(Command line:.+)\b(https?://[^ ]+)", lambda match: "%s%s" % (match.group(1), '*' * len(match.group(2))), retVal)
if getpass.getuser():
retVal = re.sub(r"(?i)\b%s\b" % re.escape(getpass.getuser()), '*' * len(getpass.getuser()), retVal)

View File

@ -112,8 +112,6 @@ class Dump(object):
self._write(data, content_type=content_type)
def string(self, header, data, content_type=None, sort=True):
kb.stickyLevel = None
if conf.api:
self._write(data, content_type=content_type)
return

View File

@ -1881,7 +1881,6 @@ def _setKnowledgeBaseAttributes(flushAll=True):
kb.reduceTests = None
kb.tlsSNI = {}
kb.stickyDBMS = False
kb.stickyLevel = None
kb.storeCrawlingChoice = None
kb.storeHashesChoice = None
kb.suppressResumeInfo = False

View File

@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME
from lib.core.enums import OS
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.3.1.81"
VERSION = "1.3.1.82"
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)

View File

@ -645,7 +645,6 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
abortedFlag = True
finally:
kb.prependFlag = False
kb.stickyLevel = None
retrievedLength = len(finalValue or "")
if finalValue is not None:

View File

@ -53,6 +53,7 @@ try:
from lib.core.data import kb
from lib.core.common import unhandledExceptionMessage
from lib.core.common import MKSTEMP_PREFIX
from lib.core.common import setColor
from lib.core.exception import SqlmapBaseException
from lib.core.exception import SqlmapShellQuitException
from lib.core.exception import SqlmapSilentQuitException
@ -339,8 +340,7 @@ def main():
logger.critical("%s\n%s" % (errMsg, excMsg))
else:
logger.critical(errMsg)
kb.stickyLevel = logging.CRITICAL
dataToStdout(excMsg)
dataToStdout("%s\n" % setColor(excMsg.strip(), level=logging.CRITICAL))
createGithubIssue(errMsg, excMsg)
finally:

View File

@ -30,27 +30,27 @@ c1da277517c7ec4c23e953a51b51e203 lib/controller/handler.py
fb6be55d21a70765e35549af2484f762 lib/controller/__init__.py
ed7874be0d2d3802f3d20184f2b280d5 lib/core/agent.py
a932126e7d80e545c5d44af178d0bc0c lib/core/bigarray.py
f97e6dc62b453cc787ef7f801ee1af5b lib/core/common.py
76825cafb1916b85a8738493de8607c6 lib/core/common.py
de8d27ae6241163ff9e97aa9e7c51a18 lib/core/convert.py
abcb1121eb56d3401839d14e8ed06b6e lib/core/data.py
e1f7758f433202c50426efde5eb96768 lib/core/datatype.py
1646402a733e564f05025e848b323cf9 lib/core/decorators.py
5f4680b769ae07f22157bd832c97cf8f lib/core/defaults.py
9dfc69ba47209a4ceca494dde9ee8183 lib/core/dicts.py
4782353a3072e4d17c4e314daf918d8a lib/core/dump.py
13ca1a870fa0b01b9593f25e9e93ed9c lib/core/dump.py
5c91145204092b995ed1ac641e9e291d lib/core/enums.py
84ef8f32e4582fcc294dc14e1997131d lib/core/exception.py
fb6be55d21a70765e35549af2484f762 lib/core/__init__.py
18c896b157b03af716542e5fe9233ef9 lib/core/log.py
fa9f24e88c81a6cef52da3dd5e637010 lib/core/optiondict.py
b56df9d9426027f3450432c2b6428485 lib/core/option.py
b39587efbf4aef1283c0bbf1e723a8ab lib/core/option.py
fe370021c6bc99daf44b2bfc0d1effb3 lib/core/patch.py
4b12aa67fbf6c973d12e54cf9cb54ea0 lib/core/profiling.py
5e2c16a8e2daee22dd545df13386e7a3 lib/core/readlineng.py
7d8a22c582ad201f65b73225e4456170 lib/core/replication.py
3179d34f371e0295dd4604568fb30bcd lib/core/revision.py
d6269c55789f78cf707e09a0f5b45443 lib/core/session.py
e9e5e6207591b134c0cf4ecf8e712ea9 lib/core/settings.py
8a8ee76f9b901b16929cf875807a7690 lib/core/settings.py
4483b4a5b601d8f1c4281071dff21ecc lib/core/shell.py
10fd19b0716ed261e6d04f311f6f527c lib/core/subprocessng.py
9c7b5c6397fb3da33e7a4d7876d159c6 lib/core/target.py
@ -91,7 +91,7 @@ d55029a4c048e345fbb07a8f91604d83 lib/takeover/metasploit.py
ad038ac567f97a4b940b7987792d64a4 lib/takeover/udf.py
915a3fbd557fb136bd0e16c46d993be3 lib/takeover/web.py
1aadcdc058bb813d09ad23d26ea2a6b5 lib/takeover/xp_cmdshell.py
034490840639b5ca2bc97af4cb14f449 lib/techniques/blind/inference.py
96f120e4299baaea4defd902afc85979 lib/techniques/blind/inference.py
fb6be55d21a70765e35549af2484f762 lib/techniques/blind/__init__.py
fb6be55d21a70765e35549af2484f762 lib/techniques/dns/__init__.py
ea48db4c48276d7d0e71aa467c0c523f lib/techniques/dns/test.py
@ -236,7 +236,7 @@ ec2ba8c757ac96425dcd2b97970edd3a shell/stagers/stager.asp_
0c48ddb1feb7e38a951ef05a0d48e032 shell/stagers/stager.jsp_
2f9e459a4cf6a58680978cdce5ff7971 shell/stagers/stager.php_
41522f8ad02ac133ca0aeaab374c36a8 sqlmapapi.py
3926fb4ba81b03abede53d507ab89aab sqlmap.py
76998d373c6aef8d36d617a9b21d6eaf sqlmap.py
772fb3dd15edc9d4055ab9f9dee0c203 tamper/0x2char.py
3d89a5c4c33d4d1d9303f5e3bd11f0ae tamper/apostrophemask.py
1fd0eec63970728c1e6628b2e4c21d81 tamper/apostrophenullencode.py