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

# Greenhorn HackTheBox Writeup

Greenhorn HackTheBox Easy Linux machine writeup covering Discovering embedded passwords in Git repositories, Unhashed SHA-512 passwords, Pluck Exploitation, Decrypting pixelated passwords (using DEPIX

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

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

* Discovering embedded passwords in Git repositories
* Unhashed SHA-512 passwords
* Pluck Exploitation
* Decrypting pixelated passwords (using DEPIX)
  {% 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-ad09c46bef316df08a6baefff7357a9a91f4c4f4%2Fimage%20(1433).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-f011d4a60b1d3b6f4f10236e0cc265058df159f1%2Fimage%20(1434).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.25 -oG allPorts
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2524ad68a1cdb5d08561994f37e55d367a038963%2Fimage%20(1435).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 (22,80,3000)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ef720d04004a034e6eb72f2721b8de31666fde15%2Fimage%20(1436).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,3000 10.10.11.25 -oN targeted
```

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

### **Password Discovery:**

On port 3000 we find a Git-like exposed service, similar to GitHub, but intended for internal corporate use

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

We proceed to create an account

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

Among the project files we find a file containing a password in "`pass.php`":

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

```
d5443aef1b64544f3685bf112f6c405218c573c7279a831b1fe9612e3a4d770486743c5580556c0d838b51749de15530f87fb793afdcc689b6b39024d7790163
```

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

This hash is in SHA512. After decryption, we obtain the password **`iloveyou1`**.

{% embed url="<https://10015.io/tools/sha512-encrypt-decrypt>" %}

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

## Pluck CMS Vulnerability

On port 80 we find a Pluck web service.

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

The `login.php` file requires a password to access the manager interface.

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

The content manager has a version `4.7.18`, vulnerable to remote code execution (RCE).

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

{% embed url="<https://github.com/Rai2en/CVE-2023-50564_Pluck-v4.7.18_PoC>" %}

### Fase d'exploitation:

1. Clone the repository containing the exploit script:

```bash
git clone https://github.com/Rai2en/CVE-2023-50564_Pluck-v4.7.18_PoC.git
cd CVE-2023-50564_Pluck-v4.7.18_PoC
```

2. We modify the `poc.py` script with the server IP address and the password "*iloveyou1*".

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

2. Next, create a `payload.zip` file containing the malicious payload, with the `<your_ip>` and port fields adjusted to match our listener.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5b26d0dadbe511e590433dc410a25dae2bd1f3f9%2Fimage%20(1429).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-bd9c3fb2f69f34eaef8d43f6f3d923d372439ea4%2Fimage%20(1430).png?alt=media" alt="" width="512"><figcaption></figcaption></figure>

5. We run the exploitation script:

```bash
python poc.py

/home/jordan/......./payload.zip
```

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

At the same time, we open a listening session on port `4444` with Netcat and gain access to the server as user `www-data`.

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

By inspecting the `/etc/passwd` file, we discover the user "junior". We succeed in connecting with the password **iloveyou1**:

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

### user.txt Flag Obtained:

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

## Privilege Escalation

1. We locate the PDF file: `Using OpenVAS.pdf`.
2. Transfer the file using Python 3 by running:

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

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

3. We download the PDF file with the following command:

<pre class="language-bash"><code class="lang-bash"><strong>wget http://10.10.11.25:1234/Using%20OpenVAS.pdf
</strong></code></pre>

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

When opening this file, we discover the pixelated password for the administrator account

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

### Password decryption:

To crack the hidden password, we use Depix software:

{% embed url="<https://github.com/spipm/Depix>" %}

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

```bash
git clone https://github.com/spipm/Depix
cd Depix
```

Next, we execute the command:

```bash
python3 depix.py /
    -p pixel.png /
    -s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png /
    -o /home/jordan/Desktop/password.png
```

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

The decrypted password is:

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

`sidefromsidetheothersidesidefromsidetheotherside`

We log in as root user with this password.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5e0a4e6c563fe4021e0dd702087cae3341198d7f%2Fimage%20(2262).png?alt=media" alt="" width="554"><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-3851a82e92446fb53e44e2ccb4036f9d60d0faa4%2Fimage%20(2263).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-2d5fe1ed09ec259167b595fb44f9b90edf2b142b%2Fimage%20(1418).png?alt=media" alt="" width="563"><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/greenhorn-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.
