From eeecb3fe2c8ebe1be7bfb7c92bd50336a9db82c2 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Tue, 29 Jan 2013 15:33:16 +0000 Subject: [PATCH] split init() into two separate functions for API purposes (issue #297) --- _sqlmap.py | 7 ++++++- lib/core/option.py | 16 ++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/_sqlmap.py b/_sqlmap.py index 9de694a2b..e77f7b4e1 100644 --- a/_sqlmap.py +++ b/_sqlmap.py @@ -30,12 +30,14 @@ from lib.core.common import unhandledExceptionMessage from lib.core.exception import SqlmapBaseException from lib.core.exception import SqlmapSilentQuitException from lib.core.exception import SqlmapUserQuitException +from lib.core.option import initOptions from lib.core.option import init from lib.core.profiling import profile 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 setRestAPILog from lib.utils.api import StdDbOut def modulePath(): @@ -57,19 +59,22 @@ def main(): # Store original command line options for possible later restoration cmdLineOptions.update(cmdLineParser().__dict__) - init(cmdLineOptions) + initOptions(cmdLineOptions) if hasattr(conf, "api"): # Overwrite system standard output and standard error to write # to an IPC database sys.stdout = StdDbOut(conf.taskid, messagetype="stdout") sys.stderr = StdDbOut(conf.taskid, messagetype="stderr") + setRestAPILog() banner() dataToStdout("[!] legal disclaimer: %s\n\n" % LEGAL_DISCLAIMER, forceOutput=True) dataToStdout("[*] starting at %s\n\n" % time.strftime("%X"), forceOutput=True) + init() + if conf.profile: profile() elif conf.smokeTest: diff --git a/lib/core/option.py b/lib/core/option.py index 39476b559..5c7777797 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -136,7 +136,6 @@ from lib.request.httpshandler import HTTPSHandler from lib.request.rangehandler import HTTPRangeHandler from lib.request.redirecthandler import SmartRedirectHandler from lib.request.templates import getPageTemplate -from lib.utils.api import setRestAPILog from lib.utils.crawler import crawl from lib.utils.deps import checkDependencies from lib.utils.google import Google @@ -2052,21 +2051,22 @@ def _resolveCrossReferences(): lib.core.common.getPageTemplate = getPageTemplate lib.core.convert.singleTimeWarnMessage = singleTimeWarnMessage -def init(inputOptions=AttribDict(), overrideOptions=False): - """ - Set attributes into both configuration and knowledge base singletons - based upon command line and configuration file options. - """ - +def initOptions(inputOptions=AttribDict(), overrideOptions=False): if not inputOptions.disableColoring: coloramainit() _setConfAttributes() _setKnowledgeBaseAttributes() _mergeOptions(inputOptions, overrideOptions) + +def init(): + """ + Set attributes into both configuration and knowledge base singletons + based upon command line and configuration file options. + """ + _useWizardInterface() setVerbosity() - setRestAPILog() _saveCmdline() _setRequestFromFile() _cleanupOptions()