泰山cms代码审计

UWI Lv4

源码:泰山内容管理系统 tarzan-cms: 一款JAVA版新技术栈的现代化开源CMS管理系统

任意文件任意路径上传

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@Slf4j
@UtilityClass
public class FileUploadUtil {

private final Pattern PATTERN = Pattern.compile("\\\\", Pattern.LITERAL);

public String uploadLocal(MultipartFile mf, String uploadPath) {
String res = "";
try {
String fileName = null;
String nowdayStr = new SimpleDateFormat("yyyyMMdd").format(new Date());
String uploadFullPath = uploadPath + File.separator + nowdayStr + File.separator;
File fileDir = new File(uploadFullPath);
// 创建文件根目录
if (!fileDir.exists() && !fileDir.mkdirs()) {
log.error("创建文件夹失败: {}", uploadFullPath);
return null;
}
// 获取文件名
String orgName = mf.getOriginalFilename();
fileName = orgName.substring(0, orgName.lastIndexOf('.')) + '_' + System.currentTimeMillis() + orgName.substring(orgName.indexOf('.'));

String savePath = fileDir.getPath() + File.separator + fileName;
File savefile = new File(savePath);
FileCopyUtils.copy(mf.getBytes(), savefile);
res = nowdayStr + File.separator + fileName;
if (res.contains("\\")) {
res = PATTERN.matcher(res).replaceAll(Matcher.quoteReplacement("/"));
}
} catch (IOException e) {
log.error(e.getMessage(), e);
}
return res;
}
}

发现没有过滤../

image-20250925134723419

image-20250925134756338

我们还可以对任意已经知道的路径进行内容覆盖

image-20250925134859306

image-20250925134922296

ssrf

image-20250926094504031

看看download函数具体干了啥

image-20250926094541732

感觉是可以ssrf的

看看parseUrl函数有无过滤一些东西

image-20250926094624843

再看看filterUrl函数 有个正则 不太懂正则问问gpt

image-20250926094721980

逐步解析

  1. https?://
    • 匹配 http://https://
  2. (\w|-)+
    • 匹配 域名的开头部分(例如 wwwsub-domain)。
    • \w = [A-Za-z0-9_],再加上 -
  3. (\.(\w|-)+)+
    • 匹配一个或多个 域名后缀部分(例如 .com.org.co.uk)。
  4. (/ ... )+
    • 表示 路径必须至少有一个斜杠 / 开头
    • 所以这个正则不会只匹配 http://example.com,必须带 /xxx 才算。
  5. 路径部分 \w+
    • 匹配 / 后的路径,如 /index
  6. (\?...)?
    • 可选的 查询参数部分
    • \?param=value&param2=value2 这种。
  7. 查询参数解析:
    • \w+=... → key=value 的格式。
    • (\w|%|-) → 值可以包含字母、数字、下划线、-%(支持 URL 编码)。
    • (\&\w+=...) → 允许多个参数用 & 连接。

举几个能匹配的例子 ✅

  • http://www.example.com/index
  • https://sub-domain.example.org/path/to/page
  • https://abc.xyz.com/page?key=value
  • http://test.com/path?param1=abc&param2=123
  • https://a-b_c.com/resource?name=Tom-Jerry&age=20

举几个匹配不到的例子 ❌

  • http://example.com (因为少了路径 /
  • ftp://example.com/file (不是 http/https)
  • https://example.com/page?param=value#fragment (不支持 #fragment
  • https://中文域名.cn/路径 (因为没支持 Unicode 中文)

image-20250926094820877

image-20250926094908422

yaml反序列化rce

image-20250926112432609

跟进

image-20250926112453230

继续跟进

image-20250926112510423

继续跟进

image-20250926112530175

配置号yaml

image-20250926112556493

打包成zip

image-20250926112609684

上传 可以看到确实有rmi的连接 但是不知道为啥就是没有出发计算器

image-20250926112624952

  • Title: 泰山cms代码审计
  • Author: UWI
  • Created at : 2025-09-25 13:01:12
  • Updated at : 2025-09-26 11:46:20
  • Link: https://nbwsws.github.io/2025/09/25/代码审计/泰山cms/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments