# HTB | Sea

This is a Linux box. You can find it [here](https://app.hackthebox.com/machines/Sea).

**Skill Learned**

* CVE-2023-41425
* Port Forwarding
* Unauthenticated Information leak & command Injection

## NMAP

IP:10.10.11.28

```
nmap -sT -p- --min-rate 10000 10.10.11.28
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F9BYk95sHQiq396sGxLeo%2Fimage.png?alt=media&#x26;token=9d774ba6-4951-48c6-96de-fa2ef7c68cd1" alt=""><figcaption></figcaption></figure>

```
nmap -sC -sV -p 22,80 10.10.11.28
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FUZnlTlIko9nVjoi8gVmB%2Fimage.png?alt=media&#x26;token=f049d148-2176-422d-98e0-9cb670137da8" alt=""><figcaption><p>nmap</p></figcaption></figure>

### Port 80

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F468RUKDotzZFj5qe468N%2Fimage.png?alt=media&#x26;token=88ee0912-72f2-4813-8142-ac48c2201255" alt=""><figcaption><p>Port 80</p></figcaption></figure>

Let's do a directory search on the website

```
dirsearch -u http://10.10.11.28/ -x 403,404
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FRlegdU1KdXcETvI9ssvZ%2Fimage.png?alt=media&#x26;token=c23ee378-9ed0-41c9-82bb-06c053f4e756" alt=""><figcaption><p>dirsearch</p></figcaption></figure>

when enumerating /themes further using fuff&#x20;

```
ffuf -c -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-medium-directories.txt -u "http://sea.htb/themes/FUZZ" -t 200
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FHEyrYbEjDLTwiQOVNxGy%2Fimage.png?alt=media&#x26;token=5b94c690-e884-47f5-a297-2ff78c51774b" alt=""><figcaption><p>ffuf /themes</p></figcaption></figure>

when enumerating /themes/bike further using fuff&#x20;

```
ffuf -c -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-medium-directories.txt -u "http://sea.htb/themes/bike/FUZZ" -t 200 -fc 403
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FOkx7KC5ANeRPgybHhvPv%2Fimage.png?alt=media&#x26;token=fe2ea253-0dfd-420d-917f-71dfb347384d" alt=""><figcaption><p>ffuf /themes/bike</p></figcaption></figure>

on visiting `/themes/bike/version` it gives us version **3.2.0**

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FOmDhlaxx5AhPWFyzRiKu%2Fimage.png?alt=media&#x26;token=b6779c5a-4a39-47f6-af8f-10e626ffcb09" alt=""><figcaption><p>/version</p></figcaption></figure>

on visiting `/themes/bike/README.md` it downloads the readme file, further analysing the file we found CMS - **WonderCMS**

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2Fr3GwqrLRC7Z2YHlSRYLE%2Fimage.png?alt=media&#x26;token=b09da925-5da9-4b1e-a846-aa1a82a49890" alt=""><figcaption><p>readme.md</p></figcaption></figure>

## Foothold/shell

### CVE-2023-41425

On googling the Wonder CMS exploit for version 3.2.0 we found [this](https://github.com/thefizzyfish/CVE-2023-41425-wonderCMS_RCE) GitHub[ ](https://github.com/thefizzyfish/CVE-2023-41425-wonderCMS_RCE)repo.

Download the Python script run it with proper argument values and Simultaneously start the NC listener

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FCyNu8KcboOwGLF30FfkM%2Fimage.png?alt=media&#x26;token=36f214d9-fc3e-454a-9255-9abde3690c1a" alt=""><figcaption><p>CVE-2023-41425.py</p></figcaption></figure>

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FMjaYSE8NoHYPt2WnS44Y%2Fimage.png?alt=media&#x26;token=9ee40a2a-c7b8-454a-b36f-2880504980e5" alt=""><figcaption><p>nc -nlvp 4444</p></figcaption></figure>

After getting the shell we were not able to find the user.txt.

On looking we found the password in database.js

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FGiKtr9LXuhtmAEbnYShg%2Fimage.png?alt=media&#x26;token=6d8d1f0f-83c4-4bcf-b575-f6509eda1c98" alt=""><figcaption><p>database.js</p></figcaption></figure>

We found the password but it is in the format used by bcrypt(refer [hashcat examples](https://hashcat.net/wiki/doku.php?id=example_hashes)),&#x20;

* $2y$: it is a prefix, which is a variant of bcrypt
* $10$: Indicates the cost parameter, determining how computationally difficult the hashing process is.
* The next 22 characters are the salt.
* The rest of the string after the salt is the actual hashed password.

To crack the hash, we just need to remove those slash escapers. Then use Hashcat with mode 3200, we have a password:&#x20;

```
hashcat -m 3200 hash.txt /home/anurag/stuff/rockyou.txt
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FCsLMbNqEAXbeW9oKANAa%2Fimage.png?alt=media&#x26;token=6a1163ba-d93d-4a7b-b962-ed3590491746" alt=""><figcaption><p>hashcat</p></figcaption></figure>

Now we will ssh with the password we just cracked and we are in the server. We also found **users.txt.**

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FtX95PEFo9BwOU59d02Q8%2Fimage.png?alt=media&#x26;token=9ef79ded-9279-44bc-baa8-0bddf154b60c" alt=""><figcaption><p>user.txt</p></figcaption></figure>

## Priv Esc

We will run `netstat -ano` to see all the socket(port) communication. We see port 8080 is hosting something.

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2Fogjo4RknTqW9v9papBO1%2Fimage.png?alt=media&#x26;token=a221265c-4e4d-40fa-8168-cd95781ee7d8" alt=""><figcaption><p>netstat -ano</p></figcaption></figure>

Let's do local port forwarding for 8080 So that we can access it via localhost

```
ssh -L 8888:localhost:8080 amay@10.10.11.28
```

### Unauthenticated information leak & Command Injection

Now let's visit `localhost:8888`&#x20;

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FOvS35s94dEHfJ3QOUD0c%2Fimage.png?alt=media&#x26;token=72cbcc28-8659-403a-8bae-c4c1a4248530" alt=""><figcaption><p>localhost:8888</p></figcaption></figure>

on using amay's password we were able to login

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FM2FkA6YADypQQpu0gbDU%2Fimage.png?alt=media&#x26;token=f2241b58-7084-4b59-99e0-93ba0637c7a1" alt=""><figcaption><p>port 8080</p></figcaption></figure>

This looks like some monitoring software. We can see the Analyze log file option when we click analyze for access.log we were able to see logs

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FL0iKdX6cOr5ryu6AaRnt%2Fimage.png?alt=media&#x26;token=991a2f7f-bbc1-4ec0-afe2-f5a19fc1f453" alt=""><figcaption><p>access.log</p></figcaption></figure>

There is another option besides access.log and that is auth.log, when looking at the auth.log we saw

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2Fc6zyza6SNAQQI1dm7VJj%2Fimage.png?alt=media&#x26;token=c0f6c132-344e-4a7a-9762-7045b2f8a00f" alt=""><figcaption><p>auth.log</p></figcaption></figure>

Let's spin up the burpsuite and look at the request again.We found a post-request for `log_file=/var/log/apache2/access.log`

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FMf09VjcjwZZLTB0My9RZ%2Fimage.png?alt=media&#x26;token=d1596e37-887c-411d-a551-819b7698c556" alt=""><figcaption><p>burp</p></figcaption></figure>

we also confirmed that accessing `/var/log/apache2` root permission is needed, which implies unauthenticated information leak

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F3BVqSphGsGZM6BYpEdXa%2Fimage.png?alt=media&#x26;token=d49e5b3e-1bf4-4991-b376-1f884fdeb3b1" alt=""><figcaption></figcaption></figure>

let's try command injection

when trying to read /root/root.txt it gives 'No suspicious traffic patterns detected in /root/root.txt.' maybe there is some filtering

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FSV1AM03DhHc1jOxU0Xwl%2Fimage.png?alt=media&#x26;token=bac3e73a-37be-4b41-813f-acdbc213a4cd" alt=""><figcaption></figcaption></figure>

when trying with `;id` we were able to read the content of  **root.txt**

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FdiM0EadTIya6f90tlNrP%2Fimage.png?alt=media&#x26;token=7d4d8285-bd85-4116-8333-aa448256d52b" alt=""><figcaption><p>root.txt</p></figcaption></figure>
