当前位置:网站首页>Angr(六)——angr_ctf
Angr(六)——angr_ctf
2022-07-25 09:27:00 【c1rcl3】
通过angr_ctf熟悉angr的使用方法
参考链接:
08
1. 直接下载angr_ctf提供的ELF可执行文件08_angr_constraints
2. 用IDA静态分析

main函数调用scanf读取16字节的字符串输入至缓冲区buffer,然后调用complex_function函数对输入进行处理。最后调用check_equals_AUPDNNPROEZRJWKB完成逐字符的字符串比较,并根据结果相应输出。
3. 编写脚本求解程序输出Good Job时对应的输入,为了避免字符串比较函数造成路径爆炸,可以避免对check部分的逻辑进行符号执行
import angr
import claripy
p = angr.Project("./08")
start_addr = 0x8048625
check_addr = 0x8048565
init_state = p.factory.blank_state(addr=start_addr)
pass_addr = 0x804A050
pass = claripy.BVS('pass', 16 * 8)
init_state.memory.store(pass_addr, pass)
sm = p.factory.simulation_manager(init_state)
sm.explore(find=check_addr)
for i in range(0, len(sm.found)):
found_state = sm.found[i]
target = "AUPDNNPROEZRJWKB".encode()
param1 = pass_addr
param2 = 16
bvt = found_state.memory.load(param1, param2)
found_state.add_constraints(bvt == target)
res = found_state.solver.eval(pass, cast_to=bytes).decode()
print(res)4. 运行脚本查看结果
![]()
5. 检查结果的正确性
![]()
09
1. 直接下载angr_ctf提供的ELF可执行文件09_angr_hooks
2. 用IDA静态分析

main函数逻辑可以分为两部分:
第一部分:首先读取一个16字符的字符串至缓冲区buffer中,之后调用complex_function函数对buffer中的内容进行逐字符处理,最后将处理后的buffer中的内容与password缓冲区中的字符串进行比较。
第二部分:再次读取一个16字符的字符串至缓冲区buffer中,之后调用complex_function函数对password中的内容进行逐字符处理,最后将处理后的password中的内容与buffer中的字符串进行比较。
3. 编写脚本求解程序输出Good Job时对应的输入,为了避免字符串比较函数造成路径爆炸,可以对check函数进行hook,不进行符号执行
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("./09")
check_addr = 0x80486B3
skip_size = 5
init_state = p.factory.entry_state()
@p.hook(check_addr, length=skip_size)
def check_hook(state):
pass_addr = 0x804A054
pass_size = 0x10
bvt = state.memory.load(pass_addr, pass_size)
target = "XYMKBKUHNIQYNQXE".encode()
state.regs.eax = claripy.If(target == bvt, claripy.BVV(1, 32), claripy.BVV(0, 32))
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]
print("{}".format(found_state.posix.dumps(0)))4. 运行脚本查看结果

5. 验证结果的正确性
![]()
边栏推荐
猜你喜欢

Reflection 反射

Trojaning Attack on Neural Networks 论文阅读笔记

UE4 LoadingScreen动态加载启动动画

JS uses requestanimationframe to detect the FPS frame rate of the current animation in real time

UE4 窗口控制(最大化 最小化)

Redis使用场景

DHCP的配置(以华为eNSP为例)

ROS distributed operation -- launch file starts nodes on multiple machines

UE4 快速找到打包失败的原因
![[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.
随机推荐
Redis使用场景
Redis和MongoDB的区别
数论--负进制转换
Swing component
多线程——Runnable接口,龟兔赛跑
Set creation and common methods
OSPF协议的配置(以华为eNSP为例)
Debug篇快捷键入门
力扣刷题组合问题总结(回溯)
struct2的原理
IO流中的输出流
多线程——Callable接口,lambda
JDBC总结
记录一些JS工具函数
Loam transformtoend function integrating IMU details
Download and installation of QT 6.2
See how a junior student of double non-2 (0 Internship) can get an offer from Alibaba and Tencent
UE4 快速找到打包失败的原因
数据库MySQL详解
鼠标监听,画笔