Пример #1
0
def start(fb):
    poc_manager = PoCManager(fb)
    results = poc_manager.run()
    if fb.console:
        return results if results else None
    else:
        if results: log.result(results)
Пример #2
0
def start_task():
    post_data = request.get_json(force=True)
    task_data = {}
    task_data["task_id"] = post_data.get("task_id", "")
    if not task_data["task_id"]:
        return jsonify(status=400,
                       message="Missing Parameter 'task_id'.",
                       data="POST[task_id]")
    if PoCManager.check_task_exist(task_data["task_id"]):
        return jsonify(status=400,
                       message="Task exist.",
                       data=task_data["task_id"])
    task_data["target"] = post_data.get("target", "")
    if not task_data["target"]:
        return jsonify(status=400,
                       message="Missing Parameter 'target'.",
                       data="POST[target]")
    task_data["vid"] = post_data.get("vid", "")
    if not task_data["vid"]:
        return jsonify(status=400,
                       message="Missing Parameter 'vid'.",
                       data="POST[vid]")
    task_data["mode"] = post_data.get("mode", "verify")
    task_data["verbose"] = post_data.get("verbose", True)
    task_data["cookies"] = post_data.get("cookies", "x")
    task_data["headers"] = post_data.get("headers", "x")
    task_data["proxy"] = post_data.get("proxy", "x")
    task_data["poc_dir"] = post_data.get("poc_dir", None)

    start_task_func.delay(task_data)
    return jsonify(status=200)
Пример #3
0
def start_poc_task(task_data):
    def kill_child_processes(parent_pid, sig=signal.SIGTERM):
        try:
            p = psutil.Process(parent_pid)
        except psutil.NoSuchProcess:
            return
        child_pid = p.children(recursive=True)
        for pid in child_pid:
            os.kill(pid.pid, sig)

    cmd_list = [PROGRAM, DST_FILE]
    cmd_list.extend(['''--target={}'''.format(task_data.get("target", ""))])
    cmd_list.extend(['''--vid={}'''.format(task_data.get("vid", ""))])
    cmd_list.extend(['''--task_id={}'''.format(task_data.get("task_id", ""))])
    cmd_list.extend(['''--mode={}'''.format(task_data.get("mode", "verify"))])
    cmd_list.extend(['''--quiet''' if not task_data.get("verbose", True) else ""])
    cmd_list.extend(['''--cookies={}'''.format(task_data.get("cookies", "x"))])
    cmd_list.extend(['''--proxy={}'''.format(task_data.get("proxy", "x"))])
    cmd_list.extend(['''--headers={}'''.format(task_data.get("headers", "x"))])
    if task_data.get("poc_dir"):
        cmd_list.extend(['''--poc-dir={}'''.format(task_data.get("poc_dir"))])

    manager_process = SubProcess(cmd_list).run()

    # Process timeout
    if manager_process['status'] == 1:
        process = manager_process['proc']
        log.info("process {} is timeout when scanning [{}]-[{}]-[{}],terminating...".format(
            process.pid, task_data.get("task_id"), task_data.get("vid", ""), task_data.get("target", "")))
        PoCManager.exit_write2db(task_data.get("task_id", ""))

        kill_child_processes(process.pid)
        process.kill()
        process.wait()

    if manager_process['status'] == -1:
        process = manager_process['proc']
        log.info("process {} is been revoked when scanning [{}]-[{}].".format(
            process.pid, task_data.get("vid", ""), task_data.get("target", "")))
Пример #4
0
def get_result():
    post_data = request.get_json(force=True)
    task_id = post_data.get("task_id", "")
    if not task_id:
        return jsonify(status=400, message="Missing Parameter 'task_id'.", data="POST[task_id]")

    if not check_task_id(task_id):
        return jsonify(status=400, message="task_id error")

    results = PoCManager.get_task_result(task_id)
    if not results:
        return jsonify(status=400, message="Task no found.")
    else:
        results_data = results.get("data", "")
        if results_data:
            if not isinstance(results_data, dict):
                return jsonify(status=201, message=results_data)
            else:
                return jsonify(results_data)
        else:
            return jsonify(status=201, message="not vuln")