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 | Internal Server Error: java.lang.NumberFormatException: For input string: "''" |
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 | 200 OK |
所以,直接改回 GET
并增加 X-Custom-Ip-Authorization: 127.0.0.1
就可以绕过鉴权了。现在,需要给 Burp Suite 增加设置,让其自动为 HTTP 请求头增加新的字段,操作步骤如下:
- 点击
Proxy -> Options -> Match and Replace
- 点击
Add
增加规则 Type
选择Request header
,Match
留空,Replace
填写要增加的字段和值
接下来在 Burp 的浏览器就可以访问 /admin
页面了。在 Burp 的 HTTP history
中,默认显示的是原始请求,如果要查看修改后的请求,需要从 Original request
切换到 Auto-modified request
。
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 usercarlos
.
根据提示,尝试访问 .git
,发现存在 GIT 相关文件。
访问 /.git/COMMIT_EDITMSG
,返回 Remove admin password from config
,所以应该访问前一个版本就可以看到密码了。
使用 wget
下载这个 .git
目录:
1 | wget -r https://0a6000ed03a5aea18178e8be00230072.web-security-academy.net/.git/ |
通过 GIT 操作:
1 | git log |
之后,尝试使用 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 请求头中的字段信息