def test_tutorial():
    thebin = str(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../test_programs/msp430/microcorruption_tutorial/out.elf'))
    p = angr.Project(thebin, load_options={'rebase_granularity': 8})
    p.hook_symbol('getsn', simos_msp430.MCgetsn())
    p.hook_symbol('__stop_progExec__', simos_msp430.MCstopexec())
    p.hook_symbol('puts', simos_msp430.MCputs())
    simgr = p.factory.simulation_manager(save_unconstrained=True)
    simgr.explore(find=p.loader.find_symbol('unlock_door').rebased_addr)
    stdin_contents = simgr.found[0].posix.dumps(0)
    nose.tools.assert_not_in(b'\0', stdin_contents[:8])
    nose.tools.assert_equal(stdin_contents[8], 0)
def test_sydney():
    thebin = str(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     '../test_programs/msp430/microcorruption_sydney/out.elf'))
    p = angr.Project(thebin, load_options={'rebase_granularity': 8})
    p.hook_symbol('getsn', simos_msp430.MCgetsn())
    p.hook_symbol('__stop_progExec__', simos_msp430.MCstopexec())
    p.hook_symbol('puts', simos_msp430.MCputs())
    simgr = p.factory.simulation_manager()
    simgr.explore(find=0x4462)
    stdin_contents = simgr.found[0].posix.dumps(0)
    nose.tools.assert_true('47544e6b7b5f443a00' in stdin_contents.hex())
Ejemplo n.º 3
0
def test_new_orleans():
    thebin = str(
        os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            '../test_programs/msp430/microcorruption_new_orleans/out.elf'))
    p = angr.Project(thebin, load_options={'rebase_granularity': 8})
    p.hook_symbol('getsn', simos_msp430.MCgetsn())
    p.hook_symbol('__stop_progExec__', simos_msp430.MCstopexec())
    p.hook_symbol('puts', simos_msp430.MCputs())
    simgr = p.factory.simulation_manager()
    simgr.explore(find=p.loader.find_symbol('unlock_door').rebased_addr)
    stdin_contents = simgr.found[0].posix.dumps(0)
    nose.tools.assert_true('7d493c6a51373f' in stdin_contents.hex())