Skip to content

Commit de10cff

Browse files
committed
Fixes leakage of sqlmap temporary directories
1 parent da65936 commit de10cff

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

data/txt/sha256sums.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ c9d1f64648062d7962caf02c4e2e7d84e8feb2a14451146f627112aae889afcd lib/core/dump.
180180
4608f21a4333c162ab3c266c903fda4793cc5834de30d06affe9b7566dd09811 lib/core/__init__.py
181181
3d308440fb01d04b5d363bfbe0f337756b098532e5bb7a1c91d5213157ec2c35 lib/core/log.py
182182
2a06dc9b5c17a1efdcdb903545729809399f1ee96f7352cc19b9aaa227394ff3 lib/core/optiondict.py
183-
97378f241005dc1b8b4c0a67b9b39af76a9735d2bb0a49e8f2ef59c0d115d93e lib/core/option.py
183+
3ca1a6759c196aa104130af0ed47826cd01009beaa3fa836a25faabfec7dd18e lib/core/option.py
184184
866e93c93541498ecce70125037bdd376d78188e481d225f81843f21f4797d8c lib/core/patch.py
185185
85f10c6195a3a675892d914328173a6fb6a8393120417a2f10071c6e77bfa47d lib/core/profiling.py
186186
c4bfb493a03caf84dd362aec7c248097841de804b7413d0e1ecb8a90c8550bc0 lib/core/readlineng.py
187187
d1bd70c1a55858495c727fbec91e30af267459c8f64d50fabf9e4ee2c007e920 lib/core/replication.py
188188
1d0f80b0193ac5204527bfab4bde1a7aee0f693fd008e86b4b29f606d1ef94f3 lib/core/revision.py
189189
d2eb8e4b05ac93551272b3d4abfaf5b9f2d3ac92499a7704c16ed0b4f200db38 lib/core/session.py
190-
a4f0bd3aec711d65a6a18dfb1b966c5890a93f3c1a47187831c0831fb0e89034 lib/core/settings.py
190+
9e356b74c0f4db3788619d4c4090290b4175cccc58650ef5667813ae11b1d71b lib/core/settings.py
191191
1c5eab9494eb969bc9ce118a2ea6954690c6851cbe54c18373c723b99734bf09 lib/core/shell.py
192192
4eea6dcf023e41e3c64b210cb5c2efc7ca893b727f5e49d9c924f076bb224053 lib/core/subprocessng.py
193193
cdd352e1331c6b535e780f6edea79465cb55af53aa2114dcea0e8bf382e56d1a lib/core/target.py
@@ -476,7 +476,7 @@ baaf7a29a1fe07e7cecc7fb1b1f6a6f327b12154b8d5619e9808b2cf43ad2198 README.md
476476
535ab6ac8b8441a3758cee86df3e68abec8b43eee54e32777967252057915acc sqlmapapi.py
477477
168309215af7dd5b0b71070e1770e72f1cbb29a3d8025143fb8aa0b88cd56b62 sqlmapapi.yaml
478478
c43cc0dd5b4026083ad420c04705a031504aa503cc99ab2236010c4cbd472d39 sqlmap.conf
479-
e29538ddcb7bb80fc3b07b3ccc23e46df1faf9ff4b6d7db0558a9a9587a6b8c6 sqlmap.py
479+
cf35266a47f5acfd5f0c7dfc4443bf46480cdc2e1ae9cfc2014602e798e91d24 sqlmap.py
480480
82caac95182ac5cae02eb7d8a2dc07e71389aeae6b838d3d3f402c9597eb086a tamper/0eunion.py
481481
bc8f5e638578919e4e75a5b01a84b47456bac0fd540e600975a52408a3433460 tamper/apostrophemask.py
482482
c9c3d71f11de0140906d7b4f24fadb9926dc8eaf5adab864f8106275f05526ce tamper/apostrophenullencode.py

lib/core/option.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,8 @@ def _createTemporaryDirectory():
16571657
errMsg += "temporary directory location ('%s')" % getSafeExString(ex)
16581658
raise SqlmapSystemException(errMsg)
16591659

1660+
conf.tempDirs.append(tempfile.tempdir)
1661+
16601662
if six.PY3:
16611663
_pympTempLeakPatch(kb.tempDir)
16621664

@@ -1982,6 +1984,8 @@ def _setConfAttributes():
19821984
conf.dbmsHandler = None
19831985
conf.dnsServer = None
19841986
conf.dumpPath = None
1987+
conf.fileWriteType = None
1988+
conf.HARCollectorFactory = None
19851989
conf.hashDB = None
19861990
conf.hashDBFile = None
19871991
conf.httpCollector = None
@@ -1998,9 +2002,8 @@ def _setConfAttributes():
19982002
conf.resultsFP = None
19992003
conf.scheme = None
20002004
conf.tests = []
2005+
conf.tempDirs = []
20012006
conf.trafficFP = None
2002-
conf.HARCollectorFactory = None
2003-
conf.fileWriteType = None
20042007

20052008
def _setKnowledgeBaseAttributes(flushAll=True):
20062009
"""

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from thirdparty import six
2020

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

sqlmap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,17 +567,17 @@ def main():
567567

568568
kb.threadException = True
569569

570-
if kb.get("tempDir"):
570+
for tempDir in conf.get("tempDirs", []):
571571
for prefix in (MKSTEMP_PREFIX.IPC, MKSTEMP_PREFIX.TESTING, MKSTEMP_PREFIX.COOKIE_JAR, MKSTEMP_PREFIX.BIG_ARRAY):
572-
for filepath in glob.glob(os.path.join(kb.tempDir, "%s*" % prefix)):
572+
for filepath in glob.glob(os.path.join(tempDir, "%s*" % prefix)):
573573
try:
574574
os.remove(filepath)
575575
except OSError:
576576
pass
577577

578-
if not filterNone(filepath for filepath in glob.glob(os.path.join(kb.tempDir, '*')) if not any(filepath.endswith(_) for _ in (".lock", ".exe", ".so", '_'))): # ignore junk files
578+
if any((conf.vulnTest, conf.smokeTest)) or not filterNone(filepath for filepath in glob.glob(os.path.join(tempDir, '*')) if not any(filepath.endswith(_) for _ in (".lock", ".exe", ".so", '_'))): # ignore junk files
579579
try:
580-
shutil.rmtree(kb.tempDir, ignore_errors=True)
580+
shutil.rmtree(tempDir, ignore_errors=True)
581581
except OSError:
582582
pass
583583

0 commit comments

Comments
 (0)