Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f375e4

Browse files
committed
Fixing unhandled exception message and removing sticky level logic
1 parent ed26dc0 commit 1f375e4

7 files changed

Lines changed: 14 additions & 25 deletions

File tree

lib/core/common.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -872,9 +872,9 @@ def boldifyMessage(message):
872872

873873
return retVal
874874

875-
def setColor(message, color=None, bold=False):
875+
def setColor(message, color=None, bold=False, level=None):
876876
retVal = message
877-
level = extractRegexResult(r"\[(?P<result>%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message) or kb.get("stickyLevel")
877+
level = level or extractRegexResult(r"\[(?P<result>%s)\]" % '|'.join(_[0] for _ in getPublicTypeMembers(LOGGING_LEVELS)), message)
878878

879879
if isinstance(level, unicode):
880880
level = unicodeencode(level)
@@ -884,11 +884,7 @@ def setColor(message, color=None, bold=False):
884884
retVal = colored(message, color=color, on_color=None, attrs=("bold",) if bold else None)
885885
elif level:
886886
level = getattr(logging, level, None) if isinstance(level, basestring) else level
887-
if message != '.':
888-
retVal = LOGGER_HANDLER.colorize(message, level)
889-
kb.stickyLevel = level if message and message[-1] != "\n" else None
890-
else:
891-
kb.stickyLevel = None
887+
retVal = LOGGER_HANDLER.colorize(message, level)
892888

893889
return retVal
894890

@@ -999,7 +995,6 @@ def readInput(message, default=None, checkBatch=True, boolean=False):
999995
"""
1000996

1001997
retVal = None
1002-
kb.stickyLevel = None
1003998

1004999
message = getUnicode(message)
10051000

@@ -2039,7 +2034,6 @@ def clearConsoleLine(forceOutput=False):
20392034
dataToStdout("\r%s\r" % (" " * (getConsoleWidth() - 1)), forceOutput)
20402035

20412036
kb.prependFlag = False
2042-
kb.stickyLevel = None
20432037

20442038
def parseXmlFile(xmlFile, handler):
20452039
"""
@@ -3358,8 +3352,7 @@ def unhandledExceptionMessage():
33583352
errMsg += "repository at '%s'. If the exception persists, please open a new issue " % GIT_PAGE
33593353
errMsg += "at '%s' " % ISSUES_PAGE
33603354
errMsg += "with the following text and any other information required to "
3361-
errMsg += "reproduce the bug. The "
3362-
errMsg += "developers will try to reproduce the bug, fix it accordingly "
3355+
errMsg += "reproduce the bug. Developers will try to reproduce the bug, fix it accordingly "
33633356
errMsg += "and get back to you\n"
33643357
errMsg += "Running version: %s\n" % VERSION_STRING[VERSION_STRING.find('/') + 1:]
33653358
errMsg += "Python version: %s\n" % PYVERSION
@@ -3495,7 +3488,7 @@ def maskSensitiveData(msg):
34953488
retVal = retVal.replace(match.group(3), '*' * len(match.group(3)))
34963489

34973490
# Fail-safe substitution
3498-
retVal = re.sub(r"(?i)\bhttps?://[^ ]+", lambda match: '*' * len(match.group(0)), retVal)
3491+
retVal = re.sub(r"(?i)(Command line:.+)\b(https?://[^ ]+)", lambda match: "%s%s" % (match.group(1), '*' * len(match.group(2))), retVal)
34993492

35003493
if getpass.getuser():
35013494
retVal = re.sub(r"(?i)\b%s\b" % re.escape(getpass.getuser()), '*' * len(getpass.getuser()), retVal)

lib/core/dump.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ def singleString(self, data, content_type=None):
112112
self._write(data, content_type=content_type)
113113

114114
def string(self, header, data, content_type=None, sort=True):
115-
kb.stickyLevel = None
116-
117115
if conf.api:
118116
self._write(data, content_type=content_type)
119117
return

lib/core/option.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,6 @@ def _setKnowledgeBaseAttributes(flushAll=True):
18811881
kb.reduceTests = None
18821882
kb.tlsSNI = {}
18831883
kb.stickyDBMS = False
1884-
kb.stickyLevel = None
18851884
kb.storeCrawlingChoice = None
18861885
kb.storeHashesChoice = None
18871886
kb.suppressResumeInfo = False

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.3.1.81"
22+
VERSION = "1.3.1.82"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/techniques/blind/inference.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,6 @@ def blindThread():
645645
abortedFlag = True
646646
finally:
647647
kb.prependFlag = False
648-
kb.stickyLevel = None
649648
retrievedLength = len(finalValue or "")
650649

651650
if finalValue is not None:

sqlmap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from lib.core.data import kb
5454
from lib.core.common import unhandledExceptionMessage
5555
from lib.core.common import MKSTEMP_PREFIX
56+
from lib.core.common import setColor
5657
from lib.core.exception import SqlmapBaseException
5758
from lib.core.exception import SqlmapShellQuitException
5859
from lib.core.exception import SqlmapSilentQuitException
@@ -339,8 +340,7 @@ def main():
339340
logger.critical("%s\n%s" % (errMsg, excMsg))
340341
else:
341342
logger.critical(errMsg)
342-
kb.stickyLevel = logging.CRITICAL
343-
dataToStdout(excMsg)
343+
dataToStdout("%s\n" % setColor(excMsg.strip(), level=logging.CRITICAL))
344344
createGithubIssue(errMsg, excMsg)
345345

346346
finally:

txt/checksum.md5

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@ c1da277517c7ec4c23e953a51b51e203 lib/controller/handler.py
3030
fb6be55d21a70765e35549af2484f762 lib/controller/__init__.py
3131
ed7874be0d2d3802f3d20184f2b280d5 lib/core/agent.py
3232
a932126e7d80e545c5d44af178d0bc0c lib/core/bigarray.py
33-
f97e6dc62b453cc787ef7f801ee1af5b lib/core/common.py
33+
76825cafb1916b85a8738493de8607c6 lib/core/common.py
3434
de8d27ae6241163ff9e97aa9e7c51a18 lib/core/convert.py
3535
abcb1121eb56d3401839d14e8ed06b6e lib/core/data.py
3636
e1f7758f433202c50426efde5eb96768 lib/core/datatype.py
3737
1646402a733e564f05025e848b323cf9 lib/core/decorators.py
3838
5f4680b769ae07f22157bd832c97cf8f lib/core/defaults.py
3939
9dfc69ba47209a4ceca494dde9ee8183 lib/core/dicts.py
40-
4782353a3072e4d17c4e314daf918d8a lib/core/dump.py
40+
13ca1a870fa0b01b9593f25e9e93ed9c lib/core/dump.py
4141
5c91145204092b995ed1ac641e9e291d lib/core/enums.py
4242
84ef8f32e4582fcc294dc14e1997131d lib/core/exception.py
4343
fb6be55d21a70765e35549af2484f762 lib/core/__init__.py
4444
18c896b157b03af716542e5fe9233ef9 lib/core/log.py
4545
fa9f24e88c81a6cef52da3dd5e637010 lib/core/optiondict.py
46-
b56df9d9426027f3450432c2b6428485 lib/core/option.py
46+
b39587efbf4aef1283c0bbf1e723a8ab lib/core/option.py
4747
fe370021c6bc99daf44b2bfc0d1effb3 lib/core/patch.py
4848
4b12aa67fbf6c973d12e54cf9cb54ea0 lib/core/profiling.py
4949
5e2c16a8e2daee22dd545df13386e7a3 lib/core/readlineng.py
5050
7d8a22c582ad201f65b73225e4456170 lib/core/replication.py
5151
3179d34f371e0295dd4604568fb30bcd lib/core/revision.py
5252
d6269c55789f78cf707e09a0f5b45443 lib/core/session.py
53-
e9e5e6207591b134c0cf4ecf8e712ea9 lib/core/settings.py
53+
8a8ee76f9b901b16929cf875807a7690 lib/core/settings.py
5454
4483b4a5b601d8f1c4281071dff21ecc lib/core/shell.py
5555
10fd19b0716ed261e6d04f311f6f527c lib/core/subprocessng.py
5656
9c7b5c6397fb3da33e7a4d7876d159c6 lib/core/target.py
@@ -91,7 +91,7 @@ d55029a4c048e345fbb07a8f91604d83 lib/takeover/metasploit.py
9191
ad038ac567f97a4b940b7987792d64a4 lib/takeover/udf.py
9292
915a3fbd557fb136bd0e16c46d993be3 lib/takeover/web.py
9393
1aadcdc058bb813d09ad23d26ea2a6b5 lib/takeover/xp_cmdshell.py
94-
034490840639b5ca2bc97af4cb14f449 lib/techniques/blind/inference.py
94+
96f120e4299baaea4defd902afc85979 lib/techniques/blind/inference.py
9595
fb6be55d21a70765e35549af2484f762 lib/techniques/blind/__init__.py
9696
fb6be55d21a70765e35549af2484f762 lib/techniques/dns/__init__.py
9797
ea48db4c48276d7d0e71aa467c0c523f lib/techniques/dns/test.py
@@ -236,7 +236,7 @@ ec2ba8c757ac96425dcd2b97970edd3a shell/stagers/stager.asp_
236236
0c48ddb1feb7e38a951ef05a0d48e032 shell/stagers/stager.jsp_
237237
2f9e459a4cf6a58680978cdce5ff7971 shell/stagers/stager.php_
238238
41522f8ad02ac133ca0aeaab374c36a8 sqlmapapi.py
239-
3926fb4ba81b03abede53d507ab89aab sqlmap.py
239+
76998d373c6aef8d36d617a9b21d6eaf sqlmap.py
240240
772fb3dd15edc9d4055ab9f9dee0c203 tamper/0x2char.py
241241
3d89a5c4c33d4d1d9303f5e3bd11f0ae tamper/apostrophemask.py
242242
1fd0eec63970728c1e6628b2e4c21d81 tamper/apostrophenullencode.py

0 commit comments

Comments
 (0)