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

# Greenhorn HackTheBox攻略記事

Gitリポジトリ内の埋め込みパスワードの発見、ハッシュ化されていないSHA-512パスワード、Pluck悪用、ピクセル化されたパスワードの復号（DEPIXを使用）を扱うGreenhorn HackTheBox Easy Linuxマシンの攻略記事。

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

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

* Gitリポジトリ内に埋め込まれたパスワードの発見
* ハッシュ化されていない SHA-512 パスワード
* Pluckのエクスプロイト
* モザイク化されたパスワードの復号（DEPIXを使用）
  {% endhint %}

## 偵察 <a href="#reconnaissance" id="reconnaissance"></a>

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

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

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

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

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

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

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

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

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

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

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

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

```bash
nmap -sCV -p80,22,3000 10.10.11.25 -oN targeted
```

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

DNS 経由でドメイン名を IP アドレスに解決するには、その IP アドレスに関連付けられたドメイン名を次の `/etc/hosts` ファイルに存在するユーザーに対して試します。

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

### **パスワードの発見:**

3000番ポートでは、GitHubに似たGit風の公開サービスが見つかるが、社内企業利用向けである

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

プロジェクトファイルの中に、"`pass.php`":

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

```
d5443aef1b64544f3685bf112f6c405218c573c7279a831b1fe9612e3a4d770486743c5580556c0d838b51749de15530f87fb793afdcc689b6b39024d7790163
```

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

このハッシュは SHA512 です。復号後、パスワードを取得する **`iloveyou1`**.

{% embed url="<https://10015.io/tools/sha512-encrypt-decrypt>" %}

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

## Pluck CMS の脆弱性

80番ポートでは、PluckのWebサービスが見つかる。

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

その `login.php` このファイルには、マネージャーインターフェースにアクセスするためのパスワードが必要です。

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

コンテンツマネージャーのバージョンは `4.7.18`、リモートコード実行（RCE）の脆弱性があります。

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

{% embed url="<https://github.com/Rai2en/CVE-2023-50564_Pluck-v4.7.18_PoC>" %}

### エクスプロイト段階:

1. エクスプロイトスクリプトを含むリポジトリをクローンする:

```bash
git clone https://github.com/Rai2en/CVE-2023-50564_Pluck-v4.7.18_PoC.git
cd CVE-2023-50564_Pluck-v4.7.18_PoC
```

2. 次に、 `poc.py` スクリプトをサーバーのIPアドレスとパスワード「*iloveyou1*".

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

2. 次に、 `payload.zip` 悪意のあるペイロードを含むファイルを作成し、 `<your_ip>` とポートの欄をリスナーに合わせて調整する。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5b26d0dadbe511e590433dc410a25dae2bd1f3f9%2Fimage%20(1429).png?alt=media" alt="" width="563"><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-bd9c3fb2f69f34eaef8d43f6f3d923d372439ea4%2Fimage%20(1430).png?alt=media" alt="" width="512"><figcaption></figcaption></figure>

5. エクスプロイトスクリプトを実行する:

```bash
python poc.py

/home/jordan/......./payload.zip
```

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

同時に、ポート `4444` でNetcatの待ち受けセッションを開き、ユーザー `www-data`.

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

を確認すると、 `/etc/passwd` ファイルから、ユーザー「junior」が見つかる。パスワードでの接続に成功する **iloveyou1**:

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5159badd77248f01a548d4c8894c15212472af3c%2Fimage%20(1419).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-ffa17b1c6919f979a844301ffa20359f14fe9428%2Fimage%20(2255).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## 権限昇格

1. PDFファイルを見つけます： `OpenVAS.pdf を使用`.
2. Python 3 を使ってファイルを転送するには、次を実行する:

```bash
python3 -m http.server 1234
```

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

3. 次のコマンドで PDF ファイルをダウンロードする:

<pre class="language-bash"><code class="lang-bash"><strong>wget http://10.10.11.25:1234/Using%20OpenVAS.pdf
</strong></code></pre>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6b56a6a461a206bcf56dff03b6c269ea0f924a60%2Fimage%20(2257).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-57a695e108752fb9dafcf8038e841ac43f4612d9%2Fimage%20(2258).png?alt=media" alt=""><figcaption></figcaption></figure>

### パスワードの復号：

隠されたパスワードを解析するために、Depixソフトウェアを使用します：

{% embed url="<https://github.com/spipm/Depix>" %}

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

```bash
git clone https://github.com/spipm/Depix
cd Depix
```

次に、次のコマンドを実行する:

```bash
python3 depix.py /
    -p pixel.png /
    -s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png /
    -o /home/jordan/Desktop/password.png
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9e3f95cd8ecd3b56616252df4b134e1b2b6ec612%2Fimage%20(2260).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-585b2b71b3e9b74a0b16d3b664e6dfefd3be931b%2Fimage%20(2265).png?alt=media" alt=""><figcaption></figcaption></figure>

`sidefromsidetheothersidesidefromsidetheotherside`

このパスワードで root ユーザーとしてログインします。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5e0a4e6c563fe4021e0dd702087cae3341198d7f%2Fimage%20(2262).png?alt=media" alt="" width="554"><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-3851a82e92446fb53e44e2ccb4036f9d60d0faa4%2Fimage%20(2263).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-2d5fe1ed09ec259167b595fb44f9b90edf2b142b%2Fimage%20(1418).png?alt=media" alt="" width="563"><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/greenhorn-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.
