Skip to content

Commit

Permalink
Implements option --time-limit (#5502)
Browse files Browse the repository at this point in the history
  • Loading branch information
stamparm committed Sep 28, 2023
1 parent c629374 commit e0ec2fc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/core/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import json
import re
import sys
import time

from lib.core.bigarray import BigArray
from lib.core.compat import xrange
Expand Down Expand Up @@ -334,6 +335,10 @@ def getUnicode(value, encoding=None, noneToNull=False):
True
"""

# Best position for --time-limit mechanism
if conf.get("timeLimit") and kb.get("startTime") and (time.time() - kb.startTime > conf.timeLimit):
raise SystemExit

if noneToNull and value is None:
return NULL

Expand Down
1 change: 1 addition & 0 deletions lib/core/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -2171,6 +2171,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
kb.smokeMode = False
kb.reduceTests = None
kb.sslSuccess = False
kb.startTime = time.time()
kb.stickyDBMS = False
kb.suppressResumeInfo = False
kb.tableFrom = None
Expand Down
1 change: 1 addition & 0 deletions lib/core/optiondict.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"skipWaf": "boolean",
"testFilter": "string",
"testSkip": "string",
"timeLimit": "float",
"webRoot": "string",
},

Expand Down
2 changes: 1 addition & 1 deletion lib/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from thirdparty.six import unichr as _unichr

# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.7.9.2"
VERSION = "1.7.9.3"
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)
Expand Down
3 changes: 3 additions & 0 deletions lib/parse/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,9 @@ def cmdLineParser(argv=None):
general.add_argument("--test-skip", dest="testSkip",
help="Skip tests by payloads and/or titles (e.g. BENCHMARK)")

general.add_argument("--time-limit", dest="timeLimit", type=float,
help="Run with a time limit in seconds (e.g. 3600)")

general.add_argument("--web-root", dest="webRoot",
help="Web server document root directory (e.g. \"/var/www\")")

Expand Down
7 changes: 5 additions & 2 deletions sqlmap.conf
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,15 @@ skipWaf = False
# Default: sqlmap
tablePrefix = sqlmap

# Select tests by payloads and/or titles (e.g. ROW)
# Select tests by payloads and/or titles (e.g. ROW).
testFilter =

# Skip tests by payloads and/or titles (e.g. BENCHMARK)
# Skip tests by payloads and/or titles (e.g. BENCHMARK).
testSkip =

# Run with a time limit in seconds (e.g. 3600).
timeLimit =

# Web server document root directory (e.g. "/var/www").
webRoot =

Expand Down

0 comments on commit e0ec2fc

Please sign in to comment.