angr 01_angr_avoid avoid路径优化


01_angr_avoid是angr的第2个例子,下载位置:https://github.com/jakespringer/angr_ctf

1 解题过程

(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.

In [1]: import angr

In [2]: p = angr.Project("./01_angr_avoid")

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

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

In [5]: sm.explore(find=0x080485e5, avoid=0x080485a8)
WARNING | 2021-08-17 05:00:47,178 | 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-17 05:00:47,178 | 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-17 05:00:47,178 | angr.storage.memory_mixins.default_filler_mixin | 1) setting a value to the initial state
WARNING | 2021-08-17 05:00:47,178 | 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-17 05:00:47,178 | angr.storage.memory_mixins.default_filler_mixin | 3) adding the state option SYMBOL_FILL_UNCONSTRAINED_{MEMORY,REGISTERS}, to suppress these messages.
WARNING | 2021-08-17 05:00:47,178 | angr.storage.memory_mixins.default_filler_mixin | Filling register edi with 4 unconstrained bytes referenced from 0x80d4591 (__libc_csu_init+0x1 in 01_angr_avoid (0x80d4591))
WARNING | 2021-08-17 05:00:47,180 | angr.storage.memory_mixins.default_filler_mixin | Filling register ebx with 4 unconstrained bytes referenced from 0x80d4593 (__libc_csu_init+0x3 in 01_angr_avoid (0x80d4593))
WARNING | 2021-08-17 05:00:51,423 | angr.storage.memory_mixins.default_filler_mixin | Filling memory at 0x7ffeff3d with 11 unconstrained bytes referenced from 0x818b210 (strncmp+0x0 in libc.so.6 (0x8b210))
WARNING | 2021-08-17 05:00:51,423 | angr.storage.memory_mixins.default_filler_mixin | Filling memory at 0x7ffeff60 with 4 unconstrained bytes referenced from 0x818b210 (strncmp+0x0 in libc.so.6 (0x8b210))
Out[5]: <SimulationManager with 1 active, 16 deadended, 1 found, 8 avoid>

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

In [7]: found_state.posix.dumps(0)
Out[7]: b'HUJOZMYS'

2 IDA设置的问题

拖入IDA32,提示如下信息:
在这里插入图片描述
通过修改配置文件\IDA_Pro_v7.5_Portable\cfg\hexrays.cfg来解决该问题:

MAX_FUNCSIZE            = 64        // Functions over 64K are not decompiled
 
// 修改为:
MAX_FUNCSIZE            = 1024        // Functions over 64K are not decompiled

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
是的,angr 中支持使用蒙特卡洛树搜索(Monte Carlo Tree Search,MCTS)策略进行路径探索。具体来说,angr 提供了一个名为 MCTSExplorer 的探索技术,可以使用蒙特卡洛树搜索策略来探索程序路径。MCTSExplorer 技术会在每个基本块中执行多次符号执行,并根据执行结果动态调整探索策略,以尽可能地覆盖更多的路径。 以下是使用 MCTSExplorer 探索技术进行路径探索的示例代码: ```python import angr # 创建一个 angr 项目 proj = angr.Project('/path/to/binary') # 初始化一个初始状态 state = proj.factory.entry_state() # 初始化一个 MCTSExplorer 探索技术 mcts_explorer = angr.exploration_techniques.MCTSExplorer( num_samples=10, # 每个基本块执行的符号执行次数 num_rounds=5, # 蒙特卡洛树搜索的迭代次数 heuristic=angr.exploration_techniques.ExplorerHeuristic(), # 探索策略 ) # 开始探索 path_group = proj.factory.path_group(state, immutable=False) path_group.use_technique(mcts_explorer) path_group.run() # 输出探索结果 print("Total branches explored:", path_group.branches_explored) print("Total basic blocks explored:", path_group._stashes['deadended'].size()) ``` 在这个示例代码中,我们创建了一个 angr 项目对象以及一个初始状态对象。然后,我们初始化了一个 MCTSExplorer 探索技术,其中 num_samples 参数用于指定每个基本块执行的符号执行次数,num_rounds 参数用于指定蒙特卡洛树搜索的迭代次数,heuristic 参数用于指定探索策略。接着,我们将 MCTSExplorer 技术添加到路径组对象中,并执行路径探索。最后,我们输出了探索结果。 需要注意的是,使用蒙特卡洛树搜索策略进行路径探索可能会非常耗时,因此需要根据具体情况调整 num_samples 和 num_rounds 参数的值,以平衡探索效率和探索质量。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值