Adding --report-json option

This commit is contained in:
Miroslav Štampar 2026-06-15 15:35:33 +02:00
parent 948d01d57a
commit 17e94c3409
13 changed files with 581 additions and 69 deletions

View file

@ -176,6 +176,10 @@ def main():
init()
if conf.get("reportJson"):
from lib.utils.api import setupReportCollector
conf.reportCollector = setupReportCollector()
if not conf.updateAll:
# Postponed imports (faster start)
if conf.smokeTest:
@ -568,6 +572,21 @@ def main():
warnMsg = "your sqlmap version is outdated"
logger.warning(warnMsg)
# emit the JSON report BEFORE the closing banner, so it does not appear awkwardly after
# "[*] ending @ ..."
if conf.get("reportCollector") is not None:
try:
from lib.utils.api import writeReportJson
writeReportJson(conf.reportCollector, conf.reportJson)
logger.info("JSON report written to '%s'" % conf.reportJson)
except Exception as ex:
logger.error("unable to write JSON report to '%s' ('%s')" % (conf.reportJson, getSafeExString(ex)))
finally:
try:
conf.reportCollector.disconnect()
except Exception as ex:
logger.debug("problem occurred while closing the report collector ('%s')" % getSafeExString(ex))
if conf.get("showTime"):
dataToStdout("\n[*] ending @ %s\n\n" % time.strftime("%X /%Y-%m-%d/"), forceOutput=True)