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

# Greenhorn HackTheBox 复盘

Greenhorn HackTheBox 简单 Linux 机器复盘，涵盖在 Git 仓库中发现嵌入式密码、未加哈希的 SHA-512 密码、Pluck 利用、解密像素化密码（使用 DEPIX

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

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

* 在 Git 仓库中发现嵌入的密码
* 未哈希的 SHA-512 密码
* Pluck 利用
* 解密像素化密码（使用 DEPIX）
  {% endhint %}

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

**工作区设置：**

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

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

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

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

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

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

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

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

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

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

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

```bash
nmap -sCV -p80,22,3000 10.10.11.25 -oN targeted
```

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

### **密码发现：**

在 3000 端口上我们发现了一个类似 Git 的暴露服务，类似于 GitHub，但供企业内部使用

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

在项目文件中，我们找到一个包含密码的文件，位于“`pass.php`":

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

```
d5443aef1b64544f3685bf112f6c405218c573c7279a831b1fe9612e3a4d770486743c5580556c0d838b51749de15530f87fb793afdcc689b6b39024d7790163
```

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

这个哈希是 SHA512。解密后，我们得到密码 **`iloveyou1`**.

{% embed url="<https://10015.io/tools/sha512-encrypt-decrypt>" %}

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

## Pluck CMS 漏洞

在 80 端口上我们发现了一个 Pluck Web 服务。

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

该 `login.php` 该文件需要密码才能访问管理界面。

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

该内容管理器的版本为 `4.7.18`，存在远程代码执行（RCE）漏洞。

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

{% embed url="<https://github.com/Rai2en/CVE-2023-50564_Pluck-v4.7.18_PoC>" %}

### 利用阶段：

1. 克隆包含利用脚本的仓库：

```bash
git clone https://github.com/Rai2en/CVE-2023-50564_Pluck-v4.7.18_PoC.git
cd CVE-2023-50564_Pluck-v4.7.18_PoC
```

2. 我们修改 `poc.py` 脚本，填入服务器 IP 地址和密码“*iloveyou1*".

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

2. 接下来，创建一个 `payload.zip` 包含恶意载荷的文件，并将 `<your_ip>` 和端口字段调整为与我们的监听器匹配。

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

5. 我们运行利用脚本：

```bash
python poc.py

/home/jordan/......./payload.zip
```

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

同时，我们在端口上打开一个监听会话 `4444` ，使用 Netcat 并以用户身份获得服务器访问权限 `www-data`.

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

通过检查 `/etc/passwd` 文件，我们发现用户“junior”。我们成功使用密码连接 **iloveyou1**:

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

## 权限提升

1. 我们找到该 PDF 文件： `使用 OpenVAS.pdf`.
2. 使用 Python 3 传输文件，运行：

```bash
python3 -m http.server 1234
```

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

3. 我们使用以下命令下载 PDF 文件：

<pre class="language-bash"><code class="lang-bash"><strong>wget http://10.10.11.25:1234/Using%20OpenVAS.pdf
</strong></code></pre>

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

### 密码解密：

要破解隐藏的密码，我们使用 Depix 软件：

{% embed url="<https://github.com/spipm/Depix>" %}

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

```bash
git clone https://github.com/spipm/Depix
cd Depix
```

接下来，我们执行命令：

```bash
python3 depix.py /
    -p pixel.png /
    -s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png /
    -o /home/jordan/Desktop/password.png
```

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

`sidefromsidetheothersidesidefromsidetheotherside`

我们使用这个密码以 root 用户身份登录。

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

### root 的 flag :)

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3851a82e92446fb53e44e2ccb4036f9d60d0faa4%2Fimage%20(2263).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-2d5fe1ed09ec259167b595fb44f9b90edf2b142b%2Fimage%20(1418).png?alt=media" alt="" width="563"><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/greenhorn-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.
