angr符号执行用例解析——ais3_crackme

源码及二进制文件链接:https://github.com/angr/angr-doc/tree/master/examples/ais3_crackme

这次的用例非常简单,也非常基础(也是唯一一个,我自己能做出来的)。

执行这个二进制文件 ./ais3_crackme

输出: You need to enter the secret key!

看来需要参数,随便输入个123: ./ais3_crackme 123

输出:You need to enter the secret key!

所以我们的目的就是输入一个正确的key,得到成功的返回结果,这个key就是最后的flag了。

把ais3_crackme拖到IDA中,分析一下(记得用64位的IDA分析这个文件):

查看字符串:


看到了,Correct!... 再看下调用它的地址:


调用地址是0x400602,下一条指令的地址是0x400607,所以我们目标就是让程序执行到0x400607。

现在就知道如何使用angr了,就是让程序接收一个符号输入,找到从入口点到地址0x400607的路径,求解满足这个路径的符号值就可以啦。

代码如下:

import angr
import claripy

b=angr.Project('ais3_crackme') # load the binary file
argv=claripy.BVS('argv1',100*8) # create a symbol variable
# get the state of entry point
s=b.factory.entry_state(args=['./c',argv]) # the ./c is needed, without it will wrong maybe is related with the input format
sm=b.factory.simulation_manager(s) # init the simulation manager from the entry state
sm.explore(find=0x4006F0) # execute and  find the path to 0x
found=sm.found[0]
solution=found.solver.eval(argv,cast_to=str)
print repr(solution)

solution=solution[:solution.find("\x00")] # because the argv is too long, we need split the result
print solution

运行后输出结果:

ais3{I_tak3_g00d_n0t3s}


你可能感兴趣的:(漏洞挖掘,物联网)