angr 00_angr_find demo


00_angr_find是angr的第一个例子,下载位置:https://github.com/jakespringer/angr_ctf

1 启动angr

依次执行如下指令:

export WORKON_HOME=$HOME/Python-workhome
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
workon angr

如果没有ipython,可通过如下指令安装:

pip3 install ipython

2 使用angr解00_angr_find

(1)输入ipython进行python环境

(angr) dist$ ipython
Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.26.0 -- An enhanced Interactive Python. Type '?' for help.

(2)输入import angr引入angr库

In [1]: import angr

(3)通过angr的方法新建一个工程

In [2]: p = angr.Project("./00_angr_find")

(4)告诉angr从哪开始执行(angr是依赖unicorn的,unicorn可以执行任意一段二进制代码)
给出一个初始化状态,并从初始化状态开始执行:

In [3]: init_state = p.factory.entry_state()

In [4]: sm = p.factory.simulation_manager(init_state)

(5)告诉angr从哪儿结束
ida的基本块流图为:
在这里插入图片描述
结束的位置应为push offset aGoodJob ; "Good Job."这条语句的地址08048678,并执行:

In [5]: sm.explore(find=0x08048678)
WARNING | 2021-08-16 21:54:44,296 | angr.storage.memory_mixins.default_filler_mixin | The program is accessing memory or registers with an unspecified value. This could indicate unwanted behavior.
WARNING | 2021-08-16 21:54:44,297 | angr.storage.memory_mixins.default_filler_mixin | angr will cope with this by generating an unconstrained symbolic variable and continuing. You can resolve this by:
WARNING | 2021-08-16 21:54:44,297 | angr.storage.memory_mixins.default_filler_mixin | 1) setting a value to the initial state
WARNING | 2021-08-16 21:54:44,297 | angr.storage.memory_mixins.default_filler_mixin | 2) adding the state option ZERO_FILL_UNCONSTRAINED_{MEMORY,REGISTERS}, to make unknown regions hold null
WARNING | 2021-08-16 21:54:44,297 | angr.storage.memory_mixins.default_filler_mixin | 3) adding the state option SYMBOL_FILL_UNCONSTRAINED_{MEMORY,REGISTERS}, to suppress these messages.
WARNING | 2021-08-16 21:54:44,297 | angr.storage.memory_mixins.default_filler_mixin | Filling register edi with 4 unconstrained bytes referenced from 0x80486b1 (__libc_csu_init+0x1 in 00_angr_find (0x80486b1))
WARNING | 2021-08-16 21:54:44,298 | angr.storage.memory_mixins.default_filler_mixin | Filling register ebx with 4 unconstrained bytes referenced from 0x80486b3 (__libc_csu_init+0x3 in 00_angr_find (0x80486b3))
WARNING | 2021-08-16 21:54:46,799 | angr.storage.memory_mixins.default_filler_mixin | Filling memory at 0x7ffeff60 with 4 unconstrained bytes referenced from 0x818ac20 (strcmp+0x0 in libc.so.6 (0x8ac20))
Out[5]: <SimulationManager with 1 active, 16 deadended, 1 found>

从执行的一些路径看,找到了一条路径可以到达给定的08048678地址。
(6)获取找到的这个状态:

In [6]: sm.found[0]
Out[6]: <SimState @ 0x8048678>

In [7]: found_state = sm.found[0]

(7)由于我们关心的是程序的输入,在这里可以把程序的输入打印出来

In [8]: found_state.posix.dumps(0)
Out[8]: b'JXWVXRKX'

(8)到这里,可以进行一下测试,这个输入的结果正是题目的flag:

(angr) dist$ ./00_angr_find 
Enter the password: JXWVXRKX
Good Job.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值