(taskid, target, filename)
Download a certain file from the file system
Download a certain file from the file system
Download a certain file from the file system
def download(taskid, target, filename):
    """
    Download a certain file from the file system
    """
    if taskid not in DataStore.tasks:
        logger.warning("[%s] Invalid task ID provided to download()" % taskid)
        return jsonize({"success": False, "message": "Invalid task ID"})

    # Prevent file path traversal - the lame way
    if ".." in target:
        logger.warning("[%s] Forbidden path (%s)" % (taskid, target))
        return jsonize({"success": False, "message": "Forbidden path"})

    path = os.path.join(paths.SQLMAP_OUTPUT_PATH, target)

    if os.path.exists(path):
        logger.debug("[%s] Retrieved content of file %s" % (taskid, target))
        with open(path, 'rb') as inf:
            file_content = inf.read()
        return jsonize({"success": True, "file": file_content.encode("base64")})
    else:
        logger.warning("[%s] File does not exist %s" % (taskid, target))
        return jsonize({"success": False, "message": "File does not exist"})
def download ( taskid , target , filename ) : if taskid not in DataStore . tasks : logger . warning ( "[%s] Invalid task ID provided to download()" % taskid ) return jsonize ( { "success" : False , "message" : "Invalid task ID" } ) # Prevent file path traversal - the lame way if ".." in target : logger . warning ( "[%s] Forbidden path (%s)" % ( taskid , target ) ) return jsonize ( { "success" : False , "message" : "Forbidden path" } ) path = os . path . join ( paths . SQLMAP_OUTPUT_PATH , target ) if os . path . exists ( path ) : logger . debug ( "[%s] Retrieved content of file %s" % ( taskid , target ) ) with open ( path , 'rb' ) as inf : file_content = inf . read ( ) return jsonize ( { "success" : True , "file" : file_content . encode ( "base64" ) } ) else : logger . warning ( "[%s] File does not exist %s" % ( taskid , target ) ) return jsonize ( { "success" : False , "message" : "File does not exist" } )