File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717
1818from lib .core .exception import SqlmapSystemException
1919from lib .core .settings import BIGARRAY_CHUNK_SIZE
20- from lib .core .settings import BIGARRAY_TEMP_PREFIX
2120
2221DEFAULT_SIZE_OF = sys .getsizeof (object ())
2322
@@ -92,7 +91,7 @@ def index(self, value):
9291
9392 def _dump (self , chunk ):
9493 try :
95- handle , filename = tempfile .mkstemp (prefix = BIGARRAY_TEMP_PREFIX )
94+ handle , filename = tempfile .mkstemp ()
9695 self .filenames .add (filename )
9796 os .close (handle )
9897 with open (filename , "w+b" ) as fp :
Original file line number Diff line number Diff line change 1515import socket
1616import string
1717import sys
18+ import tempfile
1819import threading
1920import time
2021import urllib2
@@ -1437,6 +1438,17 @@ def _checkDependencies():
14371438 if conf .dependencies :
14381439 checkDependencies ()
14391440
1441+ def _createTemporaryDirectory ():
1442+ """
1443+ Creates temporary directory for this run.
1444+ """
1445+
1446+ if not os .path .isdir (tempfile .gettempdir ()):
1447+ os .makedirs (tempfile .gettempdir ())
1448+ tempfile .tempdir = tempfile .mkdtemp (prefix = "sqlmap" , suffix = str (os .getpid ()))
1449+ if not os .path .isdir (tempfile .tempdir ):
1450+ os .makedirs (tempfile .tempdir )
1451+
14401452def _cleanupOptions ():
14411453 """
14421454 Cleanup configuration attributes.
@@ -2332,6 +2344,7 @@ def init():
23322344 _cleanupOptions ()
23332345 _purgeOutput ()
23342346 _checkDependencies ()
2347+ _createTemporaryDirectory ()
23352348 _basicOptionValidation ()
23362349 _setProxyList ()
23372350 _setTorProxySettings ()
Original file line number Diff line number Diff line change 446446# Approximate chunk length (in bytes) used by BigArray objects (only last chunk and cached one are held in memory)
447447BIGARRAY_CHUNK_SIZE = 1024 * 1024
448448
449- # Prefix used for storing dumped chunks in BigArray objects
450- BIGARRAY_TEMP_PREFIX = "sqlmapba-%d-" % os .getpid ()
451-
452449# Only console display last n table rows
453450TRIM_STDOUT_DUMP_SIZE = 256
454451
Original file line number Diff line number Diff line change 66"""
77
88import bdb
9- import glob
109import inspect
1110import logging
1211import os
1312import re
13+ import shutil
1414import sys
1515import tempfile
1616import time
4444from lib .core .option import initOptions
4545from lib .core .option import init
4646from lib .core .profiling import profile
47- from lib .core .settings import BIGARRAY_TEMP_PREFIX
4847from lib .core .settings import LEGAL_DISCLAIMER
4948from lib .core .testing import smokeTest
5049from lib .core .testing import liveTest
@@ -154,11 +153,7 @@ def main():
154153 if conf .get ("showTime" ):
155154 dataToStdout ("\n [*] shutting down at %s\n \n " % time .strftime ("%X" ), forceOutput = True )
156155
157- for filename in glob .glob ("%s*" % os .path .join (tempfile .gettempdir (), BIGARRAY_TEMP_PREFIX )):
158- try :
159- os .remove (filename )
160- except :
161- pass
156+ shutil .rmtree (tempfile .tempdir , ignore_errors = True )
162157
163158 kb .threadContinue = False
164159 kb .threadException = True
You can’t perform that action at this time.
0 commit comments