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

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

**VPN 连接检查**

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

<figure><img src="/files/620ae8ca9897bfce2e53507d19b8701fd078d892" 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="/files/2513872fc35b2b856046ef95e913b242a73c9a26" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

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

<figure><img src="/files/23ea5df1382519a79f52755d5936e857ec60a496" alt=""><figcaption></figcaption></figure>

要通过 DNS 将域名解析为 IP 地址，请将与其 IP 地址关联的域名插入到 `/etc/hosts` 文件中的用户进行测试。

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

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

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

<figure><img src="/files/599527d7532a333cbeb6019b8eddeb499081bf6d" alt=""><figcaption></figcaption></figure>

我们继续创建一个账户

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

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

<figure><img src="/files/473f2137d42fe18e85eef374010735606003af4b" alt=""><figcaption></figcaption></figure>

```
d5443aef1b64544f3685bf112f6c405218c573c7279a831b1fe9612e3a4d770486743c5580556c0d838b51749de15530f87fb793afdcc689b6b39024d7790163
```

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

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

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

<figure><img src="/files/06b5e71879d9cb7518c6a0710e22595db6cc9b53" alt=""><figcaption></figcaption></figure>

## Pluck CMS 漏洞

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

<figure><img src="/files/51ce10d7df019b76135a4b467b131958becf0edf" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/745a3a4ce922eb1ae2479090c1fa8e1ca0d574f9" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/82d9d7f32c51be097a68e3b57b23cb0889a2fb05" 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="/files/bb1189079a5f203d5ebfff31544601f59bc971d5" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/07f026db151b1936d746cc2a9f33af2236517a46" alt="" width="512"><figcaption></figcaption></figure>

5. 我们运行利用脚本：

```bash
python poc.py

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

<figure><img src="/files/2734d1330ed5e4f6a7e019ae6c5edb590daae13e" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/38fe717f05a0934f9b5a40bcd0eadbbe14ffc002" alt=""><figcaption></figcaption></figure>

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

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

### 已获得 user.txt 标志：

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

## 权限提升

1. 我们找到 PDF 文件： `使用 OpenVAS.pdf`.
2. 通过运行以下命令使用 Python 3 传输文件：

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

<figure><img src="/files/a80364ee3fcf4fe38de916a333ab85af9a8bd4e1" 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="/files/53d7de2cbd36d436f8daa99025140839cc199a16" alt=""><figcaption></figcaption></figure>

打开此文件时，我们发现管理员账户的像素化密码

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

### 密码解密：

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

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

<figure><img src="/files/4e45d8493ddba25e654ba318267aea09382d7d98" 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="/files/973beeb4b47ee5000c82f54381aac61bb8af9563" alt=""><figcaption></figcaption></figure>

解密后的密码是：

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

`sidefromsidetheothersidesidefromsidetheotherside`

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

<figure><img src="/files/3cd9ce0834feb069ed6ad0220438cf776b272f43" alt="" width="554"><figcaption></figcaption></figure>

### root 的 flag :)

<figure><img src="/files/1effb661d5b0ded15dd3d15521b4ea12ef990ee5" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/561703846203badb1736e2bb920f15e3fcdaafae" 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 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/greenhorn-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.
