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

# Mirai HackTheBox 详解

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

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

* 识别一台 IoT 设备
* 取证文件恢复
  {% endhint %}

## 侦察

**工作区设置：**

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

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

**VPN 连接检查**

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

<figure><img src="/files/484f81eed5a1f8d359bd7c73318a2a93830e9ad0" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

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

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

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

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

```bash
nmap -sCV -p22,53,80,1178,32400,32469 10.10.10.48 -oN targeted
```

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

## 80 端口 - Pi-hole

扫描 80 端口时，Wappalyzer 工具没有显示任何有价值的信息。

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

然而，经过一点模糊测试后，我们发现一个目录“`admin`”，它与 Pi-hole 相关，包含一个登录面板。

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

然后我们在互联网上搜索默认凭据，并找到以下信息：

* **用户：** pi
* **密码：** raspberry

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

由于 22 端口开放，我们尝试通过 SSH 连接：

```bash
ssh pi@10.10.10.48
```

连接成功。

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

### user.txt 旗标

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

## **权限提升：**

**Sudo 组：** 检查用户组后，我们看到用户“pi”属于 sudo 组。由于我们已经知道它的密码，因此可以获得 root 权限。

```bash
id
```

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

接下来，我们运行 `sudo su` 并输入用户“pi”的密码：

```bash
sudo su
```

### root.txt 标志

**root.txt 文件的恢复：** 攻击者告诉我们，他丢失了 `root.txt` 该文件，并且我们必须在 U 盘备份中查找它。

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

我们搜索已连接的 USB 设备，并找到一个 `/dev/sdb` 磁盘

```bash
df -h 
```

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

当尝试直接读取这个磁盘时，数据不可读。不过，在使用 `strings` 命令后，我们能够从该设备中恢复可读信息：

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

```bash
strings /dev/sdb
```

<figure><img src="/files/842a5725983e830536f11c995dc4527df24db791" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/63dbb63f09f3e8a6853ee188a7dbdeee338a71a6" alt="" width="530"><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/mirai-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.
