コード例 #1
0
    def test_dependencies(self):
        s_initialize("DEP TEST 1")
        s_group("group", default_value=b"0", values=[b"1", b"2"])

        if s_block_start("ONE", dep="group", dep_values=[b"1"]):
            s_static("ONE")
            s_block_end()

        if s_block_start("TWO", dep="group", dep_values=[b"2"]):
            s_static("TWO")
            s_group("group2", default_value=b"0", values=[b"1", b"2"])
            s_block_end()

        mutations = list(blocks.CURRENT.get_mutations())
        rendered = blocks.CURRENT.render()
        assert b"ONE" not in rendered
        assert b"TWO" not in rendered
        rendered = blocks.CURRENT.render(
            MutationContext(mutations=mutations[0]))
        assert b"ONE" in rendered
        assert b"TWO" not in rendered
        rendered = blocks.CURRENT.render(
            MutationContext(mutations=mutations[1]))
        assert b"ONE" not in rendered
        assert b"TWO" in rendered
        assert len(mutations) == 4
コード例 #2
0
ファイル: test_s_group.py プロジェクト: youduda/boofuzz
def scenario_output_as(context, mutation, result):
    if result.startswith("0x"):
        result = result[2:]
        result = bytes(bytearray.fromhex(result))
    mutation = int(mutation)
    assert context.req.render(
        MutationContext(mutation=context.mutations[mutation])) == result
コード例 #3
0
    def test_repeaters(self):
        s_initialize("REP TEST 1")
        if s_block_start("BLOCK"):
            s_delim(">", name="delim", fuzzable=False)
            s_string("pedram", name="string", fuzzable=False)
            s_byte(0xDE, name="byte", fuzzable=False)
            s_word(0xDEAD, name="word", fuzzable=False)
            s_dword(0xDEADBEEF, name="dword", fuzzable=False)
            s_qword(0xDEADBEEFDEADBEEF, name="qword", fuzzable=False)
            s_random(b"0", 5, 10, 100, name="random", fuzzable=False)
            s_block_end()
        s_repeat("BLOCK", min_reps=5, max_reps=15, step=5)

        data = blocks.CURRENT.render()
        length = len(data)
        self.assertEqual(23, length)

        expected_lengths = [length + length * 5, length + length * 10, length + length * 15]
        for mutation, expected_length in zip(blocks.CURRENT.get_mutations(), expected_lengths):
            data = blocks.CURRENT.render(MutationContext(mutation=mutation))
            self.assertEqual(expected_length, len(data))
コード例 #4
0
def scenario_can_render_all_mutations(context):
    for mutation in context.mutations:
        context.req.render(MutationContext(mutations=mutation))
コード例 #5
0
def scenario_can_render_all_mutations(context):
    mutations = list(context.req.get_mutations())
    for mutation in mutations:
        context.req.render(MutationContext(mutations=mutation))