Angr - Examples
代码取自https://github.com/jakespringer/angr_ctf
输入以到达地址(指示地址)
import angr
import sys
def main(argv):
path_to_binary = argv[1] # :string
project = angr.Project(path_to_binary)
# Start in main()
initial_state = project.factory.entry_state()
# Start simulation
simulation = project.factory.simgr(initial_state)
# Find the way yo reach the good address
good_address = 0x804867d
# Avoiding this address
avoid_address = 0x080485A8
simulation.explore(find=good_address, avoid=avoid_address)
# If found a way to reach the address
if simulation.found:
solution_state = simulation.found[0]
# Print the string that Angr wrote to stdin to follow solution_state
print(solution_state.posix.dumps(sys.stdin.fileno()))
else:
raise Exception('Could not find the solution')
if __name__ == '__main__':
main(sys.argv)到达地址的输入(指示打印)
注册表数值
栈值
在这种情况下,输入是用 scanf("%u %u") 获取的,给定的值是 "1 1",所以栈中的值 0x00000001 来自用户输入。您可以看到这些值是如何从 $ebp - 8 开始的。因此,在代码中,我们已经从 $esp 减去了 8 字节(因为在那时刻 $ebp 和 $esp 具有相同的值),然后我们推入了 BVS。

静态内存值(全局变量)
动态内存值(Malloc)
文件模拟
应用约束
在某些情况下,您可以激活veritesting,它将合并类似状态,以节省无用的分支并找到解决方案:simulation = project.factory.simgr(initial_state, veritesting=True)
模拟管理器
有些模拟管理器可能比其他的更有用。在前面的示例中,存在一个问题,因为创建了许多有用的分支。在这里,veritesting技术将合并这些分支并找到解决方案。
这个模拟管理器也可以通过以下方式激活:simulation = project.factory.simgr(initial_state, veritesting=True)
钩住/绕过对函数的一次调用
Hooking a function / Simprocedure
钩住一个函数 / Simprocedure
模拟带有多个参数的scanf
静态二进制文件
最后更新于