MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / _createTargetDirs

Function _createTargetDirs

lib/core/target.py:654–696  ·  view source on GitHub ↗

Create the output directory.

()

Source from the content-addressed store, hash-verified

652 conf.dumper.setOutputFile()
653
654def _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
698def _setAuxOptions():
699 """

Callers 1

setupTargetEnvFunction · 0.85

Calls 10

getUnicodeFunction · 0.90
normalizeUnicodeFunction · 0.90
openFileFunction · 0.90
getSafeExStringFunction · 0.90
_createDumpDirFunction · 0.85
_createFilesDirFunction · 0.85
_configureDumperFunction · 0.85
writeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…