|
14 | 14 | import urlparse |
15 | 15 |
|
16 | 16 | from lib.core.common import Backend |
| 17 | +from lib.core.common import getUnicode |
17 | 18 | from lib.core.common import hashDBRetrieve |
18 | 19 | from lib.core.common import intersect |
19 | 20 | from lib.core.common import paramToDict |
@@ -513,15 +514,22 @@ def _createTargetDirs(): |
513 | 514 | try: |
514 | 515 | os.makedirs(paths.SQLMAP_OUTPUT_PATH, 0755) |
515 | 516 | 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)) |
525 | 533 |
|
526 | 534 | if not os.path.isdir(conf.outputPath): |
527 | 535 | try: |
|
0 commit comments