Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54be398

Browse files
committed
Patch for an Issue #711
1 parent 27ebc02 commit 54be398

3 files changed

Lines changed: 17 additions & 16 deletions

File tree

lib/core/common.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,9 +1045,6 @@ def setPaths():
10451045
paths.SQLMAP_XML_BANNER_PATH = os.path.join(paths.SQLMAP_XML_PATH, "banner")
10461046
paths.SQLMAP_OUTPUT_PATH = paths.get("SQLMAP_OUTPUT_PATH", os.path.join(paths.SQLMAP_ROOT_PATH, "output"))
10471047

1048-
if not os.access(paths.SQLMAP_OUTPUT_PATH, os.W_OK):
1049-
paths.SQLMAP_OUTPUT_PATH = os.path.join(os.path.expanduser("~"), ".sqlmap", "output")
1050-
10511048
paths.SQLMAP_DUMP_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "dump")
10521049
paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files")
10531050

lib/core/target.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import urlparse
1515

1616
from lib.core.common import Backend
17+
from lib.core.common import getUnicode
1718
from lib.core.common import hashDBRetrieve
1819
from lib.core.common import intersect
1920
from lib.core.common import paramToDict
@@ -513,15 +514,22 @@ def _createTargetDirs():
513514
try:
514515
os.makedirs(paths.SQLMAP_OUTPUT_PATH, 0755)
515516
except OSError, ex:
516-
tempDir = tempfile.mkdtemp(prefix="sqlmapoutput")
517-
warnMsg = "unable to create default root output directory "
518-
warnMsg += "'%s' (%s). " % (paths.SQLMAP_OUTPUT_PATH, ex)
519-
warnMsg += "Using temporary directory '%s' instead" % tempDir
520-
logger.warn(warnMsg)
521-
522-
paths.SQLMAP_OUTPUT_PATH = tempDir
523-
524-
conf.outputPath = os.path.join(paths.SQLMAP_OUTPUT_PATH, conf.hostname)
517+
paths.SQLMAP_OUTPUT_PATH = os.path.join(os.path.expanduser("~"), ".sqlmap", "output")
518+
try:
519+
if not os.path.isdir(paths.SQLMAP_OUTPUT_PATH):
520+
os.makedirs(paths.SQLMAP_OUTPUT_PATH, 0755)
521+
warnMsg = "using '%s' as the output directory" % paths.SQLMAP_OUTPUT_PATH
522+
logger.warn(warnMsg)
523+
except OSError, ex:
524+
tempDir = tempfile.mkdtemp(prefix="sqlmapoutput")
525+
warnMsg = "unable to create regular output directory "
526+
warnMsg += "'%s' (%s). " % (paths.SQLMAP_OUTPUT_PATH, ex)
527+
warnMsg += "Using temporary directory '%s' instead" % tempDir
528+
logger.warn(warnMsg)
529+
530+
paths.SQLMAP_OUTPUT_PATH = tempDir
531+
532+
conf.outputPath = os.path.join(paths.SQLMAP_OUTPUT_PATH, getUnicode(conf.hostname))
525533

526534
if not os.path.isdir(conf.outputPath):
527535
try:

sqlmap.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ def main():
8383
dataToStdout("[!] legal disclaimer: %s\n\n" % LEGAL_DISCLAIMER, forceOutput=True)
8484
dataToStdout("[*] starting at %s\n\n" % time.strftime("%X"), forceOutput=True)
8585

86-
if ".sqlmap" in paths.SQLMAP_OUTPUT_PATH:
87-
warnMsg = "using '%s' as the output directory" % paths.SQLMAP_OUTPUT_PATH
88-
logger.warn(warnMsg)
89-
9086
init()
9187

9288
if conf.profile:

0 commit comments

Comments
 (0)