Skip to content

Commit 9e17bab

Browse files
committed
Implements option --retry-on (#4876)
1 parent fc9875f commit 9e17bab

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

lib/core/option.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,6 +2648,13 @@ def _basicOptionValidation():
26482648
errMsg = "invalid regular expression '%s' ('%s')" % (conf.paramExclude, getSafeExString(ex))
26492649
raise SqlmapSyntaxException(errMsg)
26502650

2651+
if conf.retryOn:
2652+
try:
2653+
re.compile(conf.retryOn)
2654+
except Exception as ex:
2655+
errMsg = "invalid regular expression '%s' ('%s')" % (conf.retryOn, getSafeExString(ex))
2656+
raise SqlmapSyntaxException(errMsg)
2657+
26512658
if conf.cookieDel and len(conf.cookieDel):
26522659
errMsg = "option '--cookie-del' should contain a single character (e.g. ';')"
26532660
raise SqlmapSyntaxException(errMsg)

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"delay": "float",
5555
"timeout": "float",
5656
"retries": "integer",
57+
"retryOn": "string",
5758
"rParam": "string",
5859
"safeUrl": "string",
5960
"safePost": "string",

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.5.10.21"
23+
VERSION = "1.5.11.0"
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ def cmdLineParser(argv=None):
246246
request.add_argument("--retries", dest="retries", type=int,
247247
help="Retries when the connection timeouts (default %d)" % defaults.retries)
248248

249+
request.add_argument("--retry-on", dest="retryOn",
250+
help="Retry request on regexp matching content (e.g. \"drop\")")
251+
249252
request.add_argument("--randomize", dest="rParam",
250253
help="Randomly change value for given parameter(s)")
251254

lib/request/connect.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,17 @@ class _(dict):
909909

910910
socket.setdefaulttimeout(conf.timeout)
911911

912+
if conf.retryOn and re.search(conf.retryOn, page, re.I):
913+
if threadData.retriesCount < conf.retries:
914+
warnMsg = "forced retry of the request because of undesired page content"
915+
logger.warn(warnMsg)
916+
return Connect._retryProxy(**kwargs)
917+
else:
918+
errMsg = "unable to get the page content not matching "
919+
errMsg += "the given regular expression '%s'. Please use as high " % conf.retryOn
920+
errMsg += "value for option '--retries' as possible (e.g. 20 or more)"
921+
raise SqlmapConnectionException(errMsg)
922+
912923
processResponse(page, responseHeaders, code, status)
913924

914925
if not skipLogTraffic:

sqlmap.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ timeout = 30
160160
# Default: 3
161161
retries = 3
162162

163+
# Retry request on regexp matching content.
164+
retries = 3
165+
163166
# Randomly change value for the given parameter.
164167
rParam =
165168

0 commit comments

Comments
 (0)