当前位置:网站首页>Angr(四)——angr_ctf
Angr(四)——angr_ctf
2022-07-25 09:27:00 【c1rcl3】
通过angr_ctf熟悉angr的使用方法
参考链接:
04
1. 直接下载angr_ctf提供的ELF可执行文件04_angr_symbolic_stack
2. 用IDA静态分析,可以发现程序关键逻辑在handle_user中

程序调用scanf读取两个无符号整数(unsigned int)到栈上,之后调用complex_function0和complex_function1对两个参数分别进行处理,最后进行逻辑判断,输出Good Job或Try again。
3. 编写脚本求解程序输出Good Job时对应的输入,可以指定符号执行从handle_user函数调用scanf方法读取输入后开始,需要对栈进行部署。
import angr
def isGood(state):
return b'Good Job.' in state.posix.dumps(1)
def isBad(state):
return b'Try again.' in state.posix.dumps(1)
p = angr.Project("./04")
start_addr = 0x8048697
init_state = p.factory.blank_state(addr=start_addr)
padding_size = 8
init_state.stack_push(init_state.regs.ebp)
init_state.regs.ebp = init_state.regs.esp
init_state.regs.esp -= padding_size
pass1 = init_state.solver.BVS('pass1', 32)
pass2 = init_state.solver.BVS('pass2', 32)
init_state.stack_push(pass1)
init_state.stack_push(pass2)
sm = p.factory.simulation_manager(init_state)
sm.explore(find=isGood, avoid=isBad)
for i in range(0, len(sm.found)):
found_state = sm.found[i]
res1 = found_state.solver.eval(pass1)
res2 = found_state.solver.eval(pass2)
print("{} {}".format(res1, res2))4. 运行脚本查看结果

5. 验证结果正确性
![]()
05
1. 直接下载angr_ctf提供的ELF可执行文件05_angr_symbolic_memory
2. 用IDA静态分析

程序调用scanf读取4个8字节字符串到指定内存中,之后对32个字节逐个进行处理,最后通过字符串比较进行判断,输出Good Job或Try again。
3. 编写脚本求解程序输出Good Job时对应的输入,可以指定符号执行从调用scanf方法读取输入后开始,需要对内存进行部署。
import angr
import claripy
def isGood(state):
return b'Good Job.' in state.posix.dumps(1)
def isBad(state):
return b'Try again.' in state.posix.dumps(1)
p = angr.Project("./05")
start_addr = 0x8048601
init_state = p.factory.blank_state(addr=start_addr)
p1 = claripy.BVS('p1', 64)
p2 = claripy.BVS('p2', 64)
p3 = claripy.BVS('p3', 64)
p4 = claripy.BVS('p4', 64)
p1_addr = 0xA1BA1C0
p2_addr = 0xA1BA1C8
p3_addr = 0xA1BA1D0
p4_addr = 0xA1BA1D8
init_state.memory.store(p1_addr, p1)
init_state.memory.store(p2_addr, p2)
init_state.memory.store(p3_addr, p3)
init_state.memory.store(p4_addr, p4)
sm = p.factory.simulation_manager(init_state)
sm.explore(find=isGood, avoid=isBad)
for i in range(0, len(sm.found)):
found_state = sm.found[i]
res1 = found_state.solver.eval(p1, cast_to=bytes).decode()
res2 = found_state.solver.eval(p2, cast_to=bytes).decode()
res3 = found_state.solver.eval(p3, cast_to=bytes).decode()
res4 = found_state.solver.eval(p4, cast_to=bytes).decode()
print(res1)
print(res2)
print(res3)
print(res4)4. 运行脚本查看结果

5. 验证结果正确性
![]()
边栏推荐
- 1、 Initial mysql, MySQL installation, environment configuration, initialization
- Yarn quick reference manual
- 复现 ASVspoof 2021 baseline RawNet2
- JDBC操作数据库详解
- 集合的创建,及常用方法
- 用户喜好
- Pytorch 通过 Tensor 某一维的值将 Tensor 分开的方法(简易)
- An ASP code that can return to the previous page and automatically refresh the page
- js加密参数定位
- 测试基本概念
猜你喜欢

切换 shell 命令行终端(bash/zsh)后,conda 无法使用: command not found

【专栏】RPC系列(理论)-夜的第一章

File upload function

Subtotal of rospy odometry sinkhole

UE4 LoadingScreen动态加载启动动画

@Import, conditional and @importresource annotations
![[necessary for growth] Why do I recommend you to write a blog? May you be what you want to be in years to come.](/img/f5/e6739083f0dce8da1d09d078321633.png)
[necessary for growth] Why do I recommend you to write a blog? May you be what you want to be in years to come.

VoxCeleb1 数据集下载

数据库MySQL详解

Probabilistic robot learning notes Chapter 2
随机推荐
复现 ASVspoof 2021 baseline RawNet2
File upload function
yarn速查手册
shortest-unsorted-continuous-subarray
广度优先遍历(图和二叉树的层序遍历相关问题)
GUI窗口
UE4源码的获取和编译
Basic knapsack problem
数论---最大公约数最小公倍数
拷贝过来老的项目变成web项目
Swing组件之单选与多选按钮
UE4 窗口控制(最大化 最小化)
VSCode Latex Workshop 设置 XeLatex 编译
Radio and multi selection buttons of swing components
Yarn quick reference manual
将 conda 虚拟环境 env 加入 jupyter kernel
RedisUtil
bug要素
[necessary for growth] Why do I recommend you to write a blog? May you be what you want to be in years to come.
NPM details