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

Skip to content

Commit ba883b7

Browse files
committed
Better exception messages (including types)
1 parent 27265f5 commit ba883b7

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

lib/core/common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
from lib.core.enums import PAYLOAD
8585
from lib.core.enums import REFLECTIVE_COUNTER
8686
from lib.core.enums import SORT_ORDER
87+
from lib.core.exception import SqlmapBaseException
8788
from lib.core.exception import SqlmapDataException
8889
from lib.core.exception import SqlmapGenericException
8990
from lib.core.exception import SqlmapNoneDataException
@@ -4784,6 +4785,8 @@ def getSafeExString(ex, encoding=None):
47844785
u'foobar'
47854786
"""
47864787

4788+
retVal = None
4789+
47874790
if getattr(ex, "message", None):
47884791
retVal = ex.message
47894792
elif getattr(ex, "msg", None):
@@ -4792,8 +4795,11 @@ def getSafeExString(ex, encoding=None):
47924795
retVal = ex[1]
47934796
elif isinstance(ex, (list, tuple)) and len(ex) > 0 and isinstance(ex[0], basestring):
47944797
retVal = ex[0]
4795-
else:
4798+
4799+
if retVal is None:
47964800
retVal = str(ex)
4801+
elif not isinstance(ex, SqlmapBaseException):
4802+
retVal = "%s: %s" % (type(ex).__name__, retVal)
47974803

47984804
return getUnicode(retVal or "", encoding=encoding).strip()
47994805

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.2.18"
22+
VERSION = "1.3.2.19"
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/core/threads.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from lib.core.data import logger
1919
from lib.core.datatype import AttribDict
2020
from lib.core.enums import PAYLOAD
21+
from lib.core.exception import SqlmapBaseException
2122
from lib.core.exception import SqlmapConnectionException
2223
from lib.core.exception import SqlmapThreadException
2324
from lib.core.exception import SqlmapUserQuitException
@@ -95,7 +96,8 @@ def exceptionHandledFunction(threadFunction, silent=False):
9596
raise
9697
except Exception as ex:
9798
if not silent and kb.get("threadContinue"):
98-
logger.error("thread %s: %s" % (threading.currentThread().getName(), ex.message))
99+
errMsg = ex.message if isinstance(ex, SqlmapBaseException) else "%s: %s" % (type(ex).__name__, ex.message)
100+
logger.error("thread %s: '%s'" % (threading.currentThread().getName(), errMsg))
99101

100102
if conf.get("verbose") > 1:
101103
traceback.print_exc()

txt/checksum.md5

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ c1da277517c7ec4c23e953a51b51e203 lib/controller/handler.py
3030
fb6be55d21a70765e35549af2484f762 lib/controller/__init__.py
3131
ed7874be0d2d3802f3d20184f2b280d5 lib/core/agent.py
3232
a932126e7d80e545c5d44af178d0bc0c lib/core/bigarray.py
33-
964885db1ac028fa622ee5ba20f061b1 lib/core/common.py
33+
0d12ca1436b330d986221388d054730b lib/core/common.py
3434
de8d27ae6241163ff9e97aa9e7c51a18 lib/core/convert.py
3535
abcb1121eb56d3401839d14e8ed06b6e lib/core/data.py
3636
00828c4455321b6987e3f882f4ef4f92 lib/core/datatype.py
@@ -50,12 +50,12 @@ d5ef43fe3cdd6c2602d7db45651f9ceb lib/core/readlineng.py
5050
7d8a22c582ad201f65b73225e4456170 lib/core/replication.py
5151
3179d34f371e0295dd4604568fb30bcd lib/core/revision.py
5252
d6269c55789f78cf707e09a0f5b45443 lib/core/session.py
53-
23e7cd640ca9345ced37e2c30194859d lib/core/settings.py
53+
587adf8926007e3e73492e136bc74da4 lib/core/settings.py
5454
4483b4a5b601d8f1c4281071dff21ecc lib/core/shell.py
5555
10fd19b0716ed261e6d04f311f6f527c lib/core/subprocessng.py
5656
43772ea73e9e3d446f782af591cb4eda lib/core/target.py
5757
7857b24b7865ccb4a05283faa596974d lib/core/testing.py
58-
e9788d2992f842cf91ab67389bf4372a lib/core/threads.py
58+
5c369aefa7c5af85dee9212acdf94bbc lib/core/threads.py
5959
2c263c8610667fdc593c50a35ab20f57 lib/core/unescaper.py
6060
54e9cd1968adea11283d44631f0ca400 lib/core/update.py
6161
5b3f08208be0579356f78ce5805d37b2 lib/core/wordlist.py

0 commit comments

Comments
 (0)