Better exception messages (including types)

This commit is contained in:
Miroslav Stampar 2019-02-12 10:42:32 +01:00
parent 27265f56ba
commit ba883b77df
4 changed files with 14 additions and 6 deletions

View File

@ -84,6 +84,7 @@ from lib.core.enums import PLACE
from lib.core.enums import PAYLOAD
from lib.core.enums import REFLECTIVE_COUNTER
from lib.core.enums import SORT_ORDER
from lib.core.exception import SqlmapBaseException
from lib.core.exception import SqlmapDataException
from lib.core.exception import SqlmapGenericException
from lib.core.exception import SqlmapNoneDataException
@ -4784,6 +4785,8 @@ def getSafeExString(ex, encoding=None):
u'foobar'
"""
retVal = None
if getattr(ex, "message", None):
retVal = ex.message
elif getattr(ex, "msg", None):
@ -4792,8 +4795,11 @@ def getSafeExString(ex, encoding=None):
retVal = ex[1]
elif isinstance(ex, (list, tuple)) and len(ex) > 0 and isinstance(ex[0], basestring):
retVal = ex[0]
else:
if retVal is None:
retVal = str(ex)
elif not isinstance(ex, SqlmapBaseException):
retVal = "%s: %s" % (type(ex).__name__, retVal)
return getUnicode(retVal or "", encoding=encoding).strip()

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.2.18"
VERSION = "1.3.2.19"
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

@ -18,6 +18,7 @@ from lib.core.data import kb
from lib.core.data import logger
from lib.core.datatype import AttribDict
from lib.core.enums import PAYLOAD
from lib.core.exception import SqlmapBaseException
from lib.core.exception import SqlmapConnectionException
from lib.core.exception import SqlmapThreadException
from lib.core.exception import SqlmapUserQuitException
@ -95,7 +96,8 @@ def exceptionHandledFunction(threadFunction, silent=False):
raise
except Exception as ex:
if not silent and kb.get("threadContinue"):
logger.error("thread %s: %s" % (threading.currentThread().getName(), ex.message))
errMsg = ex.message if isinstance(ex, SqlmapBaseException) else "%s: %s" % (type(ex).__name__, ex.message)
logger.error("thread %s: '%s'" % (threading.currentThread().getName(), errMsg))
if conf.get("verbose") > 1:
traceback.print_exc()

View File

@ -30,7 +30,7 @@ c1da277517c7ec4c23e953a51b51e203 lib/controller/handler.py
fb6be55d21a70765e35549af2484f762 lib/controller/__init__.py
ed7874be0d2d3802f3d20184f2b280d5 lib/core/agent.py
a932126e7d80e545c5d44af178d0bc0c lib/core/bigarray.py
964885db1ac028fa622ee5ba20f061b1 lib/core/common.py
0d12ca1436b330d986221388d054730b lib/core/common.py
de8d27ae6241163ff9e97aa9e7c51a18 lib/core/convert.py
abcb1121eb56d3401839d14e8ed06b6e lib/core/data.py
00828c4455321b6987e3f882f4ef4f92 lib/core/datatype.py
@ -50,12 +50,12 @@ d5ef43fe3cdd6c2602d7db45651f9ceb lib/core/readlineng.py
7d8a22c582ad201f65b73225e4456170 lib/core/replication.py
3179d34f371e0295dd4604568fb30bcd lib/core/revision.py
d6269c55789f78cf707e09a0f5b45443 lib/core/session.py
23e7cd640ca9345ced37e2c30194859d lib/core/settings.py
587adf8926007e3e73492e136bc74da4 lib/core/settings.py
4483b4a5b601d8f1c4281071dff21ecc lib/core/shell.py
10fd19b0716ed261e6d04f311f6f527c lib/core/subprocessng.py
43772ea73e9e3d446f782af591cb4eda lib/core/target.py
7857b24b7865ccb4a05283faa596974d lib/core/testing.py
e9788d2992f842cf91ab67389bf4372a lib/core/threads.py
5c369aefa7c5af85dee9212acdf94bbc lib/core/threads.py
2c263c8610667fdc593c50a35ab20f57 lib/core/unescaper.py
54e9cd1968adea11283d44631f0ca400 lib/core/update.py
5b3f08208be0579356f78ce5805d37b2 lib/core/wordlist.py