def load_program(ctx, filename, gui): p = amoco.load_program(filename) ctx.obj["p"] = p if gui: spawn_gui(ctx) else: spawn_console(ctx,["p"])
def test_func(ploop): p = amoco.load_program(ploop) z = lsweep(p) # build func manually... fcfg = cfg.graph() b0 = cfg.node(z.getblock(0x804849d)) b1 = cfg.node(z.getblock(0x80484ac)) #b1.cut(0x80484d0) b2 = cfg.node(z.getblock(0x80484d0)) b3 = cfg.node(z.getblock(0x80484d8)) e0 = cfg.link(b0,b1) e1 = cfg.link(b1,b2) e2 = cfg.link(b2,b1) e3 = cfg.link(b2,b3) for e in (e0,e1,e2,e3): fcfg.add_edge(e) assert len(fcfg.C)==1 # create func: f = code.func(fcfg.C[0]) assert f.support==(0x804849d,0x80484e5) assert f.blocks==[n.data for n in f.cfg.sV] #s = cfg.signature(f.cfg) #sig = '{[(+Fcejv)] [(?Facjlv)(Fc)(-Fclr)]}' #assert s == sig # test pickle func: x = pickler(f) y = loads(x) assert y._is_func assert y.blocks==f.blocks assert y.support==f.support
def emul_program(ctx, filename, gui, interact): p = amoco.load_program(filename) p = amoco.emul(p) ctx.obj["p"] = p if gui: spawn_gui(ctx) else: spawn_emul(ctx,interact)
def emul_program(ctx, filename, gui, fallback): p = amoco.load_program(filename) q = amoco.emul(p) ctx.obj["p"] = p ctx.obj["q"] = q if gui: spawn_gui(ctx) else: spawn_emul(ctx, fallback)
def bin_info(ctx, filename, header): p = amoco.load_program(filename) ctx.obj["p"] = p click.secho("file: ",fg='blue') click.secho(str(p.view.title())) click.secho("checksec: ",fg='blue') click.echo(str(p.view.checksec)) if header: click.secho("header:",fg='blue') click.echo(str(p.view.header)) spawn_console(ctx)
def test_block(sc1): p = amoco.load_program(sc1) p.use_x86() z = lsweep(p) ib = z.iterblocks() b0 = next(ib) assert b0._is_block b1 = next(ib) assert b1._is_block # test pickle: x = pickler(b0) y = pickler(b1) X = loads(x) assert len(X.instr)==1 assert X.address==b0.address assert X.support==b0.support Y = loads(y) assert Y==b1 addr = Y.instr[-2].address n = Y.cut(addr) assert len(Y.instr)==(len(b1.instr)-2)
def test_loader_003(sc1): p = amoco.load_program(sc1) assert p.bin.f.getvalue() == sc1 assert p.bin.filename == '(sc-eb165e31...)'
def test_loader_002(samples): for f in samples: p = amoco.load_program(f)