Patch for an Issue #1105

This commit is contained in:
Miroslav Stampar 2015-01-13 10:33:51 +01:00
parent 8e03f4db0f
commit 06ff8b3a16
4 changed files with 16 additions and 12 deletions

View File

@ -17,7 +17,6 @@ import tempfile
from lib.core.exception import SqlmapSystemException
from lib.core.settings import BIGARRAY_CHUNK_SIZE
from lib.core.settings import BIGARRAY_TEMP_PREFIX
DEFAULT_SIZE_OF = sys.getsizeof(object())
@ -92,7 +91,7 @@ class BigArray(list):
def _dump(self, chunk):
try:
handle, filename = tempfile.mkstemp(prefix=BIGARRAY_TEMP_PREFIX)
handle, filename = tempfile.mkstemp()
self.filenames.add(filename)
os.close(handle)
with open(filename, "w+b") as fp:

View File

@ -15,6 +15,7 @@ import re
import socket
import string
import sys
import tempfile
import threading
import time
import urllib2
@ -1437,6 +1438,17 @@ def _checkDependencies():
if conf.dependencies:
checkDependencies()
def _createTemporaryDirectory():
"""
Creates temporary directory for this run.
"""
if not os.path.isdir(tempfile.gettempdir()):
os.makedirs(tempfile.gettempdir())
tempfile.tempdir = tempfile.mkdtemp(prefix="sqlmap", suffix=str(os.getpid()))
if not os.path.isdir(tempfile.tempdir):
os.makedirs(tempfile.tempdir)
def _cleanupOptions():
"""
Cleanup configuration attributes.
@ -2332,6 +2344,7 @@ def init():
_cleanupOptions()
_purgeOutput()
_checkDependencies()
_createTemporaryDirectory()
_basicOptionValidation()
_setProxyList()
_setTorProxySettings()

View File

@ -446,9 +446,6 @@ ROTATING_CHARS = ('\\', '|', '|', '/', '-')
# Approximate chunk length (in bytes) used by BigArray objects (only last chunk and cached one are held in memory)
BIGARRAY_CHUNK_SIZE = 1024 * 1024
# Prefix used for storing dumped chunks in BigArray objects
BIGARRAY_TEMP_PREFIX = "sqlmapba-%d-" % os.getpid()
# Only console display last n table rows
TRIM_STDOUT_DUMP_SIZE = 256

View File

@ -6,11 +6,11 @@ See the file 'doc/COPYING' for copying permission
"""
import bdb
import glob
import inspect
import logging
import os
import re
import shutil
import sys
import tempfile
import time
@ -44,7 +44,6 @@ from lib.core.exception import SqlmapUserQuitException
from lib.core.option import initOptions
from lib.core.option import init
from lib.core.profiling import profile
from lib.core.settings import BIGARRAY_TEMP_PREFIX
from lib.core.settings import LEGAL_DISCLAIMER
from lib.core.testing import smokeTest
from lib.core.testing import liveTest
@ -154,11 +153,7 @@ def main():
if conf.get("showTime"):
dataToStdout("\n[*] shutting down at %s\n\n" % time.strftime("%X"), forceOutput=True)
for filename in glob.glob("%s*" % os.path.join(tempfile.gettempdir(), BIGARRAY_TEMP_PREFIX)):
try:
os.remove(filename)
except:
pass
shutil.rmtree(tempfile.tempdir, ignore_errors=True)
kb.threadContinue = False
kb.threadException = True