File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import codecs
1111import os
1212import re
13+ import tempfile
1314import time
1415
1516from lib .core .common import dataToSessionFile
@@ -231,13 +232,29 @@ def __createTargetDirs():
231232 Create the output directory.
232233 """
233234
234- conf .outputPath = "%s%s%s" % (paths .SQLMAP_OUTPUT_PATH , os .sep , conf .hostname )
235-
236235 if not os .path .isdir (paths .SQLMAP_OUTPUT_PATH ):
237- os .makedirs (paths .SQLMAP_OUTPUT_PATH , 0755 )
236+ try :
237+ os .makedirs (paths .SQLMAP_OUTPUT_PATH , 0755 )
238+ except :
239+ tempDir = tempfile .mkdtemp (prefix = 'output' )
240+ warnMsg = "unable to create default root output directory at "
241+ warnMsg += "'%s'. using temporary directory '%s' instead" % (paths .SQLMAP_OUTPUT_PATH , tempDir )
242+ logger .warn (warnMsg )
243+
244+ paths .SQLMAP_OUTPUT_PATH = tempDir
245+
246+ conf .outputPath = "%s%s%s" % (paths .SQLMAP_OUTPUT_PATH , os .sep , conf .hostname )
238247
239248 if not os .path .isdir (conf .outputPath ):
240- os .makedirs (conf .outputPath , 0755 )
249+ try :
250+ os .makedirs (conf .outputPath , 0755 )
251+ except :
252+ tempDir = tempfile .mkdtemp (prefix = 'output' )
253+ warnMsg = "unable to create output directory '%s'. " % conf .outputPath
254+ warnMsg += "using temporary directory '%s' instead" % tempDir
255+ logger .warn (warnMsg )
256+
257+ conf .outputPath = tempDir
241258
242259 __createDumpDir ()
243260 __createFilesDir ()
You can’t perform that action at this time.
0 commit comments