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

Skip to content

Commit 680aeda

Browse files
committed
Adding option --tmp-dir
1 parent afdca09 commit 680aeda

5 files changed

Lines changed: 49 additions & 24 deletions

File tree

lib/core/option.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,18 +1548,36 @@ def _createTemporaryDirectory():
15481548
Creates temporary directory for this run.
15491549
"""
15501550

1551-
try:
1552-
if not os.path.isdir(tempfile.gettempdir()):
1553-
os.makedirs(tempfile.gettempdir())
1554-
except IOError, ex:
1555-
errMsg = "there has been a problem while accessing "
1556-
errMsg += "system's temporary directory location(s) ('%s'). Please " % getSafeExString(ex)
1557-
errMsg += "make sure that there is enough disk space left. If problem persists, "
1558-
errMsg += "try to set environment variable 'TEMP' to a location "
1559-
errMsg += "writeable by the current user"
1560-
raise SqlmapSystemException, errMsg
1561-
1562-
if "sqlmap" not in (tempfile.tempdir or ""):
1551+
if conf.tmpDir:
1552+
try:
1553+
if not os.path.isdir(conf.tmpDir):
1554+
os.makedirs(conf.tmpDir)
1555+
1556+
_ = os.path.join(conf.tmpDir, randomStr())
1557+
open(_, "w+b").close()
1558+
os.remove(_)
1559+
1560+
tempfile.tempdir = conf.tmpDir
1561+
1562+
warnMsg = "using '%s' as the temporary directory" % conf.tmpDir
1563+
logger.warn(warnMsg)
1564+
except (OSError, IOError), ex:
1565+
errMsg = "there has been a problem while accessing "
1566+
errMsg += "temporary directory location(s) ('%s')" % getSafeExString(ex)
1567+
raise SqlmapSystemException, errMsg
1568+
else:
1569+
try:
1570+
if not os.path.isdir(tempfile.gettempdir()):
1571+
os.makedirs(tempfile.gettempdir())
1572+
except IOError, ex:
1573+
errMsg = "there has been a problem while accessing "
1574+
errMsg += "system's temporary directory location(s) ('%s'). Please " % getSafeExString(ex)
1575+
errMsg += "make sure that there is enough disk space left. If problem persists, "
1576+
errMsg += "try to set environment variable 'TEMP' to a location "
1577+
errMsg += "writeable by the current user"
1578+
raise SqlmapSystemException, errMsg
1579+
1580+
if "sqlmap" not in (tempfile.tempdir or "") or conf.tmpDir and tempfile.tempdir == conf.tmpDir:
15631581
tempfile.tempdir = tempfile.mkdtemp(prefix="sqlmap", suffix=str(os.getpid()))
15641582

15651583
kb.tempDir = tempfile.tempdir

lib/core/optiondict.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,14 @@
218218
"dependencies": "boolean",
219219
"disableColoring": "boolean",
220220
"googlePage": "integer",
221+
"identifyWaf": "boolean",
221222
"mobile": "boolean",
222223
"offline": "boolean",
223224
"pageRank": "boolean",
224225
"purgeOutput": "boolean",
226+
"skipWaf": "boolean",
225227
"smart": "boolean",
228+
"tmpDir": "string",
226229
"wizard": "boolean",
227230
"verbose": "integer",
228231
},
@@ -231,8 +234,6 @@
231234
"disablePrecon": "boolean",
232235
"profile": "boolean",
233236
"forceDns": "boolean",
234-
"identifyWaf": "boolean",
235-
"skipWaf": "boolean",
236237
"ignore401": "boolean",
237238
"smokeTest": "boolean",
238239
"liveTest": "boolean",

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.revision import getRevisionNumber
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.0.5.128"
22+
VERSION = "1.0.5.129"
2323
REVISION = getRevisionNumber()
2424
STABLE = VERSION.count('.') <= 2
2525
VERSION_STRING = "sqlmap/%s#%s" % (VERSION, "stable" if STABLE else "dev")

lib/parse/cmdline.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,6 @@ def cmdLineParser(argv=None):
719719
action="store_true",
720720
help="Make a thorough testing for a WAF/IPS/IDS protection")
721721

722-
miscellaneous.add_option("--skip-waf", dest="skipWaf",
723-
action="store_true",
724-
help="Skip heuristic detection of WAF/IPS/IDS protection")
725-
726722
miscellaneous.add_option("--mobile", dest="mobile",
727723
action="store_true",
728724
help="Imitate smartphone through HTTP User-Agent header")
@@ -739,12 +735,19 @@ def cmdLineParser(argv=None):
739735
action="store_true",
740736
help="Safely remove all content from output directory")
741737

738+
miscellaneous.add_option("--skip-waf", dest="skipWaf",
739+
action="store_true",
740+
help="Skip heuristic detection of WAF/IPS/IDS protection")
741+
742742
miscellaneous.add_option("--smart", dest="smart",
743743
action="store_true",
744744
help="Conduct thorough tests only if positive heuristic(s)")
745745

746746
miscellaneous.add_option("--sqlmap-shell", dest="sqlmapShell", action="store_true",
747-
help="Prompt for an interactive sqlmap shell")
747+
help="Prompt for an interactive sqlmap shell")
748+
749+
miscellaneous.add_option("--tmp-dir", dest="tmpDir",
750+
help="Local directory for storing temporary files")
748751

749752
miscellaneous.add_option("--wizard", dest="wizard",
750753
action="store_true",

sqlmap.conf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,10 +756,6 @@ googlePage = 1
756756
# Valid: True or False
757757
identifyWaf = False
758758

759-
# Skip heuristic detection of WAF/IPS/IDS protection.
760-
# Valid: True or False
761-
skipWaf = False
762-
763759
# Imitate smartphone through HTTP User-Agent header.
764760
# Valid: True or False
765761
mobile = False
@@ -772,10 +768,17 @@ offline = False
772768
# Valid: True or False
773769
pageRank = False
774770

771+
# Skip heuristic detection of WAF/IPS/IDS protection.
772+
# Valid: True or False
773+
skipWaf = False
774+
775775
# Conduct thorough tests only if positive heuristic(s).
776776
# Valid: True or False
777777
smart = False
778778

779+
# Local directory for storing temporary files.
780+
tmpDir =
781+
779782
# Simple wizard interface for beginner users.
780783
# Valid: True or False
781784
wizard = False

0 commit comments

Comments
 (0)