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

Skip to content

Commit c5a2567

Browse files
committed
Minor DREI patch (leaky multiprocessing)
1 parent f8f57e1 commit c5a2567

5 files changed

Lines changed: 22 additions & 2 deletions

File tree

lib/core/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4650,6 +4650,7 @@ def decloakToTemp(filename):
46504650
>>> _ = decloakToTemp(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.asp_"))
46514651
>>> openFile(_, "rb", encoding=None).read().startswith(b'<%')
46524652
True
4653+
>>> os.remove(_)
46534654
"""
46544655

46554656
content = decloak(filename)

lib/core/option.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,9 @@ def _createHomeDirectories():
15191519

15201520
paths["SQLMAP_%s_PATH" % context.upper()] = tempDir
15211521

1522+
def _pympTempLeakPatch(tempDir): # Cross-referenced function
1523+
raise NotImplementedError
1524+
15221525
def _createTemporaryDirectory():
15231526
"""
15241527
Creates temporary directory for this run.
@@ -1570,6 +1573,9 @@ def _createTemporaryDirectory():
15701573
errMsg += "temporary directory location ('%s')" % getSafeExString(ex)
15711574
raise SqlmapSystemException(errMsg)
15721575

1576+
if six.PY3:
1577+
_pympTempLeakPatch(kb.tempDir)
1578+
15731579
def _cleanupOptions():
15741580
"""
15751581
Cleanup configuration attributes.

lib/core/patch.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import lib.core.common
1212
import lib.core.threads
1313
import lib.core.convert
14+
import lib.core.option
1415
import lib.request.connect
1516
import lib.utils.search
1617
import thirdparty.ansistrm.ansistrm
@@ -61,8 +62,20 @@ def resolveCrossReferences():
6162
lib.core.convert.filterNone = filterNone
6263
lib.core.convert.isListLike = isListLike
6364
lib.core.convert.singleTimeWarnMessage = singleTimeWarnMessage
65+
lib.core.option._pympTempLeakPatch = pympTempLeakPatch
6466
lib.request.connect.setHTTPHandlers = _setHTTPHandlers
6567
lib.utils.search.setHTTPHandlers = _setHTTPHandlers
6668
lib.controller.checks.setVerbosity = setVerbosity
6769
lib.controller.checks.setWafFunctions = _setWafFunctions
6870
thirdparty.ansistrm.ansistrm.stdoutencode = stdoutencode
71+
72+
def pympTempLeakPatch(tempDir):
73+
"""
74+
Patch for "pymp" leaking directories inside Python3
75+
"""
76+
77+
try:
78+
import multiprocessing.util
79+
multiprocessing.util.get_temp_dir = lambda: tempDir
80+
except:
81+
pass

lib/core/settings.py

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

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.5.29"
21+
VERSION = "1.3.5.30"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def main():
378378
except OSError:
379379
pass
380380

381-
if not filterNone(filepath for filepath in glob.glob(os.path.join(kb.tempDir, '*')) if not any(filepath.endswith(_) for _ in ('.lock', '.exe', '_'))):
381+
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
382382
try:
383383
shutil.rmtree(kb.tempDir, ignore_errors=True)
384384
except OSError:

0 commit comments

Comments
 (0)