Minor DREI patch (leaky multiprocessing)

This commit is contained in:
Miroslav Stampar 2019-05-06 15:39:11 +02:00
parent f8f57e1030
commit c5a2567033
5 changed files with 22 additions and 2 deletions

View File

@ -4650,6 +4650,7 @@ def decloakToTemp(filename):
>>> _ = decloakToTemp(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.asp_")) >>> _ = decloakToTemp(os.path.join(paths.SQLMAP_SHELL_PATH, "stagers", "stager.asp_"))
>>> openFile(_, "rb", encoding=None).read().startswith(b'<%') >>> openFile(_, "rb", encoding=None).read().startswith(b'<%')
True True
>>> os.remove(_)
""" """
content = decloak(filename) content = decloak(filename)

View File

@ -1519,6 +1519,9 @@ def _createHomeDirectories():
paths["SQLMAP_%s_PATH" % context.upper()] = tempDir paths["SQLMAP_%s_PATH" % context.upper()] = tempDir
def _pympTempLeakPatch(tempDir): # Cross-referenced function
raise NotImplementedError
def _createTemporaryDirectory(): def _createTemporaryDirectory():
""" """
Creates temporary directory for this run. Creates temporary directory for this run.
@ -1570,6 +1573,9 @@ def _createTemporaryDirectory():
errMsg += "temporary directory location ('%s')" % getSafeExString(ex) errMsg += "temporary directory location ('%s')" % getSafeExString(ex)
raise SqlmapSystemException(errMsg) raise SqlmapSystemException(errMsg)
if six.PY3:
_pympTempLeakPatch(kb.tempDir)
def _cleanupOptions(): def _cleanupOptions():
""" """
Cleanup configuration attributes. Cleanup configuration attributes.

View File

@ -11,6 +11,7 @@ import lib.controller.checks
import lib.core.common import lib.core.common
import lib.core.threads import lib.core.threads
import lib.core.convert import lib.core.convert
import lib.core.option
import lib.request.connect import lib.request.connect
import lib.utils.search import lib.utils.search
import thirdparty.ansistrm.ansistrm import thirdparty.ansistrm.ansistrm
@ -61,8 +62,20 @@ def resolveCrossReferences():
lib.core.convert.filterNone = filterNone lib.core.convert.filterNone = filterNone
lib.core.convert.isListLike = isListLike lib.core.convert.isListLike = isListLike
lib.core.convert.singleTimeWarnMessage = singleTimeWarnMessage lib.core.convert.singleTimeWarnMessage = singleTimeWarnMessage
lib.core.option._pympTempLeakPatch = pympTempLeakPatch
lib.request.connect.setHTTPHandlers = _setHTTPHandlers lib.request.connect.setHTTPHandlers = _setHTTPHandlers
lib.utils.search.setHTTPHandlers = _setHTTPHandlers lib.utils.search.setHTTPHandlers = _setHTTPHandlers
lib.controller.checks.setVerbosity = setVerbosity lib.controller.checks.setVerbosity = setVerbosity
lib.controller.checks.setWafFunctions = _setWafFunctions lib.controller.checks.setWafFunctions = _setWafFunctions
thirdparty.ansistrm.ansistrm.stdoutencode = stdoutencode thirdparty.ansistrm.ansistrm.stdoutencode = stdoutencode
def pympTempLeakPatch(tempDir):
"""
Patch for "pymp" leaking directories inside Python3
"""
try:
import multiprocessing.util
multiprocessing.util.get_temp_dir = lambda: tempDir
except:
pass

View File

@ -18,7 +18,7 @@ from lib.core.enums import OS
from thirdparty import six from thirdparty import six
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.3.5.29" VERSION = "1.3.5.30"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} 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) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

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