Information Disclosure Writeup

PortSwigger

Author:

  • Pham Quoc Trung

Used Tools:

  • BurpSuite

Problems Solving:

Lab: Information disclosure in error messages

Description:

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.

Solution:

Ở bài này, mục tiêu là mình phải lấy được version của Apache thông qua việc trigger lỗi. Để ý khi ấn vào 1 sản phẩm mình sẽ có request response như sau

Mình thử thay productID thành 1 số cực lớn

Có vẻ không có lỗi gì xảy ra. Lần này thì thay vì số, mình sẽ điền một thứ gì đó khác xem sao

Đã có lỗi xảy ra và response trả về mã 500, cũng như mình đã thấy được phiên bản của Apache được lộ ra. Giờ chỉ cần submit là mình sẽ hoàn thành bài lab

Lab: Information disclosure on debug page

Description:

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.

Solution:

Với bài này thì đề bài yêu cầu mình tìm ra giá trị của biến môi trường SECRET_KEY. Khi tấn công như bài trước thì không có gì thú vị xảy ra

Thử nhìn vào code front-end của trang web, mình thấy có đoạn comment như sau

Truy cập vào /cgi-bin/phpinfo.php, mình thấy được một trang in ra nội dung của hàm phpinfo() trong PHP, thứ mà sẽ chứa rất nhiều thông tin về trang web và server.

Kéo xuống tìm mục Environments\text{Environments}, mình sẽ thấy giá trị các biến môi trường của trang web

Và mình cũng nhìn thấy giá trị cần tìm của biến SECRET_KEY. Submit để hoàn thành bài lab này

Lab: Source code disclosure via backup files

Description:

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.

Solution:

Mục tiêu của chúng ta là phải tìm được password của database. Với bài này thì các request response trên trang chủ đều không thu được gì hay ho. Mình sẽ thử vào /robots.txt xem có đường dẫn nào hay không

Ở đây mình thấy có thư mục /backup. Thử truy cập vào coi sao

Mình thu được một file có đuôi .bak, đuôi của các file backup. Dựa vào tên thì mình nghĩ đây là file backup của template của trang web này. Dưới đây là nội dung của file này

Đọc code, mình thấy được đoạn để kết nối tới database cũng như password của database trong đó. Sử dụng để submit, mình hoàn thành bài lab

Lab: Authentication bypass via information disclosure

Description:

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

Solution:

Ở bài này, khi mình đăng nhập vào wiener và thử vào /admin, đây là lỗi xảy ra

Mục tiêu là phải bypass được việc này để có thể truy cập vào admin panel để xóa tài khoản của carlos. Dựa trên đề bài, có vẻ cơ chế authen này sử dụng một custom HTTP Header của server. Mình sẽ thử sử dụng HTTP Method TRACE để xem request phía server sẽ ra sao. Điều này sẽ hoạt động nếu server đang bật debug mode

Dựa trên response trả về, mình thấy có header X-Custom-IP-Authorization sử dụng để authorzize địa chỉ IP. Để ý lại mã lỗi trả về khi truy cập /admin, mình phải là local user\text{local user} để có thể truy cập. Kết hợp hai dữ kiện trên, mình sẽ thử thêm header X-Custom-IP-Authorization với giá trị là 127.0.0.1 hoặc localhost khi gửi request GET tới /admin xem sao

Với 127.0.0.1, mình đã có thể truy cập vào admin panel. Tiến hành xóa user carlos để hoàn thành bài lab

Lab: Information disclosure in version control history

Description:

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.

Solution:

Dựa trên đề bài, có vẻ trang web này sử dụng version control system, phổ biến nhất có thể nghĩ tới Git\text{Git}. Mình sẽ thử truy cập vào /.git để kiểm tra

Có vẻ đúng như mình dự đoán. Để có thể thao tác với đống này mình sẽ cần một chút kiến thức về Git\text{Git}. Có thể thẩm qua video sau: Link

Đầu tiên mình sẽ phải down thư mục này về máy

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

Sử dụng lệnh git log để xem lịch sử các commit

Ở đây mình thấy có dòng Remove admin password from config.\text{Remove admin password from config}. Có vẻ ban đầu trong config có chứa mật khẩu admin. Mình sẽ sử dụng lệnh git diff để so sánh sự khác nhau giữa 2 commit

Có thể thấy, mình đã thu được admin password trước khi bị remove. Giờ chỉ cần đăng nhập vào administrator và xóa đi user carlos là mình sẽ hoàn thành được bài lab cuối này

© 2024,Pham Quoc Trung. All rights reserved.

Last updated