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

# Blocky HackTheBox 详解

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

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

* WordPress 枚举
* 信息泄露
* 分析 jar 文件 - JD-Gui + SSH 访问
* 滥用 Sudoers 权限（提权）
  {% endhint %}

## 侦察

**工作区设置：**

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

<figure><img src="/files/25887ddbdf73f01dcf9942c00a1bd56e30108e51" alt=""><figcaption></figcaption></figure>

**VPN 连接检查**

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

<figure><img src="/files/46bfd392c9773784be0b0d1541dd10f5adf19e8c" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/31720de14da6665ab503b6b335f0defc338d7cf1" alt=""><figcaption></figcaption></figure>

**使用 extractport 对开放端口进行分析：** 使用 extractport 函数以图形方式显示开放端口并将其复制到剪贴板。（21.22.80,25565）

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

**使用 Nmap 扫描端口版本：** 使用 Nmap 扫描端口版本并将信息提取到“targeted”文件中：

```bash
nmap -sCV -p21,22,80,25565 10.10.10.37 -oN targeted
```

<figure><img src="/files/6da4a922ec3ea1e135eb11bffe52346d57d4b551" alt=""><figcaption></figcaption></figure>

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

### 80 端口

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

**使用 Gobuster 枚举目录：**

我们使用 **Gobuster** 以枚举目标机器 Web 服务器上的目录。

```bash
gobuster dir -u http://blocky.htb/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

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

我们发现了一个名为 **plugins**.

<figure><img src="/files/17a3e82ff407de080d118732efdbdd3a6497f52b" alt=""><figcaption></figcaption></figure>

**下载并解压 BlockyCore.jar 文件：**

我们下载 **BlockyCore.jar** 文件，它看起来像一个自定义插件。然后我们将其内容解压。

```java
jar xf BlockyCore.jar
```

#### 反编译 BlockyCore.class 文件

在解压后的文件中我们发现一个 **BlockyCore.class** 文件。我们使用 **javap** 对其内容进行检查

```bash
javap -c BlockyCore.class
```

我们找到了一组数据库凭据：

* **localhost**
* **root**
* **8YsqfCTnvxAUeduzjNSXe22**

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

#### 通过 PhpMyAdmin 访问数据库

使用提取出的凭据，我们登录到 **PhpMyAdmin** 并在数据库中发现一个包含名为 **notch**.

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

**通过 SSH 连接：**

我们使用该密码 **`8YsqfCTnvxAUeduzjNSXe22`** 用于用户 **notch** 并成功登录。

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

### User.txt 标志

<figure><img src="/files/07fdddf6fd2965b2f3c2cf55d112e6c5d6a66aa8" alt=""><figcaption></figcaption></figure>

## 权限提升

我们注意到该用户属于 **sudo** 组，这使我们能够使用 **sudo** 来提升我们的权限

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

**执行 sudo su 命令：**/ 我们运行以下命令以获得 root shell：

```bash
sudo su
8YsqfCTnvxAUeduzjNSXe22
```

### root.txt 标志：)

<figure><img src="/files/803515dfed1f6127854776ed7591775a5fd0d1f2" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/ce1b9522decbdbc87c71663593fcf66162799130" alt="" width="516"><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/blocky-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.
