Skip to content

Commit 6336389

Browse files
committed
Another update for #5295
1 parent a7b5924 commit 6336389

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

lib/core/option.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,11 +1696,20 @@ def _cleanupOptions():
16961696
try:
16971697
conf.ignoreCode = [int(_) for _ in re.split(PARAMETER_SPLITTING_REGEX, conf.ignoreCode)]
16981698
except ValueError:
1699-
errMsg = "options '--ignore-code' should contain a list of integer values or a wildcard value '%s'" % IGNORE_CODE_WILDCARD
1699+
errMsg = "option '--ignore-code' should contain a list of integer values or a wildcard value '%s'" % IGNORE_CODE_WILDCARD
17001700
raise SqlmapSyntaxException(errMsg)
17011701
else:
17021702
conf.ignoreCode = []
17031703

1704+
if conf.abortCode:
1705+
try:
1706+
conf.abortCode = [int(_) for _ in re.split(PARAMETER_SPLITTING_REGEX, conf.abortCode)]
1707+
except ValueError:
1708+
errMsg = "option '--abort-code' should contain a list of integer values"
1709+
raise SqlmapSyntaxException(errMsg)
1710+
else:
1711+
conf.abortCode = []
1712+
17041713
if conf.paramFilter:
17051714
conf.paramFilter = [_.strip() for _ in re.split(PARAMETER_SPLITTING_REGEX, conf.paramFilter.upper())]
17061715
else:

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"authType": "string",
4040
"authCred": "string",
4141
"authFile": "string",
42+
"abortCode": "string",
4243
"ignoreCode": "string",
4344
"ignoreProxy": "boolean",
4445
"ignoreRedirects": "boolean",

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty.six import unichr as _unichr
2121

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

lib/parse/cmdline.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,11 @@ def cmdLineParser(argv=None):
201201
request.add_argument("--auth-file", dest="authFile",
202202
help="HTTP authentication PEM cert/private key file")
203203

204+
request.add_argument("--abort-code", dest="abortCode",
205+
help="Abort on (problematic) HTTP error code(s) (e.g. 401)")
206+
204207
request.add_argument("--ignore-code", dest="ignoreCode",
205-
help="Ignore (problematic) HTTP error code (e.g. 401)")
208+
help="Ignore (problematic) HTTP error code(s) (e.g. 401)")
206209

207210
request.add_argument("--ignore-proxy", dest="ignoreProxy", action="store_true",
208211
help="Ignore system default proxy settings")

lib/request/connect.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,11 @@ class _(dict):
767767
if not multipart:
768768
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
769769

770+
if code in conf.abortCode:
771+
errMsg = "aborting due to detected HTTP code '%d'" % code
772+
singleTimeLogMessage(errMsg, logging.CRITICAL)
773+
raise SystemExit
774+
770775
if ex.code not in (conf.ignoreCode or []):
771776
if ex.code == _http_client.UNAUTHORIZED:
772777
errMsg = "not authorized, try to provide right HTTP "
@@ -921,6 +926,11 @@ class _(dict):
921926
errMsg += "function '%s' ('%s')" % (function.__name__, getSafeExString(ex))
922927
raise SqlmapGenericException(errMsg)
923928

929+
if code in conf.abortCode:
930+
errMsg = "aborting due to detected HTTP code '%d'" % code
931+
singleTimeLogMessage(errMsg, logging.CRITICAL)
932+
raise SystemExit
933+
924934
threadData.lastPage = page
925935
threadData.lastCode = code
926936

sqlmap.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ authCred =
101101
# Syntax: key_file
102102
authFile =
103103

104+
# Abort on (problematic) HTTP error code (e.g. 401).
105+
# Valid: string
106+
abortCode =
107+
104108
# Ignore (problematic) HTTP error code (e.g. 401).
105-
# Valid: integer
109+
# Valid: string
106110
ignoreCode =
107111

108112
# Ignore system default proxy settings.

0 commit comments

Comments
 (0)