Create results file for storing results of running in a multiple target mode.
()
| 569 | Backend.setOs(conf.os) |
| 570 | |
| 571 | def _setResultsFile(): |
| 572 | """ |
| 573 | Create results file for storing results of running in a |
| 574 | multiple target mode. |
| 575 | """ |
| 576 | |
| 577 | if not conf.multipleTargets: |
| 578 | return |
| 579 | |
| 580 | if not conf.resultsFP: |
| 581 | conf.resultsFile = conf.resultsFile or os.path.join(paths.SQLMAP_OUTPUT_PATH, time.strftime(RESULTS_FILE_FORMAT).lower()) |
| 582 | found = os.path.exists(conf.resultsFile) |
| 583 | |
| 584 | try: |
| 585 | conf.resultsFP = openFile(conf.resultsFile, "a", UNICODE_ENCODING, buffering=0) |
| 586 | except (OSError, IOError) as ex: |
| 587 | try: |
| 588 | warnMsg = "unable to create results file '%s' ('%s'). " % (conf.resultsFile, getUnicode(ex)) |
| 589 | handle, conf.resultsFile = tempfile.mkstemp(prefix=MKSTEMP_PREFIX.RESULTS, suffix=".csv") |
| 590 | os.close(handle) |
| 591 | conf.resultsFP = openFile(conf.resultsFile, "w+", UNICODE_ENCODING, buffering=0) |
| 592 | warnMsg += "Using temporary file '%s' instead" % conf.resultsFile |
| 593 | logger.warning(warnMsg) |
| 594 | except IOError as _: |
| 595 | errMsg = "unable to write to the temporary directory ('%s'). " % _ |
| 596 | errMsg += "Please make sure that your disk is not full and " |
| 597 | errMsg += "that you have sufficient write permissions to " |
| 598 | errMsg += "create temporary files and/or directories" |
| 599 | raise SqlmapSystemException(errMsg) |
| 600 | |
| 601 | if not found: |
| 602 | conf.resultsFP.writelines("Target URL,Place,Parameter,Technique(s),Note(s)%s" % os.linesep) |
| 603 | |
| 604 | logger.info("using '%s' as the CSV results file in multiple targets mode" % conf.resultsFile) |
| 605 | |
| 606 | def _createFilesDir(): |
| 607 | """ |
no test coverage detected
searching dependent graphs…