def test_state():
    s = SimState(arch='AMD64')
    s.registers.store('sp', 0x7ffffffffff0000)
    nose.tools.assert_equals(s.se.eval(s.registers.load('sp')), 0x7ffffffffff0000)

    s.stack_push(s.se.BVV("ABCDEFGH"))
    nose.tools.assert_equals(s.se.eval(s.registers.load('sp')), 0x7fffffffffefff8)
    s.stack_push(s.se.BVV("IJKLMNOP"))
    nose.tools.assert_equals(s.se.eval(s.registers.load('sp')), 0x7fffffffffefff0)

    a = s.stack_pop()
    nose.tools.assert_equals(s.se.eval(s.registers.load('sp')), 0x7fffffffffefff8)
    nose.tools.assert_equals(s.se.eval(a, cast_to=str), "IJKLMNOP")

    b = s.stack_pop()
    nose.tools.assert_equals(s.se.eval(s.registers.load('sp')), 0x7ffffffffff0000)
    nose.tools.assert_equals(s.se.eval(b, cast_to=str), "ABCDEFGH")
Ejemplo n.º 2
0
    def test_state(self):
        s = SimState(arch="AMD64")
        s.registers.store("sp", 0x7FFFFFFFFFF0000)
        assert s.solver.eval(s.registers.load("sp")) == 0x7FFFFFFFFFF0000

        s.stack_push(s.solver.BVV(b"ABCDEFGH"))
        assert s.solver.eval(s.registers.load("sp")) == 0x7FFFFFFFFFEFFF8
        s.stack_push(s.solver.BVV(b"IJKLMNOP"))
        assert s.solver.eval(s.registers.load("sp")) == 0x7FFFFFFFFFEFFF0

        a = s.stack_pop()
        assert s.solver.eval(s.registers.load("sp")) == 0x7FFFFFFFFFEFFF8
        assert s.solver.eval(a, cast_to=bytes) == b"IJKLMNOP"

        b = s.stack_pop()
        assert s.solver.eval(s.registers.load("sp")) == 0x7FFFFFFFFFF0000
        assert s.solver.eval(b, cast_to=bytes) == b"ABCDEFGH"
Ejemplo n.º 3
0
def test_crosspage_read():
    state = SimState(arch='ARM')
    state.regs.sp = 0x7fff0008
    state.stack_push(0x44556677)
    state.stack_push(0x1)
    state.stack_push(0x2)
    state.stack_push(0x3)
    state.stack_push(0x4)
    state.stack_push(0x99887766)
    state.stack_push(0x5)
    state.stack_push(0x105c8)
    state.stack_push(0x11223344)
    state.stack_push(0x10564)

    r = state.memory.load(state.regs.sp, 40)
    assert "77665544" in state.solver.any_str(r).encode('hex')
Ejemplo n.º 4
0
def test_crosspage_read():
    state = SimState(arch='ARM')
    state.regs.sp = 0x7fff0008
    state.stack_push(0x44556677)
    state.stack_push(0x1)
    state.stack_push(0x2)
    state.stack_push(0x3)
    state.stack_push(0x4)
    state.stack_push(0x99887766)
    state.stack_push(0x5)
    state.stack_push(0x105c8)
    state.stack_push(0x11223344)
    state.stack_push(0x10564)

    r = state.memory.load(state.regs.sp, 40)
    assert bytes.fromhex("77665544") in state.solver.eval(r, cast_to=bytes)
Ejemplo n.º 5
0
def test_crosspage_read():
    state = SimState(arch='ARM')
    state.regs.sp = 0x7fff0008
    state.stack_push(0x44556677)
    state.stack_push(0x1)
    state.stack_push(0x2)
    state.stack_push(0x3)
    state.stack_push(0x4)
    state.stack_push(0x99887766)
    state.stack_push(0x5)
    state.stack_push(0x105c8)
    state.stack_push(0x11223344)
    state.stack_push(0x10564)

    r = state.memory.load(state.regs.sp, 40)
    assert bytes.fromhex("77665544") in state.solver.eval(r, cast_to=bytes)