1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| import angr import claripy
def Go(): proj = angr.Project('./babycalc') start_addr = 0x40080a init_state = proj.factory.blank_state(addr = start_addr) init_state.regs.rbp = init_state.regs.rsp init_state.regs.rsp -= 0x100
v3 = claripy.BVS('v3', 8) v4 = claripy.BVS('v4', 8) v5 = claripy.BVS('v5', 8) v5 = claripy.BVS('v5', 8) v6 = claripy.BVS('v6', 8) v7 = claripy.BVS('v7', 8) v8 = claripy.BVS('v8', 8) v9 = claripy.BVS('v9', 8) v10 = claripy.BVS('v10', 8) v11 = claripy.BVS('v11', 8) v12 = claripy.BVS('v12', 8) v13 = claripy.BVS('v13', 8) v14 = claripy.BVS('v14', 8) v15 = claripy.BVS('v15', 8) v16 = claripy.BVS('v16', 8) v17 = claripy.BVS('v17', 8) v18 = claripy.BVS('v18', 8) val = [v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18]
for i in range(16): stack_addr = init_state.regs.rbp - 0x30 + i init_state.memory.store(stack_addr, val[i])
simgr = proj.factory.simgr(init_state) find_addr = 0x400ba1 simgr.explore(find = find_addr) if simgr.found: solution_state = simgr.found[0] for i in range(16): real_val = solution_state.solver.eval(val[i]) print(real_val) else: raise Exception('Could not find!') if __name__ == '__main__': Go()
|