mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-29 04:53:48 +03:00
split init() into two separate functions for API purposes (issue #297)
This commit is contained in:
parent
085495024f
commit
eeecb3fe2c
|
@ -30,12 +30,14 @@ from lib.core.common import unhandledExceptionMessage
|
||||||
from lib.core.exception import SqlmapBaseException
|
from lib.core.exception import SqlmapBaseException
|
||||||
from lib.core.exception import SqlmapSilentQuitException
|
from lib.core.exception import SqlmapSilentQuitException
|
||||||
from lib.core.exception import SqlmapUserQuitException
|
from lib.core.exception import SqlmapUserQuitException
|
||||||
|
from lib.core.option import initOptions
|
||||||
from lib.core.option import init
|
from lib.core.option import init
|
||||||
from lib.core.profiling import profile
|
from lib.core.profiling import profile
|
||||||
from lib.core.settings import LEGAL_DISCLAIMER
|
from lib.core.settings import LEGAL_DISCLAIMER
|
||||||
from lib.core.testing import smokeTest
|
from lib.core.testing import smokeTest
|
||||||
from lib.core.testing import liveTest
|
from lib.core.testing import liveTest
|
||||||
from lib.parse.cmdline import cmdLineParser
|
from lib.parse.cmdline import cmdLineParser
|
||||||
|
from lib.utils.api import setRestAPILog
|
||||||
from lib.utils.api import StdDbOut
|
from lib.utils.api import StdDbOut
|
||||||
|
|
||||||
def modulePath():
|
def modulePath():
|
||||||
|
@ -57,19 +59,22 @@ def main():
|
||||||
|
|
||||||
# Store original command line options for possible later restoration
|
# Store original command line options for possible later restoration
|
||||||
cmdLineOptions.update(cmdLineParser().__dict__)
|
cmdLineOptions.update(cmdLineParser().__dict__)
|
||||||
init(cmdLineOptions)
|
initOptions(cmdLineOptions)
|
||||||
|
|
||||||
if hasattr(conf, "api"):
|
if hasattr(conf, "api"):
|
||||||
# Overwrite system standard output and standard error to write
|
# Overwrite system standard output and standard error to write
|
||||||
# to an IPC database
|
# to an IPC database
|
||||||
sys.stdout = StdDbOut(conf.taskid, messagetype="stdout")
|
sys.stdout = StdDbOut(conf.taskid, messagetype="stdout")
|
||||||
sys.stderr = StdDbOut(conf.taskid, messagetype="stderr")
|
sys.stderr = StdDbOut(conf.taskid, messagetype="stderr")
|
||||||
|
setRestAPILog()
|
||||||
|
|
||||||
banner()
|
banner()
|
||||||
|
|
||||||
dataToStdout("[!] legal disclaimer: %s\n\n" % LEGAL_DISCLAIMER, forceOutput=True)
|
dataToStdout("[!] legal disclaimer: %s\n\n" % LEGAL_DISCLAIMER, forceOutput=True)
|
||||||
dataToStdout("[*] starting at %s\n\n" % time.strftime("%X"), forceOutput=True)
|
dataToStdout("[*] starting at %s\n\n" % time.strftime("%X"), forceOutput=True)
|
||||||
|
|
||||||
|
init()
|
||||||
|
|
||||||
if conf.profile:
|
if conf.profile:
|
||||||
profile()
|
profile()
|
||||||
elif conf.smokeTest:
|
elif conf.smokeTest:
|
||||||
|
|
|
@ -136,7 +136,6 @@ from lib.request.httpshandler import HTTPSHandler
|
||||||
from lib.request.rangehandler import HTTPRangeHandler
|
from lib.request.rangehandler import HTTPRangeHandler
|
||||||
from lib.request.redirecthandler import SmartRedirectHandler
|
from lib.request.redirecthandler import SmartRedirectHandler
|
||||||
from lib.request.templates import getPageTemplate
|
from lib.request.templates import getPageTemplate
|
||||||
from lib.utils.api import setRestAPILog
|
|
||||||
from lib.utils.crawler import crawl
|
from lib.utils.crawler import crawl
|
||||||
from lib.utils.deps import checkDependencies
|
from lib.utils.deps import checkDependencies
|
||||||
from lib.utils.google import Google
|
from lib.utils.google import Google
|
||||||
|
@ -2052,21 +2051,22 @@ def _resolveCrossReferences():
|
||||||
lib.core.common.getPageTemplate = getPageTemplate
|
lib.core.common.getPageTemplate = getPageTemplate
|
||||||
lib.core.convert.singleTimeWarnMessage = singleTimeWarnMessage
|
lib.core.convert.singleTimeWarnMessage = singleTimeWarnMessage
|
||||||
|
|
||||||
def init(inputOptions=AttribDict(), overrideOptions=False):
|
def initOptions(inputOptions=AttribDict(), overrideOptions=False):
|
||||||
"""
|
|
||||||
Set attributes into both configuration and knowledge base singletons
|
|
||||||
based upon command line and configuration file options.
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not inputOptions.disableColoring:
|
if not inputOptions.disableColoring:
|
||||||
coloramainit()
|
coloramainit()
|
||||||
|
|
||||||
_setConfAttributes()
|
_setConfAttributes()
|
||||||
_setKnowledgeBaseAttributes()
|
_setKnowledgeBaseAttributes()
|
||||||
_mergeOptions(inputOptions, overrideOptions)
|
_mergeOptions(inputOptions, overrideOptions)
|
||||||
|
|
||||||
|
def init():
|
||||||
|
"""
|
||||||
|
Set attributes into both configuration and knowledge base singletons
|
||||||
|
based upon command line and configuration file options.
|
||||||
|
"""
|
||||||
|
|
||||||
_useWizardInterface()
|
_useWizardInterface()
|
||||||
setVerbosity()
|
setVerbosity()
|
||||||
setRestAPILog()
|
|
||||||
_saveCmdline()
|
_saveCmdline()
|
||||||
_setRequestFromFile()
|
_setRequestFromFile()
|
||||||
_cleanupOptions()
|
_cleanupOptions()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user