mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-01-24 00:04:23 +03:00
Another update for #1402
This commit is contained in:
parent
2453b02b63
commit
b06a34ab1a
|
@ -647,16 +647,17 @@ def server(host="0.0.0.0", port=RESTAPI_SERVER_PORT):
|
||||||
run(host=host, port=port, quiet=True, debug=False)
|
run(host=host, port=port, quiet=True, debug=False)
|
||||||
|
|
||||||
|
|
||||||
def _client(url, data=None):
|
def _client(url, options=None):
|
||||||
logger.debug("Calling " + url)
|
logger.debug("Calling " + url)
|
||||||
try:
|
try:
|
||||||
if data is not None:
|
data = None
|
||||||
data = jsonize(data)
|
if options is not None:
|
||||||
|
data = jsonize(options)
|
||||||
req = urllib2.Request(url, data, {'Content-Type': 'application/json'})
|
req = urllib2.Request(url, data, {'Content-Type': 'application/json'})
|
||||||
response = urllib2.urlopen(req)
|
response = urllib2.urlopen(req)
|
||||||
text = response.read()
|
text = response.read()
|
||||||
except:
|
except:
|
||||||
if data:
|
if options:
|
||||||
logger.error("Failed to load and parse " + url)
|
logger.error("Failed to load and parse " + url)
|
||||||
raise
|
raise
|
||||||
return text
|
return text
|
||||||
|
@ -707,12 +708,12 @@ def client(host=RESTAPI_SERVER_HOST, port=RESTAPI_SERVER_PORT):
|
||||||
argv = ["sqlmap.py"] + shlex.split(command)[1:]
|
argv = ["sqlmap.py"] + shlex.split(command)[1:]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
d = cmdLineParser(argv).__dict__
|
cmdLineOptions = cmdLineParser(argv).__dict__
|
||||||
except:
|
except:
|
||||||
taskid = None
|
taskid = None
|
||||||
continue
|
continue
|
||||||
|
|
||||||
d = { k: v for k, v in d.iteritems() if v is not None }
|
cmdLineOptions = { k: v for k, v in cmdLineOptions.iteritems() if v is not None }
|
||||||
|
|
||||||
raw = _client(addr + "/task/new")
|
raw = _client(addr + "/task/new")
|
||||||
res = dejsonize(raw)
|
res = dejsonize(raw)
|
||||||
|
@ -722,7 +723,7 @@ def client(host=RESTAPI_SERVER_HOST, port=RESTAPI_SERVER_PORT):
|
||||||
taskid = res["taskid"]
|
taskid = res["taskid"]
|
||||||
logger.info("New task ID is '%s'" % taskid)
|
logger.info("New task ID is '%s'" % taskid)
|
||||||
|
|
||||||
raw = _client(addr + "/scan/" + taskid + "/start", d)
|
raw = _client(addr + "/scan/" + taskid + "/start", cmdLineOptions)
|
||||||
res = dejsonize(raw)
|
res = dejsonize(raw)
|
||||||
if not res["success"]:
|
if not res["success"]:
|
||||||
logger.error("Failed to start scan")
|
logger.error("Failed to start scan")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user