> For the complete documentation index, see [llms.txt](https://thamizhiniyancs.gitbook.io/writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thamizhiniyancs.gitbook.io/writeups/tryhackme/machines/easy/simple-ctf.md).

# Simple CTF

TryHackme Simple CTF writeup by Thamizhiniyan C S

## Overview

Greetings everyone,

In this write-up, we will tackle Simple CTF from TryHackMe.

Machine link: [Simple CTF](https://tryhackme.com/room/easyctf)

Difficulty Level: Easy

Let's Begin 🙌

Firstly, connect to the THM server using the OpenVPN configuration file generated by THM. [Click Here](https://tryhackme.com/r/access) to learn more about how to connect to VPN and access the boxes.

Once connected to the VPN service, click on "Start Machine" to access the machine's IP.

Upon joining the machine, you will be able to view the IP address of the target machine.

***

First start the machine and run a standard Nmap scan on the target.

Command: `nmap -A -T4 -v <Target_IP>`

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2F5HOCd8qTL2KbNzAwpk9I%2FUntitled.png?alt=media&amp;token=03aacf9c-2aa8-47aa-a11e-4d3485d642a2" alt=""><figcaption></figcaption></figure>

From the output we can see that there are a total of 3 services running on the target machine:

| PORT | SERVICE | VERSION             |
| ---- | ------- | ------------------- |
| 21   | FTP     | vsftpd 3.0.3        |
| 80   | HTTP    | Apache httpd 2.4.18 |
| 2222 | SSH     | Open SSH 7.2p2      |

Now, First I visited the Apache server hosted on port 80.

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FF4C3YtFAvc37TGdVRWaU%2FUntitled%201.png?alt=media&amp;token=c8a086ed-72fa-4231-8153-d032f95f8a17" alt=""><figcaption></figcaption></figure>

It displayed the default apache welcome page. So next I tried directory enumeration on this web server using gobuster.

Command: `gobuster dir -u http://<TARGET_IP>/ -w **/usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt**`

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FOvh9kt5lzZKk9QniQBjl%2FUntitled%202.png?alt=media&amp;token=e3119148-9d14-4cfe-8ed6-be04bce401ba" alt=""><figcaption></figcaption></figure>

From the output of the gobuster, we can see that there is `/simple` directory.

Now visit the `http://<Target_IP>/simple` location.

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FXnxt5GKSi1Jl9jzkidYk%2FUntitled%203.png?alt=media&amp;token=938eaea4-b442-4755-bef2-920857cb92ae" alt=""><figcaption></figcaption></figure>

This web server hosts a CMS using the CMS Made Simple, which is open source CMS. On scrolling down to the end of the page we can find the version of the CMS in the footer section.

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FFcuJgnoggcjLBMHyqYJB%2FUntitled%204.png?alt=media&amp;token=b30bfbac-0822-4f9a-a5a2-19245e636d98" alt=""><figcaption></figcaption></figure>

The CMS version is `2.2.8` , I searched google, looking for exploits for this version of CMS and I got the following:

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FXOtmb5QeZsmORlXiMC91%2FUntitled%205.png?alt=media&amp;token=f9a60eca-3c59-4a61-bc89-7d1d2f83c811" alt=""><figcaption></figcaption></figure>

This CMS is vulnerable to the exploit with the CVE `CVE-2019-9053` , which is an unauthenticated SQL Injection on this CMS.

I downloaded the exploit.

After downloading the exploit I tried to run the exploit using the following command:

`python2 <exploit.py> -u http://<targetip>/simple`

But it thrown me a error that the exploit requires a package `termcolor` to run. So I downloaded the package using the following command: `python2 -m pip install termcolor`

Then I tried to run the exploit, the exploit ran successfully and the following output was obtained:

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FXxF0RHlMFZY6jFTubYkm%2FUntitled%206.png?alt=media&amp;token=06e7e3d8-9bc4-4891-9046-105669ca96b8" alt=""><figcaption></figcaption></figure>

From this we have found the username is `mitch` and we have also got the password salt and hash. Now we can try to crack this password hash using `hashcat`.

Command: `hashcat -m 20 0c01f4468bd75d7a84c7eb73846e8d96:1dac0d92e9fa6bb2 **/usr/share/wordlists/rockyou.txt**`

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FgCrD2rt9hsclteSQFAKt%2FUntitled%207.png?alt=media&amp;token=a1bd6b0d-cee2-4e06-872f-c8dac8c29177" alt=""><figcaption></figcaption></figure>

And we have cracked the password the password is `secret`

Now we can login via ssh using the obtained credentials:

username: `mitch`

password: `secret`

Command: `ssh mitch@<Target_IP> -p 2222`

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2Fpw7DQGieWQKYgQcyLeGM%2FUntitled%208.png?alt=media&amp;token=6e48f99f-f985-4fc3-8623-9968147f351e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FzSzINS12mJifhgN02f9y%2FUntitled%209.png?alt=media&amp;token=c132b581-311a-4853-aea7-3b2a2daada8f" alt=""><figcaption></figcaption></figure>

And now we got the user flag.

Now we have escalate our privilege to access the root flag.

On Further enumeration, I have found another user in the home directory named `sunbath`.

I was looking out for privilege escalation vectors. I tried the `sudo -l` command, to check whether the user `mitch` can run any application with root privileges.

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FeGGABV29W10yZtNQ7yWY%2FUntitled%2010.png?alt=media&amp;token=395d24b0-ad66-40a6-8773-67cdba82d61b" alt=""><figcaption></figcaption></figure>

From the output, we can devise that the user `mitch` can run `vim` with root privileges.

On checking `gtfobins` \[ <https://gtfobins.github.io/gtfobins/vim/#sudo> ], we can use the following command to get a shell with root privilege:

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2F3JKebIZMTShroHGVlz5x%2FUntitled%2011.png?alt=media&amp;token=0929cd27-c6bf-4868-9f8a-2168f4ebf2c2" alt=""><figcaption></figcaption></figure>

And we got root access.

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FJ1SrvmG8oyVA8biBI3dB%2FUntitled%2012.png?alt=media&amp;token=6b2fdc63-d56c-4e57-8020-501627e3310c" alt=""><figcaption></figcaption></figure>

And finally we got the root flag:

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2F9NQwL1qaQXBfjfbjYtX8%2FUntitled%2013.png?alt=media&amp;token=a9673bb5-71af-4d74-a3c6-23ac11880c2f" alt=""><figcaption></figcaption></figure>

The answers for all the Task questions:

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FxRqd8epE7zuYcmnDm5B4%2FUntitled%2014.png?alt=media&amp;token=351ae011-64a4-4ffd-b75b-b1f12e6c5e0a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3987209575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCrNVqJHUzhf98WDK3DMl%2Fuploads%2FxyzhcRpJN2yhfyLmGJjj%2FUntitled%2015.png?alt=media&amp;token=4ac464ee-d73c-4534-b866-d19031e383e3" alt=""><figcaption></figcaption></figure>

Thank You ....
