mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-06 12:41:30 +00:00
first test of stdout/stderr redirect to a database when sqlmap is executed from restful API (#297)
This commit is contained in:
24
_sqlmap.py
24
_sqlmap.py
@@ -36,6 +36,7 @@ from lib.core.settings import LEGAL_DISCLAIMER
|
||||
from lib.core.testing import smokeTest
|
||||
from lib.core.testing import liveTest
|
||||
from lib.parse.cmdline import cmdLineParser
|
||||
from lib.utils.api import StdDbOut
|
||||
|
||||
def modulePath():
|
||||
"""
|
||||
@@ -53,16 +54,22 @@ def main():
|
||||
try:
|
||||
paths.SQLMAP_ROOT_PATH = modulePath()
|
||||
setPaths()
|
||||
|
||||
# Store original command line options for possible later restoration
|
||||
cmdLineOptions.update(cmdLineParser().__dict__)
|
||||
init(cmdLineOptions)
|
||||
|
||||
if hasattr(conf, "ipc_database"):
|
||||
# Overwrite system standard output and standard error to write
|
||||
# to a temporary I/O database
|
||||
sys.stdout = StdDbOut(type_="stdout")
|
||||
sys.stderr = StdDbOut(type_="stderr")
|
||||
|
||||
banner()
|
||||
|
||||
dataToStdout("[!] legal disclaimer: %s\n\n" % LEGAL_DISCLAIMER, forceOutput=True)
|
||||
dataToStdout("[*] starting at %s\n\n" % time.strftime("%X"), forceOutput=True)
|
||||
|
||||
# Store original command line options for possible later restoration
|
||||
cmdLineOptions.update(cmdLineParser().__dict__)
|
||||
|
||||
init(cmdLineOptions)
|
||||
|
||||
if conf.profile:
|
||||
profile()
|
||||
elif conf.smokeTest:
|
||||
@@ -115,6 +122,13 @@ def main():
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
if hasattr(conf, "ipc_database"):
|
||||
try:
|
||||
conf.ipc_database_cursor.close()
|
||||
conf.ipc_database_connection.close()
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
# Reference: http://stackoverflow.com/questions/1635080/terminate-a-multi-thread-python-program
|
||||
if conf.get("threads", 0) > 1 or conf.get("dnsServer"):
|
||||
os._exit(0)
|
||||
|
||||
Reference in New Issue
Block a user