コード例 #1
0
ファイル: webui.py プロジェクト: tpourcelot/polichombr
def diff_samples(sample_id, sample2_id):
    """
    Diff two samples using MACHOC. Maybe we could move this view in the sample
    view, just as we did for the disassemble view?
    """
    sample1 = api.samplecontrol.get_by_id(sample_id)
    if sample1 is None:
        abort(500)
    sample2 = api.samplecontrol.get_by_id(sample2_id)
    if sample2 is None:
        abort(500)
    sdiff = []
    # POST request means that the samples names sharing has been submitted.
    if request.method == "POST":
        if not request.form.getlist("selectl"):
            abort(500)
        items = []
        for i in request.form.getlist("selectl"):
            n = i.split("_")
            if len(n) == 2:
                items.append((n[0], n[1]))
        if not api.samplecontrol.sample_rename_from_diff(
                items, sample1, sample2):
            abort(500)
        if not api.add_actions_fromfunc_infos(items, sample1, sample2):
            abort(500)
        return redirect("/sample/" + str(sample1.id) + "#poli_infos")
    else:
        sdiff = api.samplecontrol.machoc_get_similar_functions(
            sample1, sample2)
    return render_template("diff.html",
                           sample1=sample1,
                           sample2=sample2,
                           sdiff=sdiff)
コード例 #2
0
ファイル: webui_sample.py プロジェクト: ANSSI-FR/polichombr
def diff_samples(sample_id, sample2_id):
    """
    Diff two samples using MACHOC. Maybe we could move this view in the sample
    view, just as we did for the disassemble view?
    """
    sample1 = api.get_elem_by_type("sample", sample_id)
    sample2 = api.get_elem_by_type("sample", sample2_id)
    sdiff = []
    # POST request means that the samples names sharing has been submitted.
    if request.method == "POST":
        if not request.form.getlist("selectl"):
            abort(500)
        items = []
        for i in request.form.getlist("selectl"):
            n = i.split("_")
            if len(n) == 2:
                items.append((n[0], n[1]))
        if not api.samplecontrol.sample_rename_from_diff(
                items, sample1, sample2):
            abort(500)
        if not api.add_actions_fromfunc_infos(items, sample1, sample2):
            abort(500)
        return redirect("/sample/" + str(sample1.id) + "#poli_infos")
    else:
        sdiff = api.samplecontrol.machoc_get_similar_functions(
            sample1, sample2)
    return render_template("diff.html",
                           sample1=sample1,
                           sample2=sample2,
                           sdiff=sdiff)