コード例 #1
0
ファイル: api.py プロジェクト: weloveit/mycuckoo
def tasks_create_submit():
    files = []
    for f in request.files.getlist("file") + request.files.getlist("files"):
        files.append({
            # The pseudo-file "f" has a read() method so passing it along to
            # the Submit Manager as-is should be fine.
            "name": f.filename, "data": f,
        })

    if files:
        submit_type = "files"
    elif request.form.get("strings"):
        submit_type = "strings"
        strings = request.form["strings"].split("\n")
    else:
        return json_error(500, "No files or strings have been given!")

    # Default options.
    options = {
        "procmemdump": "yes",
    }
    options.update(parse_options(request.form.get("options", "")))

    submit_id = sm.pre(
        submit_type, files or strings, sm.translate_options_to(options)
    )
    if not submit_id:
        return json_error(500, "Error creating Submit entry")

    files, errors, options = sm.get_files(submit_id, astree=True)

    options["full-memory-dump"] = parse_bool(
        request.form.get("memory", config("cuckoo:cuckoo:memory_dump"))
    )
    options["enforce-timeout"] = parse_bool(
        request.form.get("enforce_timeout", 0)
    )

    def selected(files, arcname=None):
        ret = []
        for entry in files:
            if entry.get("selected"):
                entry["arcname"] = arcname
                ret.append(entry)
            ret += selected(entry["children"], arcname or entry["filename"])
        return ret

    task_ids = sm.submit(submit_id, {
        "global": {
            "timeout": request.form.get("timeout", ""),
            "priority": request.form.get("priority", 1),
            "tags": request.form.get("tags", None),
            "custom": request.form.get("custom", ""),
            "owner": request.form.get("owner", ""),
            "clock": request.form.get("clock", None),
            "options": options,
        },
        "file_selection": selected(files),
    })
    return jsonify(submit_id=submit_id, task_ids=task_ids, errors=errors)
コード例 #2
0
ファイル: api.py プロジェクト: linuxamada/cuckoo
def tasks_create_file():
    data = request.files["file"]
    package = request.form.get("package", "")
    timeout = request.form.get("timeout", "")
    priority = request.form.get("priority", 1)
    options = request.form.get("options", "")
    machine = request.form.get("machine", "")
    platform = request.form.get("platform", "")
    tags = request.form.get("tags", None)
    custom = request.form.get("custom", "")
    owner = request.form.get("owner", "")
    clock = request.form.get("clock", None)
    user_id = request.form.get("user_id", "")

    memory = parse_bool(request.form.get("memory", 0))
    unique = parse_bool(request.form.get("unique", 0))
    enforce_timeout = parse_bool(request.form.get("enforce_timeout", 0))

    content = data.read()
    if unique and db.find_sample(sha256=hashlib.sha256(content).hexdigest()):
        return json_error(400, "This file has already been submitted")

    temp_file_path = Files.temp_named_put(content, data.filename)

    task_id = db.add_path(
        file_path=temp_file_path,
        package=package,
        timeout=timeout,
        priority=priority,
        options=options,
        machine=machine,
        platform=platform,
        tags=tags,
        custom=custom,
        owner=owner,
        memory=memory,
        enforce_timeout=enforce_timeout,
        clock=clock,
        user_id=user_id,
    )

    return jsonify(task_id=task_id)
コード例 #3
0
ファイル: api.py プロジェクト: CERT-Polska/cuckoo
def tasks_create_file():
    data = request.files["file"]
    package = request.form.get("package", "")
    timeout = request.form.get("timeout", "")
    priority = request.form.get("priority", 1)
    options = request.form.get("options", "")
    machine = request.form.get("machine", "")
    platform = request.form.get("platform", "")
    tags = request.form.get("tags", None)
    custom = request.form.get("custom", "")
    owner = request.form.get("owner", "")
    clock = request.form.get("clock", None)

    memory = parse_bool(request.form.get("memory", 0))
    unique = parse_bool(request.form.get("unique", 0))
    enforce_timeout = parse_bool(request.form.get("enforce_timeout", 0))

    content = data.read()
    if unique and db.find_sample(sha256=hashlib.sha256(content).hexdigest()):
        return json_error(400, "This file has already been submitted")

    temp_file_path = Files.temp_named_put(content, data.filename)

    task_id = db.add_path(
        file_path=temp_file_path,
        package=package,
        timeout=timeout,
        priority=priority,
        options=options,
        machine=machine,
        platform=platform,
        tags=tags,
        custom=custom,
        owner=owner,
        memory=memory,
        enforce_timeout=enforce_timeout,
        clock=clock
    )

    return jsonify(task_id=task_id)
コード例 #4
0
ファイル: config.py プロジェクト: iNarcissuss/Cuckoodroid-1
 def check(self, value):
     try:
         parse_bool(value)
         return True
     except:
         return False
コード例 #5
0
ファイル: config.py プロジェクト: iNarcissuss/Cuckoodroid-1
 def parse(self, value):
     try:
         return parse_bool(value)
     except:
         log.error("Incorrect Boolean %s", value)
コード例 #6
0
ファイル: test_utils.py プロジェクト: frank2411/cuckoo_dev
def test_bool():
    assert utils.parse_bool("true") is True
    assert utils.parse_bool("True") is True
    assert utils.parse_bool("yes") is True
    assert utils.parse_bool("on") is True
    assert utils.parse_bool("1") is True

    assert utils.parse_bool("false") is False
    assert utils.parse_bool("False") is False
    assert utils.parse_bool("None") is False
    assert utils.parse_bool("no") is False
    assert utils.parse_bool("off") is False
    assert utils.parse_bool("0") is False

    assert utils.parse_bool("2") is True
    assert utils.parse_bool("3") is True

    assert utils.parse_bool(True) is True
    assert utils.parse_bool(1) is True
    assert utils.parse_bool(2) is True
    assert utils.parse_bool(False) is False
    assert utils.parse_bool(0) is False
コード例 #7
0
ファイル: test_utils.py プロジェクト: consen/cuckoo
def test_bool():
    assert utils.parse_bool("true") is True
    assert utils.parse_bool("True") is True
    assert utils.parse_bool("yes") is True
    assert utils.parse_bool("on") is True
    assert utils.parse_bool("1") is True

    assert utils.parse_bool("false") is False
    assert utils.parse_bool("False") is False
    assert utils.parse_bool("None") is False
    assert utils.parse_bool("no") is False
    assert utils.parse_bool("off") is False
    assert utils.parse_bool("0") is False

    assert utils.parse_bool("2") is True
    assert utils.parse_bool("3") is True

    assert utils.parse_bool(True) is True
    assert utils.parse_bool(1) is True
    assert utils.parse_bool(2) is True
    assert utils.parse_bool(False) is False
    assert utils.parse_bool(0) is False
コード例 #8
0
ファイル: config.py プロジェクト: CERT-Polska/cuckoo
 def check(self, value):
     try:
         parse_bool(value)
         return True
     except:
         return False
コード例 #9
0
ファイル: config.py プロジェクト: CERT-Polska/cuckoo
 def parse(self, value):
     try:
         return parse_bool(value)
     except:
         log.error("Incorrect Boolean %s", value)