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

main函数逻辑为:首先读取输入input,之后用complex_function函数对输入进行逐字符处理,如果处理后的字符串与target字符串相等,则输出Good Job,否则输出Try again。
3. 编写脚本求解程序输出Good Job时对应的输入,避免探测输出Try again时的路径
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("./02")
init_state = p.factory.entry_state()
print(init_state)
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(found_state.posix.dumps(i))4. 运行脚本查看结果

5. 测试结果的正确性
![]()
03
1. 直接下载angr_ctf提供的ELF可执行文件03_angr_symbolic_registers
2. 用IDA静态分析汇编代码

在main函数中调用了get_user_input方法读取用户输入,之后调用complex_function_1、complex_function_2以及complex_function_3对输入进行处理,并根据结果输出Good Job或Try again。
查看get_user_input方法的汇编代码

可以看到get_user_input方法调用scanf函数读取了三个十六进制的参数。根据传参机制,三个参数依次保存在寄存器eax、ebx和edx中。
3. 编写脚本求解程序输出Good Job时对应的输入,可以指定符号执行从main函数调用get_user_input方法读取输入后开始,需要对寄存器进行部署。
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("./03")
start_addr = 08048980
init_state = p.factory.blank_state(addr=start_addr)
pass1 = claripy.BVS('pass1', 32)
pass2 = claripy.BVS('pass2', 32)
pass3 = claripy.BVS('pass3', 32)
init_state.regs.eax = pass1
init_state.regs.ebx = pass2
init_state.regs.edx = pass3
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)
res3 = found_state.solver.eval(pass3)
print("{:x} {:x} {:x}".format(res1, res2, res3))4. 运行脚本查看结果
![]()
5. 检查结果正确性
![]()
边栏推荐
猜你喜欢

Attention is all you need 论文精读笔记 Transformer

Reflection 反射

message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to connect to this MySQL server“

JDBC总结

史上最全面的UE4 文件操作,打开,读、写,增、删、改、查

Copy the old project into a web project

PyTorch 代码模板 (CNN)

Angr(五)——angr_ctf

message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to connect to this MySQL server“

Pow(x,n)
随机推荐
升级 GLIBC 2.29 checking LD_LIBRARY_PATH variable... contains current directory error 解决方案
Nodejs initial experience
软件测试笔记,测试用例设计
Yarn quick reference manual
多线程——Runnable接口,龟兔赛跑
Pow(x,n)
常用类的小知识
struct2的原理
JSP详解
The way of code neatness -- hit the pain point directly
多线程——Callable接口,lambda
NPM details
Bug分类和定级
多线程——静态代理模式
Exception handling exception
Vant problem record
微信小程序跳转其他小程序
Mouse monitor, Paintbrush
conda 配置深度学习环境 pytorch transformers
C3D模型pytorch源码逐句详析(三)