Skip to content

Commit e0ec2fc

Browse files
committed
Implements option --time-limit (#5502)
1 parent c629374 commit e0ec2fc

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

lib/core/convert.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import json
1717
import re
1818
import sys
19+
import time
1920

2021
from lib.core.bigarray import BigArray
2122
from lib.core.compat import xrange
@@ -334,6 +335,10 @@ def getUnicode(value, encoding=None, noneToNull=False):
334335
True
335336
"""
336337

338+
# Best position for --time-limit mechanism
339+
if conf.get("timeLimit") and kb.get("startTime") and (time.time() - kb.startTime > conf.timeLimit):
340+
raise SystemExit
341+
337342
if noneToNull and value is None:
338343
return NULL
339344

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,6 +2171,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
21712171
kb.smokeMode = False
21722172
kb.reduceTests = None
21732173
kb.sslSuccess = False
2174+
kb.startTime = time.time()
21742175
kb.stickyDBMS = False
21752176
kb.suppressResumeInfo = False
21762177
kb.tableFrom = None

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
"skipWaf": "boolean",
240240
"testFilter": "string",
241241
"testSkip": "string",
242+
"timeLimit": "float",
242243
"webRoot": "string",
243244
},
244245

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.9.2"
23+
VERSION = "1.7.9.3"
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
@@ -736,6 +736,9 @@ def cmdLineParser(argv=None):
736736
general.add_argument("--test-skip", dest="testSkip",
737737
help="Skip tests by payloads and/or titles (e.g. BENCHMARK)")
738738

739+
general.add_argument("--time-limit", dest="timeLimit", type=float,
740+
help="Run with a time limit in seconds (e.g. 3600)")
741+
739742
general.add_argument("--web-root", dest="webRoot",
740743
help="Web server document root directory (e.g. \"/var/www\")")
741744

sqlmap.conf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,12 +820,15 @@ skipWaf = False
820820
# Default: sqlmap
821821
tablePrefix = sqlmap
822822

823-
# Select tests by payloads and/or titles (e.g. ROW)
823+
# Select tests by payloads and/or titles (e.g. ROW).
824824
testFilter =
825825

826-
# Skip tests by payloads and/or titles (e.g. BENCHMARK)
826+
# Skip tests by payloads and/or titles (e.g. BENCHMARK).
827827
testSkip =
828828

829+
# Run with a time limit in seconds (e.g. 3600).
830+
timeLimit =
831+
829832
# Web server document root directory (e.g. "/var/www").
830833
webRoot =
831834

0 commit comments

Comments
 (0)