Beispiel #1
0
def test_inspect_syscall():
    class counts: #pylint:disable=no-init
        exit_before = 0
        exit_after = 0

    def handle_syscall_before(state):
        counts.exit_before += 1
        syscall_name = state.inspect.syscall_name
        assert syscall_name == "close"

    def handle_syscall_after(state):
        counts.exit_after += 1
        syscall_name = state.inspect.syscall_name
        assert syscall_name == "close"

    s = SimState(arch="AMD64", mode="symbolic")
    # set up to call so syscall close
    s.regs.rax = 3
    s.regs.rdi = 2

    # break on syscall
    s.inspect.b('syscall', BP_BEFORE, action=handle_syscall_before)
    s.inspect.b('syscall', BP_AFTER, action=handle_syscall_after)

    # step it
    proc = SIM_PROCEDURES['posix']['close'](is_syscall=True)
    ProcedureEngine(None).process(s, procedure=proc, ret_to=s.ip)

    # check counts
    assert counts.exit_before == 1
    assert counts.exit_after == 1
Beispiel #2
0
    def test_procedure_actions(self):
        s = SimState(arch='AMD64')

        s.registers.store('rbx', 2)
        proc = SIM_PROCEDURES['testing']['retreg'](reg='rbx')
        succ = ProcedureEngine(None).process(s, procedure=proc)
        rbx = succ.artifacts['procedure'].ret_expr
        assert type(rbx) is angr.state_plugins.SimActionObject
        assert s.solver.eval(rbx) == 2
        assert rbx.reg_deps == {s.arch.registers['rbx'][0]}
Beispiel #3
0
def test_procedure_actions():
    s = SimState(arch='AMD64')

    s.registers.store('rbx', 2)
    proc = SIM_PROCEDURES['testing']['retreg'](reg='rbx')
    succ = ProcedureEngine(None).process(s, procedure=proc)
    rbx = succ.artifacts['procedure'].ret_expr
    nose.tools.assert_is(type(rbx), angr.state_plugins.SimActionObject)
    nose.tools.assert_equal(s.solver.eval(rbx), 2)
    nose.tools.assert_equal(rbx.reg_deps, {s.arch.registers['rbx'][0]})