3232from lib .core .log import LOGGER_HANDLER
3333from lib .core .optiondict import optDict
3434from lib .core .subprocessng import Popen
35- from thirdparty .bottle .bottle import error
35+ from thirdparty .bottle .bottle import error as return_error
3636from thirdparty .bottle .bottle import get
3737from thirdparty .bottle .bottle import hook
3838from thirdparty .bottle .bottle import post
@@ -182,6 +182,7 @@ def engine_get_returncode(self):
182182 def engine_has_terminated (self ):
183183 return isinstance (self .engine_get_returncode (), int )
184184
185+
185186# Wrapper functions for sqlmap engine
186187class StdDbOut (object ):
187188 def __init__ (self , taskid , messagetype = "stdout" ):
@@ -289,25 +290,26 @@ def security_headers(json_header=True):
289290# HTTP Status Code functions #
290291##############################
291292
292- @error (401 ) # Access Denied
293+
294+ @return_error (401 ) # Access Denied
293295def error401 (error = None ):
294296 security_headers (False )
295297 return "Access denied"
296298
297299
298- @error (404 ) # Not Found
300+ @return_error (404 ) # Not Found
299301def error404 (error = None ):
300302 security_headers (False )
301303 return "Nothing here"
302304
303305
304- @error (405 ) # Method Not Allowed (e.g. when requesting a POST method via GET)
306+ @return_error (405 ) # Method Not Allowed (e.g. when requesting a POST method via GET)
305307def error405 (error = None ):
306308 security_headers (False )
307309 return "Method not allowed"
308310
309311
310- @error (500 ) # Internal Server Error
312+ @return_error (500 ) # Internal Server Error
311313def error500 (error = None ):
312314 security_headers (False )
313315 return "Internal server error"
@@ -316,6 +318,7 @@ def error500(error=None):
316318# Task management functions #
317319#############################
318320
321+
319322# Users' methods
320323@get ("/task/new" )
321324def task_new ():
@@ -347,15 +350,16 @@ def task_delete(taskid):
347350# Admin functions #
348351###################
349352
353+
350354@get ("/admin/<taskid>/list" )
351355def task_list (taskid ):
352356 """
353357 List task pull
354358 """
355359 if is_admin (taskid ):
356360 logger .debug ("Listed task pull" )
357- task_list = list (DataStore .tasks )
358- return jsonize ({"success" : True , "tasks" : task_list , "tasks_num" : len (task_list )})
361+ tasks = list (DataStore .tasks )
362+ return jsonize ({"success" : True , "tasks" : tasks , "tasks_num" : len (tasks )})
359363 else :
360364 return jsonize ({"success" : False , "message" : "Unauthorized" })
361365
@@ -379,6 +383,7 @@ def task_flush(taskid):
379383# sqlmap core interact functions #
380384##################################
381385
386+
382387# Handle task's options
383388@get ("/option/<taskid>/list" )
384389def option_list (taskid ):
@@ -420,6 +425,7 @@ def option_set(taskid):
420425
421426 return jsonize ({"success" : True })
422427
428+
423429# Handle scans
424430@post ("/scan/<taskid>/start" )
425431def scan_start (taskid ):
@@ -516,6 +522,7 @@ def scan_data(taskid):
516522 logger .debug ("Retrieved data and error messages for scan for task ID %s" % taskid )
517523 return jsonize ({"success" : True , "data" : json_data_message , "error" : json_errors_message })
518524
525+
519526# Functions to handle scans' logs
520527@get ("/scan/<taskid>/log/<start>/<end>" )
521528def scan_log_limited (taskid , start , end ):
@@ -562,6 +569,7 @@ def scan_log(taskid):
562569 logger .debug ("Retrieved log messages for scan for task ID %s" % taskid )
563570 return jsonize ({"success" : True , "log" : json_log_messages })
564571
572+
565573# Function to handle files inside the output directory
566574@get ("/download/<taskid>/<target>/<filename:path>" )
567575def download (taskid , target , filename ):
0 commit comments