mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-26 03:23:48 +03:00
Added commands stop, kill, list to API client
This commit is contained in:
parent
5ce3306114
commit
1417decdf1
|
@ -368,18 +368,19 @@ def task_delete(taskid):
|
||||||
###################
|
###################
|
||||||
|
|
||||||
|
|
||||||
|
@get("/admin/list")
|
||||||
@get("/admin/<taskid>/list")
|
@get("/admin/<taskid>/list")
|
||||||
def task_list(taskid):
|
def task_list(taskid=None):
|
||||||
"""
|
"""
|
||||||
List task pull
|
List task pull
|
||||||
"""
|
"""
|
||||||
if is_admin(taskid):
|
logger.debug("[%s] Listed task pool")
|
||||||
logger.debug("[%s] Listed task pool" % taskid)
|
if taskid is not None:
|
||||||
tasks = list(DataStore.tasks)
|
tasks = list(DataStore.tasks)
|
||||||
return jsonize({"success": True, "tasks": tasks, "tasks_num": len(tasks)})
|
|
||||||
else:
|
else:
|
||||||
logger.warning("[%s] Unauthorized call to task_list()" % taskid)
|
tasks = {x: dejsonize(scan_status(x))['status']
|
||||||
return jsonize({"success": False, "message": "Unauthorized"})
|
for x in list(DataStore.tasks)}
|
||||||
|
return jsonize({"success": True, "tasks": tasks, "tasks_num": len(tasks)})
|
||||||
|
|
||||||
|
|
||||||
@get("/admin/<taskid>/flush")
|
@get("/admin/<taskid>/flush")
|
||||||
|
@ -475,7 +476,9 @@ def scan_stop(taskid):
|
||||||
"""
|
"""
|
||||||
Stop a scan
|
Stop a scan
|
||||||
"""
|
"""
|
||||||
if taskid not in DataStore.tasks:
|
if (taskid not in DataStore.tasks or
|
||||||
|
DataStore.tasks[taskid].engine_process() is None or
|
||||||
|
DataStore.tasks[taskid].engine_has_terminated()):
|
||||||
logger.warning("[%s] Invalid task ID provided to scan_stop()" % taskid)
|
logger.warning("[%s] Invalid task ID provided to scan_stop()" % taskid)
|
||||||
return jsonize({"success": False, "message": "Invalid task ID"})
|
return jsonize({"success": False, "message": "Invalid task ID"})
|
||||||
|
|
||||||
|
@ -490,7 +493,9 @@ def scan_kill(taskid):
|
||||||
"""
|
"""
|
||||||
Kill a scan
|
Kill a scan
|
||||||
"""
|
"""
|
||||||
if taskid not in DataStore.tasks:
|
if (taskid not in DataStore.tasks or
|
||||||
|
DataStore.tasks[taskid].engine_process() is None or
|
||||||
|
DataStore.tasks[taskid].engine_has_terminated()):
|
||||||
logger.warning("[%s] Invalid task ID provided to scan_kill()" % taskid)
|
logger.warning("[%s] Invalid task ID provided to scan_kill()" % taskid)
|
||||||
return jsonize({"success": False, "message": "Invalid task ID"})
|
return jsonize({"success": False, "message": "Invalid task ID"})
|
||||||
|
|
||||||
|
@ -691,7 +696,7 @@ def client(host=RESTAPI_SERVER_HOST, port=RESTAPI_SERVER_PORT):
|
||||||
print
|
print
|
||||||
break
|
break
|
||||||
|
|
||||||
if command.lower() in ("data", "log", "status"):
|
if command.lower() in ("data", "log", "status", "stop", "kill"):
|
||||||
if not taskid:
|
if not taskid:
|
||||||
logger.error("No task ID in use")
|
logger.error("No task ID in use")
|
||||||
continue
|
continue
|
||||||
|
@ -743,6 +748,13 @@ def client(host=RESTAPI_SERVER_HOST, port=RESTAPI_SERVER_PORT):
|
||||||
continue
|
continue
|
||||||
logger.info("Switching to task ID '%s' " % taskid)
|
logger.info("Switching to task ID '%s' " % taskid)
|
||||||
|
|
||||||
|
elif command.lower() == "list":
|
||||||
|
raw = _client(addr + "/admin/list")
|
||||||
|
res = dejsonize(raw)
|
||||||
|
if not res["success"]:
|
||||||
|
logger.error("Failed to execute command " + command)
|
||||||
|
dataToStdout("%s\n" % raw)
|
||||||
|
|
||||||
elif command.lower() in ("exit", "bye", "quit", 'q'):
|
elif command.lower() in ("exit", "bye", "quit", 'q'):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -753,6 +765,9 @@ def client(host=RESTAPI_SERVER_HOST, port=RESTAPI_SERVER_PORT):
|
||||||
msg += "data Retrieve and show data for current task\n"
|
msg += "data Retrieve and show data for current task\n"
|
||||||
msg += "log Retrieve and show log for current task\n"
|
msg += "log Retrieve and show log for current task\n"
|
||||||
msg += "status Retrieve and show status for current task\n"
|
msg += "status Retrieve and show status for current task\n"
|
||||||
|
msg += "stop Stop current task\n"
|
||||||
|
msg += "kill Kill current task\n"
|
||||||
|
msg += "list Display all tasks\n"
|
||||||
msg += "exit Exit this client\n"
|
msg += "exit Exit this client\n"
|
||||||
|
|
||||||
dataToStdout(msg)
|
dataToStdout(msg)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user