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

# Simple CTF

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FDZZy0k87wYCEFZZR08UH%2Ff28ade2b51eb7aeeac91002d41f29c47.png?alt=media&amp;token=dd5daa8b-fb6e-4f11-864d-7e12e76a55cb" alt=""><figcaption></figcaption></figure>

## 1.How many services are running under port 1000?

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FXDs8tcxLzxR99jywKw9C%2FScreenshot%20from%202023-05-12%2012-35-18.png?alt=media&amp;token=69b21c7c-33e6-402f-a3dc-ac1d9991bc31" alt=""><figcaption></figcaption></figure>

* #### First, we need to perform a port scan, and for that, we can use Nmap. We can use the '-sS' flag for stealth scanning and the '-sV' flag to determine the version of services running on the scanned ports.

### ANS:- 2

## 2.What is running on the higher port?

### ANS:- SSH

## 3.What's the CVE you're using against the application?

* #### First, we need to enumerate the target website. We can use Dirsearch for this, and specify the URL with the '-u' flag.

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2F4LdAN8BReA7G7cXr034K%2FScreenshot%20from%202023-05-12%2012-39-07.png?alt=media&amp;token=d0f5b1c0-1ee0-46bd-a596-ab5ce419bfe2" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2F8TIvCuGRdjikQbauwtn3%2FScreenshot%20from%202023-05-12%2012-40-29.png?alt=media&amp;token=f52798e6-fc46-4ae7-b946-680956e17210" alt=""><figcaption></figcaption></figure>

* #### After scanning, we found the '/simple' endpoint, which indicates the presence of a website. We also found a CMS service application at the bottom of the page, and its version was identified as 2.2.8.

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FxjTgx1l1sgy0oV57p3Is%2FScreenshot%20from%202023-05-12%2012-41-39.png?alt=media&amp;token=e8872a68-b3be-4a1c-ad84-a699315b839c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FZQcbpL5GV7pnYtA3NEF6%2FScreenshot%20from%202023-05-12%2012-42-03.png?alt=media&amp;token=170b41d3-8608-4d84-bb2a-505cd8da179a" alt=""><figcaption></figcaption></figure>

* #### We searched for this version on ExploitDB and found an SQL injection exploit.

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FgeRLh5rwUjlduzGizoQ0%2FScreenshot%20from%202023-05-12%2012-46-49.png?alt=media&amp;token=d5471839-9da2-454c-a8c2-69764de6e8e4" alt=""><figcaption></figcaption></figure>

* #### To download the exploit, we can use 'searchsploit -m', which allows us to download exploits using the command line interface.

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FzIbUsB4PgPdzKVT4um37%2FScreenshot%20from%202023-05-11%2004-18-00.png?alt=media&amp;token=9954c94b-0fe1-44a1-8a09-d2c0151918c1" alt=""><figcaption></figcaption></figure>

### ANS:- CVE-2019-9053&#x20;

## 4. To what kind of vulnerability is the application vulnerable?

### ANS:- Sqli

### &#x20;

## 5. What's the password?

*

```
<figure><img src="/files/Pdws9vjFB3uF3zWSEsqd" alt=""><figcaption></figcaption></figure>
```

* #### Here, we found a CVE that we could exploit. We downloaded the corresponding program and ran it, which allowed us to discover the password. To run the program, we used the '-u' flag to specify the URL (e.g. <https://IP/simple>), and the '-w' flag to provide a wordlist for the program to use.

### ANS:- secret

## 6. Where can you login with the details obtained?

### ANS:- SSH

## 7.What's the user flag?

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FPkNWcpMb6ULo0ymN9PY0%2FScreenshot%20from%202023-05-11%2004-58-29.png?alt=media&amp;token=234d5b67-c66a-4a64-98fe-cfab2a7c2222" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FUMhbN0PO0KsX8WqRD3J9%2FScreenshot%20from%202023-05-11%2004-59-05.png?alt=media&amp;token=e252a965-e564-4b02-bc26-4cbf1d9cbb8e" alt=""><figcaption></figcaption></figure>

* #### Okay, we successfully logged in using SSH. We can use the 'ls' command to list the files and directories on the system, and we found a file named 'user.txt'

### ANS:- G00d j0b, keep up!

## 8. Is there any other user in the home directory? What's its name?

### ANS:- sunbath

## 9. What can you leverage to spawn a privileged shell?

* #### When we ran 'sudo -l', we found that we have permission to run '/usr/bin/vim' with root privileges

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FTrh2ATIEZTGEpZVFTNnc%2FScreenshot%20from%202023-05-12%2012-54-01.png?alt=media&amp;token=a4be6acf-da99-4867-ad51-50f89d78ba6a" alt=""><figcaption></figcaption></figure>

### ANS:- VIM

## 10.What's the root flag?

* #### To escalate our privileges, we used GTFOBins to find a way to take advantage of our 'vim' permissions. We copied the path '/usr/bin/vim' and searched for it on GTFOBins, which gave us the command 'sudo vim -c ':!/bin/sh''. By running this command, we were able to gain a root shell.

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FsfTJNN5CnqnGbQPnP2Ot%2FScreenshot%20from%202023-05-11%2005-05-50.png?alt=media&amp;token=53c5ed2c-f69f-4fbe-9d22-56cad5993ddd" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2F8hkMwvmwcaoDa9eRqSsW%2FScreenshot%20from%202023-05-11%2005-07-40.png?alt=media&amp;token=cd47aa16-54e6-4bcf-b812-57aa25aec302" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3029596032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgPS5iAwqlIXa6VqcJziH%2Fuploads%2FZzYI9JPQIWJKr62RJ0gx%2FScreenshot%20from%202023-05-11%2005-09-45.png?alt=media&amp;token=7acc3375-2c68-405c-9546-44fda611ed7e" alt=""><figcaption></figcaption></figure>

### ANS:- W3ll d0n3. You made it!&#x20;
