Patch for an Issue #711

This commit is contained in:
Miroslav Stampar 2014-06-04 16:35:07 +02:00
parent 27ebc02535
commit 54be398e83
3 changed files with 15 additions and 14 deletions

View File

@ -1045,9 +1045,6 @@ def setPaths():
paths.SQLMAP_XML_BANNER_PATH = os.path.join(paths.SQLMAP_XML_PATH, "banner") paths.SQLMAP_XML_BANNER_PATH = os.path.join(paths.SQLMAP_XML_PATH, "banner")
paths.SQLMAP_OUTPUT_PATH = paths.get("SQLMAP_OUTPUT_PATH", os.path.join(paths.SQLMAP_ROOT_PATH, "output")) paths.SQLMAP_OUTPUT_PATH = paths.get("SQLMAP_OUTPUT_PATH", os.path.join(paths.SQLMAP_ROOT_PATH, "output"))
if not os.access(paths.SQLMAP_OUTPUT_PATH, os.W_OK):
paths.SQLMAP_OUTPUT_PATH = os.path.join(os.path.expanduser("~"), ".sqlmap", "output")
paths.SQLMAP_DUMP_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "dump") paths.SQLMAP_DUMP_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "dump")
paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files") paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files")

View File

@ -14,6 +14,7 @@ import time
import urlparse import urlparse
from lib.core.common import Backend from lib.core.common import Backend
from lib.core.common import getUnicode
from lib.core.common import hashDBRetrieve from lib.core.common import hashDBRetrieve
from lib.core.common import intersect from lib.core.common import intersect
from lib.core.common import paramToDict from lib.core.common import paramToDict
@ -513,15 +514,22 @@ def _createTargetDirs():
try: try:
os.makedirs(paths.SQLMAP_OUTPUT_PATH, 0755) os.makedirs(paths.SQLMAP_OUTPUT_PATH, 0755)
except OSError, ex: except OSError, ex:
tempDir = tempfile.mkdtemp(prefix="sqlmapoutput") paths.SQLMAP_OUTPUT_PATH = os.path.join(os.path.expanduser("~"), ".sqlmap", "output")
warnMsg = "unable to create default root output directory " try:
warnMsg += "'%s' (%s). " % (paths.SQLMAP_OUTPUT_PATH, ex) if not os.path.isdir(paths.SQLMAP_OUTPUT_PATH):
warnMsg += "Using temporary directory '%s' instead" % tempDir os.makedirs(paths.SQLMAP_OUTPUT_PATH, 0755)
logger.warn(warnMsg) warnMsg = "using '%s' as the output directory" % paths.SQLMAP_OUTPUT_PATH
logger.warn(warnMsg)
except OSError, ex:
tempDir = tempfile.mkdtemp(prefix="sqlmapoutput")
warnMsg = "unable to create regular output directory "
warnMsg += "'%s' (%s). " % (paths.SQLMAP_OUTPUT_PATH, ex)
warnMsg += "Using temporary directory '%s' instead" % tempDir
logger.warn(warnMsg)
paths.SQLMAP_OUTPUT_PATH = tempDir paths.SQLMAP_OUTPUT_PATH = tempDir
conf.outputPath = os.path.join(paths.SQLMAP_OUTPUT_PATH, conf.hostname) conf.outputPath = os.path.join(paths.SQLMAP_OUTPUT_PATH, getUnicode(conf.hostname))
if not os.path.isdir(conf.outputPath): if not os.path.isdir(conf.outputPath):
try: try:

View File

@ -83,10 +83,6 @@ def main():
dataToStdout("[!] legal disclaimer: %s\n\n" % LEGAL_DISCLAIMER, forceOutput=True) dataToStdout("[!] legal disclaimer: %s\n\n" % LEGAL_DISCLAIMER, forceOutput=True)
dataToStdout("[*] starting at %s\n\n" % time.strftime("%X"), forceOutput=True) dataToStdout("[*] starting at %s\n\n" % time.strftime("%X"), forceOutput=True)
if ".sqlmap" in paths.SQLMAP_OUTPUT_PATH:
warnMsg = "using '%s' as the output directory" % paths.SQLMAP_OUTPUT_PATH
logger.warn(warnMsg)
init() init()
if conf.profile: if conf.profile: