mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 02:53:46 +03:00
fixed options initiation
This commit is contained in:
parent
b0635bddcc
commit
7adaffa71b
|
@ -1784,7 +1784,7 @@ def _mergeOptions(inputOptions, overrideOptions):
|
||||||
kb.explicitSettings.add(key)
|
kb.explicitSettings.add(key)
|
||||||
|
|
||||||
for key, value in defaults.items():
|
for key, value in defaults.items():
|
||||||
if conf[key] is None:
|
if hasattr(conf, key) and conf[key] is None:
|
||||||
conf[key] = value
|
conf[key] = value
|
||||||
|
|
||||||
def _setTrafficOutputFP():
|
def _setTrafficOutputFP():
|
||||||
|
|
|
@ -183,6 +183,7 @@ optDict = {
|
||||||
"hexConvert": "boolean",
|
"hexConvert": "boolean",
|
||||||
"oDir": "string",
|
"oDir": "string",
|
||||||
"parseErrors": "boolean",
|
"parseErrors": "boolean",
|
||||||
|
"saveCmdline": "boolean",
|
||||||
"updateAll": "boolean",
|
"updateAll": "boolean",
|
||||||
"tor": "boolean",
|
"tor": "boolean",
|
||||||
"torPort": "integer",
|
"torPort": "integer",
|
||||||
|
@ -202,6 +203,7 @@ optDict = {
|
||||||
"hpp": "boolean",
|
"hpp": "boolean",
|
||||||
"mobile": "boolean",
|
"mobile": "boolean",
|
||||||
"pageRank": "boolean",
|
"pageRank": "boolean",
|
||||||
|
"purgeOutput": "boolean",
|
||||||
"smart": "boolean",
|
"smart": "boolean",
|
||||||
"testFilter": "string",
|
"testFilter": "string",
|
||||||
"wizard": "boolean",
|
"wizard": "boolean",
|
||||||
|
|
|
@ -7,7 +7,6 @@ See the file 'doc/COPYING' for copying permission
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import optparse
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
@ -27,20 +26,21 @@ from extra.bottle.bottle import run
|
||||||
from extra.bottle.bottle import static_file
|
from extra.bottle.bottle import static_file
|
||||||
from extra.bottle.bottle import template
|
from extra.bottle.bottle import template
|
||||||
from lib.controller.controller import start
|
from lib.controller.controller import start
|
||||||
|
from lib.core.common import unArrayizeValue
|
||||||
from lib.core.convert import hexencode
|
from lib.core.convert import hexencode
|
||||||
from lib.core.convert import stdoutencode
|
from lib.core.convert import stdoutencode
|
||||||
from lib.core.data import paths
|
from lib.core.data import paths
|
||||||
from lib.core.datatype import AttribDict
|
from lib.core.datatype import AttribDict
|
||||||
from lib.core.data import cmdLineOptions
|
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
|
from lib.core.defaults import _defaults
|
||||||
from lib.core.log import FORMATTER
|
from lib.core.log import FORMATTER
|
||||||
from lib.core.log import LOGGER_HANDLER
|
from lib.core.log import LOGGER_HANDLER
|
||||||
from lib.core.log import LOGGER_OUTPUT
|
from lib.core.log import LOGGER_OUTPUT
|
||||||
from lib.core.exception import SqlmapMissingDependence
|
from lib.core.exception import SqlmapMissingDependence
|
||||||
|
from lib.core.optiondict import optDict
|
||||||
from lib.core.option import init
|
from lib.core.option import init
|
||||||
from lib.core.settings import UNICODE_ENCODING
|
from lib.core.settings import UNICODE_ENCODING
|
||||||
from lib.parse.cmdline import cmdLineParser
|
|
||||||
|
|
||||||
RESTAPI_SERVER_HOST = "127.0.0.1"
|
RESTAPI_SERVER_HOST = "127.0.0.1"
|
||||||
RESTAPI_SERVER_PORT = 8775
|
RESTAPI_SERVER_PORT = 8775
|
||||||
|
@ -60,6 +60,21 @@ def is_admin(taskid):
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def init_options():
|
||||||
|
dataype = {"boolean": False, "string": "", "integer": 0, "float": 0.0}
|
||||||
|
options = AttribDict()
|
||||||
|
|
||||||
|
for _ in optDict:
|
||||||
|
for name, type_ in optDict[_].items():
|
||||||
|
type_ = unArrayizeValue(type_)
|
||||||
|
options[name] = _defaults.get(name, dataype[type_])
|
||||||
|
|
||||||
|
# Enforce batch mode and disable coloring
|
||||||
|
options.batch = True
|
||||||
|
options.disableColoring = True
|
||||||
|
|
||||||
|
return options
|
||||||
|
|
||||||
@hook("after_request")
|
@hook("after_request")
|
||||||
def security_headers():
|
def security_headers():
|
||||||
"""
|
"""
|
||||||
|
@ -106,10 +121,8 @@ def task_new():
|
||||||
"""
|
"""
|
||||||
global tasks
|
global tasks
|
||||||
|
|
||||||
optset()
|
|
||||||
|
|
||||||
taskid = hexencode(os.urandom(16))
|
taskid = hexencode(os.urandom(16))
|
||||||
tasks[taskid] = AttribDict(cmdLineOptions)
|
tasks[taskid] = init_options()
|
||||||
|
|
||||||
return jsonize({"taskid": taskid})
|
return jsonize({"taskid": taskid})
|
||||||
|
|
||||||
|
@ -247,7 +260,7 @@ def scan_start(taskid):
|
||||||
for key, value in request.json.items():
|
for key, value in request.json.items():
|
||||||
tasks[taskid][key] = value
|
tasks[taskid][key] = value
|
||||||
|
|
||||||
print "TASKS:", tasks
|
print "DEBUG TASKS:", tasks
|
||||||
|
|
||||||
# Overwrite output directory (oDir) value to a temporary directory
|
# Overwrite output directory (oDir) value to a temporary directory
|
||||||
tasks[taskid].oDir = tempfile.mkdtemp(prefix="sqlmap-")
|
tasks[taskid].oDir = tempfile.mkdtemp(prefix="sqlmap-")
|
||||||
|
@ -328,10 +341,6 @@ def download(taskid, target, filename):
|
||||||
else:
|
else:
|
||||||
abort(500)
|
abort(500)
|
||||||
|
|
||||||
def optset():
|
|
||||||
# Store original command line options for possible later restoration
|
|
||||||
cmdLineOptions.update(cmdLineParser().__dict__)
|
|
||||||
|
|
||||||
def server(host="0.0.0.0", port=RESTAPI_SERVER_PORT):
|
def server(host="0.0.0.0", port=RESTAPI_SERVER_PORT):
|
||||||
"""
|
"""
|
||||||
REST-JSON API server
|
REST-JSON API server
|
||||||
|
@ -339,12 +348,8 @@ def server(host="0.0.0.0", port=RESTAPI_SERVER_PORT):
|
||||||
global adminid
|
global adminid
|
||||||
global tasks
|
global tasks
|
||||||
|
|
||||||
# Enforce batch mode and disable coloring
|
|
||||||
cmdLineOptions.batch = True
|
|
||||||
cmdLineOptions.disableColoring = True
|
|
||||||
|
|
||||||
adminid = hexencode(os.urandom(16))
|
adminid = hexencode(os.urandom(16))
|
||||||
tasks[adminid] = AttribDict(cmdLineOptions)
|
tasks[adminid] = init_options()
|
||||||
|
|
||||||
logger.info("running REST-JSON API server at '%s:%d'.." % (host, port))
|
logger.info("running REST-JSON API server at '%s:%d'.." % (host, port))
|
||||||
logger.info("the admin task ID is: %s" % adminid)
|
logger.info("the admin task ID is: %s" % adminid)
|
||||||
|
|
|
@ -25,16 +25,19 @@ if __name__ == "__main__":
|
||||||
# Set default logging level to debug
|
# Set default logging level to debug
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
# Initialize path variable
|
||||||
paths.SQLMAP_ROOT_PATH = modulePath()
|
paths.SQLMAP_ROOT_PATH = modulePath()
|
||||||
setPaths()
|
setPaths()
|
||||||
|
|
||||||
|
# Parse command line options
|
||||||
apiparser = optparse.OptionParser()
|
apiparser = optparse.OptionParser()
|
||||||
apiparser.add_option("--server", help="Act as a REST-JSON API server", default=RESTAPI_SERVER_PORT, action="store_true")
|
apiparser.add_option("-s", "--server", help="Act as a REST-JSON API server", default=RESTAPI_SERVER_PORT, action="store_true")
|
||||||
apiparser.add_option("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_SERVER_PORT, action="store_true")
|
apiparser.add_option("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_SERVER_PORT, action="store_true")
|
||||||
apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server", default=RESTAPI_SERVER_HOST, action="store")
|
apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server", default=RESTAPI_SERVER_HOST, action="store")
|
||||||
apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server", default=RESTAPI_SERVER_PORT, type="int", action="store")
|
apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server", default=RESTAPI_SERVER_PORT, type="int", action="store")
|
||||||
(args, _) = apiparser.parse_args()
|
(args, _) = apiparser.parse_args()
|
||||||
|
|
||||||
|
# Start the client or the server
|
||||||
if args.server is True:
|
if args.server is True:
|
||||||
server(args.host, args.port)
|
server(args.host, args.port)
|
||||||
elif args.client is True:
|
elif args.client is True:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user