angr学习笔记——0x01
可能上次的是0x00,暂且从官方的examples和docs下手,先捡软柿子捏
Analyses
所有的分析方式都位于project.analyses
下
Name | Description |
---|---|
CFGFast | Constructs a fast Control Flow Graph of the program |
CFGEmulated | Constructs an accurate Control Flow Graph of the program |
VFG | Performs VSA on every function of the program, creating a Value Flow Graph and detecting stack variables |
DDG | Calculates a Data Dependency Graph, allowing one to determine what statements a given value depends on |
BackwardSlice | Computes a Backward Slice of a program with respect to a certain target |
Identifier | Identifies common library functions in CGC binaries |
More! | angr has quite a few analyses, most of which work! If you’d like to know how to use one, please submit an issue requesting documentation. |
examples/CSCI-4968-MBE/challenges/crackme0x04
本身是一个非常简单的题,尤其是crackme0x00~crackme0x03
check()
:
1 | int __cdecl check(char *s) |
本身逻辑很简单,将输入的字符串s
按位转化为数字,相加得15,则正确,回显"Password OK!"
,所以说这一题本身是有无数多解的,包括且不限于"69","78","555"
。
官方自带的solve.py
选择使用CFG去获取FIND_ADDR
,这是我的关注点
1 | cfg = proj.analyses.CFG() |
实际使用过程大同小异,就是通过CFG去寻找一个地址,而不是人工寻找地址。
一个疑问
虽说作为符号执行是不涉及具体值的,但是还是不太理解为什么angr执行结果会存在唯一的found
,而且还是第一个匹配上FIND_ADDR
的结果
CFG
angr-doc
中写道的CFG只有两类:CFGFast
和CFGEmulated
,大概这是稍过时的文档。
当前的angr中能看到有四类CFG:
在此姑且先研究一下CFG
从help(cfg)
中可以首先看到如下一段描述:
CFG is just a wrapper around CFGFast for compatibility issues. It will be fully replaced by CFGFast in future releases. Feel free to use CFG if you intend to use CFGFast. Please use CFGEmulated if you have to use the old, slow, dynamically-generated version of CFG.
For multiple historical reasons, angr’s CFG is accurate but slow, which does not meet what most people expect. We developed CFGFast for light-speed CFG recovery, and renamed the old CFG class to CFGEmulated. For compability concerns, CFG was kept as an alias to CFGEmulated.
However, so many new users of angr would load up a binary and generate a CFG immediately after running “pip install angr”, and draw the conclusion that “angr’s CFG is so slow - angr must be unusable!” Therefore, we made the hard decision: CFG will be an alias to CFGFast, instead of CFGEmulated.
也就是说:
- angr一直致力于优化
CFGFast
,而将老版本的CFG
重命名为CFGEmulated
- 曾经的
CFG
是作为CFGEmulated
的别称存在的 - 很多用户都是直接安装angr后就开始使用
CFG
而不是CFGFast
,这使得很多用户错误地认为angr的CFG相当的慢 - 出于无奈,angr选择将
CFG
改为CFGFast
的别名
所以,目前版本CFG=CFGFast
至于kb
,似乎什么都没有讲,文档里只能看到cfg.kb.functions