> 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/linux-easy/keeper-hackthebox-writeup.md).

# Keeper HackTheBox 详解

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

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

* 滥用 Request Tracker
* 信息泄露
* 通过内存转储获取 KeePass 密码（权限提升）
  {% endhint %}

## 侦察

**工作区设置：**

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

<figure><img src="/files/0fdea1328d35d7b559bf0f5657e05582f7b9208f" alt="" width="563"><figcaption></figcaption></figure>

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

<figure><img src="/files/4d5a601636d485c7c087b795b2de9a13d6e8feca" alt="" width="563"><figcaption></figcaption></figure>

**使用 Nmap 搜索开放端口：22.80**

```bash
nmap -p- --open -n -Pn -vvv --min-rate 5000 10.10.11.227 -oG allPorts 
```

<figure><img src="/files/2cce174f4251fc15f6515c96be67a5a408e94d89" alt=""><figcaption></figcaption></figure>

**使用 Nmap 扫描端口版本：** 使用 Nmap 扫描端口版本并将信息提取到“targeted”文件中：

```bash
nmap -sCV -p22,80 10.10.11.227 -oN targeted
```

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

### 80 端口

我们发现域名 **keeper.htb** 以及一个子域名 **tickets.keeper.htb**.

<figure><img src="/files/028d68e6ab81ff8ce1c59e0e9bac734e0860f98a" alt=""><figcaption></figcaption></figure>

我们把它们添加到 `/etc/hosts` 文件：

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

## Request Tracker CMS

访问 **tickets.keeper.htb** 我们发现一个管理面板。

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

我们测试 **Request Tracker**:

```plaintext
用户名：root  
密码：password  
```

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

连接成功！

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

在 **管理 → 用户** 部分中我们找到一个用户账户：

* 用户：<Inorgaard@keeper.htb>
* 密码：Welcome2023!

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

#### SSH 连接

我们使用找到的凭据通过 SSH 连接：

```bash
ssh Inorgaard@keeper.htb
```

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

### user.txt 标志 :)

<figure><img src="/files/36ff3cb40666b795648de53bb491082a9694f9ae" alt="" width="563"><figcaption></figcaption></figure>

## 权限提升

### **KeePass 数据库转储**

我们找到一个 ZIP 文件 `RT30000.zip` 并将其下载到我们的机器上：

```bash
python3 -m http.server 8080
```

```bash
wget http://10.10.11.227:8080/RT30000.zip
```

<figure><img src="/files/6a2a4765e354d034f5f4276f064d244c9c705f3e" alt=""><figcaption></figcaption></figure>

解压后，我们得到：

* **KeePassDumpFull.dmp**
* **passcodes.kdbx**

<figure><img src="/files/154b7b3a411f6431f4b3309eff70dcbfa359a1ae" alt=""><figcaption></figcaption></figure>

我们尝试打开 `passcodes.kdbx` 使用 KeePassXC：

```bash
keepassxc passcodes.kdbx
```

它要求输入密码。我们尝试使用 **John The Ripper**进行暴力破解，但未成功。

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

### **Keepass - 内存转储分析**

{% embed url="<https://github.com/matro7sh/keepass-dump-masterkey>" %}

我们利用 `.dmp` 带有 Python 脚本的文件：

```bash
python3 poc.py KeePassDumpFull.dmp
```

这会显示出无法辨认的字符。通过在线搜索，我们找到了一个可能的密码：

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

<figure><img src="/files/0750b0e21db6c1df601251ca3a1c803d3a6dd8e7" alt="" width="563"><figcaption></figcaption></figure>

**结果**：红色粥配奶油

<figure><img src="/files/45fedf778e24844d41c359afe37101b2045e400a" alt="" width="563"><figcaption></figcaption></figure>

我们使用这个密码解锁 KeePass，得到一个 **PuTTY 加密密钥和 root 密码**.

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

### 将 PuTTY 密钥转换为 OpenSSH 格式

我们需要将 PuTTY 密钥转换为 OpenSSH 格式：

```bash
puttygen key.ppk -O private-openssh -o id_rsa
```

接下来，确保你的私钥具有正确的权限：

```bash
chmod 600 id_rsa
```

#### **连接到 SSH 服务器**

```bash
ssh -i id_rsa root@10.10.11.227
```

<figure><img src="/files/270f5fa1b1ff155195de5edbc9541089c82756f4" alt=""><figcaption></figcaption></figure>

### root.txt flag :)

<figure><img src="/files/5fc09446a2e56056801a541c0d662844f5a89314" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/ebb921d4c82bdd6bcb8c897c16691eecd7fd4729" alt="" width="417"><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/linux-easy/keeper-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.
