Create the output directory.
()
| 652 | conf.dumper.setOutputFile() |
| 653 | |
| 654 | def _createTargetDirs(): |
| 655 | """ |
| 656 | Create the output directory. |
| 657 | """ |
| 658 | |
| 659 | conf.outputPath = os.path.join(getUnicode(paths.SQLMAP_OUTPUT_PATH), normalizeUnicode(getUnicode(conf.hostname))) |
| 660 | |
| 661 | try: |
| 662 | if not os.path.isdir(conf.outputPath): |
| 663 | os.makedirs(conf.outputPath) |
| 664 | except (OSError, IOError, TypeError) as ex: |
| 665 | tempDir = tempfile.mkdtemp(prefix="sqlmapoutput") |
| 666 | warnMsg = "unable to create output directory " |
| 667 | warnMsg += "'%s' (%s). " % (conf.outputPath, getUnicode(ex)) |
| 668 | warnMsg += "Using temporary directory '%s' instead" % getUnicode(tempDir) |
| 669 | logger.warning(warnMsg) |
| 670 | |
| 671 | conf.outputPath = tempDir |
| 672 | |
| 673 | conf.outputPath = getUnicode(conf.outputPath) |
| 674 | |
| 675 | try: |
| 676 | with openFile(os.path.join(conf.outputPath, "target.txt"), "w+") as f: |
| 677 | f.write(getUnicode(kb.originalUrls.get(conf.url) or conf.url or conf.hostname)) |
| 678 | f.write(" (%s)" % (HTTPMETHOD.POST if conf.data else HTTPMETHOD.GET)) |
| 679 | f.write(" # %s" % getUnicode(subprocess.list2cmdline(sys.argv), encoding=sys.stdin.encoding)) |
| 680 | if conf.data: |
| 681 | f.write("\n\n%s" % getUnicode(conf.data)) |
| 682 | except IOError as ex: |
| 683 | if "denied" in getUnicode(ex): |
| 684 | errMsg = "you don't have enough permissions " |
| 685 | else: |
| 686 | errMsg = "something went wrong while trying " |
| 687 | errMsg += "to write to the output directory '%s' (%s)" % (paths.SQLMAP_OUTPUT_PATH, getSafeExString(ex)) |
| 688 | |
| 689 | raise SqlmapMissingPrivileges(errMsg) |
| 690 | except UnicodeError as ex: |
| 691 | warnMsg = "something went wrong while saving target data ('%s')" % getSafeExString(ex) |
| 692 | logger.warning(warnMsg) |
| 693 | |
| 694 | _createDumpDir() |
| 695 | _createFilesDir() |
| 696 | _configureDumper() |
| 697 | |
| 698 | def _setAuxOptions(): |
| 699 | """ |
no test coverage detected
searching dependent graphs…