> 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-easy/mirai-hackthebox-writeup.md).

# Mirai HackTheBox攻略記事

IoTデバイスの特定、フォレンジックによるファイル復旧を扱うMirai HackTheBox Easy Linuxマシンの攻略記事。実践的な列挙、侵入、足掛かり、権限昇格のメモ付き。

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

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

* IoT デバイスの特定
* フォレンジックファイルの復旧
  {% 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-af4bfc4f7562c78765f9c16b46170a62afbdfcaa%2Fimage%20(982).png?alt=media" alt=""><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-d2dfdea2d662c18f04fa94f8eb2f8e516fb7735b%2Fimage%20(983).png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

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

**extractPorts による開いているポートの分析:**

extractPorts 関数を使って、開いているポートを簡潔な形式で表示し、クリップボードにコピーします (22,53,80,1178,32400,32469)

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

Nmap によるポートのバージョンスキャン:

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

```bash
nmap -sCV -p22,53,80,1178,32400,32469 10.10.10.48 -oN targeted
```

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

## ポート 80 - Pi-hole

ポート 80 をスキャンしても、Wappalyzer ツールは重要な情報を何も示しません。

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

しかし、少しファジングを行った後、ディレクトリ「`admin`」を発見しました。これは Pi-hole に関連しており、ログインパネルを含んでいます。

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

そこで、デフォルトの認証情報をインターネットで検索し、次の情報を見つけます:

* **ユーザー:** pi
* **パスワード:** raspberry

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

ポート 22 が開いているため、SSH 経由で接続を試みています:

```bash
ssh pi@10.10.10.48
```

接続に成功しました。

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

### user.txtフラグ

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

## **権限昇格：**

**Sudo グループ:** ユーザーグループを確認すると、ユーザー「pi」が sudo グループに属していることがわかります。すでにパスワードを知っているので、root 権限を取得できます。

```bash
id
```

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

次に、 `sudo su` を実行し、ユーザー「pi」のパスワードを入力します:

```bash
sudo su
```

### root.txt フラグ

**root.txt ファイルの復旧:** 攻撃者は、 `root.txt` ファイルを紛失したので、USB キーのバックアップの中から探す必要があると伝えてきます。

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

接続されている USB デバイスを検索し、 `/dev/sdb` ディスク

```bash
df -h 
```

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

このディスクを直接読み取ろうとすると、データは判読不能です。しかし、 `strings` コマンドを使った後は、デバイスから読み取り可能な情報を復旧できます:

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

```bash
strings /dev/sdb
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d7c843813e19430b9fefb27f076c3562337adfbd%2Fimage%20(996).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-ee2704119fe1a89dc3d5f9dfb41d14f663745cbc%2Fimage%20(997).png?alt=media" alt="" width="530"><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-easy/mirai-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.
