# Pickle Rick

{% embed url="<https://tryhackme.com/room/picklerick>" %}

##

## Task 1: Pickle Rick

### What is the first ingredient that Rick needs?

* Lets perform a simple `nmap` scan to see which ports are open.

```
$ nmap -sC -sV 10.10.88.164
Starting Nmap 7.92 ( https://nmap.org ) at 2023-11-11 14:52 IST
Nmap scan report for 10.10.88.164
Host is up (0.13s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.6 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 b0:56:f1:d5:f7:ee:f0:9f:0f:9f:07:88:c6:56:7a:29 (RSA)
|   256 ef:9b:c2:3f:b3:84:8d:22:5e:d2:b4:09:59:ba:be:15 (ECDSA)
|_  256 0d:2a:4f:24:a0:9f:3d:20:80:31:b8:51:42:29:a7:0f (ED25519)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-title: Rick is sup4r cool
|_http-server-header: Apache/2.4.18 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 25.91 seconds
```

* There are two open ports:

| Port | Service |
| ---- | ------- |
| 22   | ssh     |
| 80   | http    |

* Let's enter the IP address in the browser and see what comes up.&#x20;

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FmJx2aAyoVQWd7UqxJ6yT%2F2.png?alt=media&#x26;token=adb0239d-5bbb-48ff-900d-b00896293dc2" alt=""><figcaption></figcaption></figure>

* Let's check the page source for more information.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FoEyIJibIeQXKxCqG8OWM%2F3.png?alt=media&#x26;token=f5828660-4b20-4bb5-aa98-70e7bb398a3c" alt=""><figcaption></figcaption></figure>

* So we have a username now: `R1ckRul3s`. However we don't know the password yet.
* On most websites, the `robots.txt` file does the job of disallowing web crawlers from accessing particular pages. Let's see if we can find anything there.&#x20;

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FNyeFAh8BuzwZHI2ciI9P%2F4.png?alt=media&#x26;token=aba33fb6-04e8-4d3c-91a3-939e6524ee6a" alt=""><figcaption></figcaption></figure>

* Looks like `Wubbalubbadubdub` is the password.
* But where should we enter these credentials?
* In order to find the login page we will have to perform some directory brute-forcing. There are various tools available, but in this case let's use `gobuster`.

```
$ gobuster dir -u http://10.10.88.164 -w /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt -x php
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.10.88.164
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Extensions:              php
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.php                 (Status: 403) [Size: 291]
/login.php            (Status: 200) [Size: 882]
/assets               (Status: 301) [Size: 313] [--> http://10.10.88.164/assets/]
/portal.php           (Status: 302) [Size: 0] [--> /login.php]
-- snip --;
```

* We can see a `/login.php` file. Let's go to the file in the browser.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FrntLGawm26e6mSMPcVrZ%2F5.png?alt=media&#x26;token=aba048de-a8e3-4ca0-87ce-72246a615df0" alt=""><figcaption></figcaption></figure>

* Let's enter the credentials that we found before i.e. `R1ckRul3s` as username and `Wubbalubbadubdub` as the password.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FwYdb8AF1B1tB30MngCgv%2F6.png?alt=media&#x26;token=95d4938a-606a-45c8-9563-e3c12fb9cc1e" alt=""><figcaption></figcaption></figure>

* We're in and we have a `Command Panel` to enter our commands.
* We can use the `ls` command to list the files and sub-directories.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2Fb9xv5p6KXuURLtDgMpZ5%2F7.png?alt=media&#x26;token=f5f8db2c-38d3-4637-8e06-f5cd0c06187a" alt=""><figcaption></figcaption></figure>

* The `Sup3rS3cretPickl3Ingred.txt` file seems interesting. Let's `cat` the contents of that file.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FrU5YZmZ0pdB7KRIXEmmD%2F8.png?alt=media&#x26;token=813deb3d-74df-43ea-9ed1-7308bb9796ee" alt=""><figcaption></figcaption></figure>

* Oh! So `cat` is disabled. We have to find another way to read the file.
* We can `grep` all the contents of the file by using the `.` regular expression.

```
grep . Sup3rS3cretPickl3Ingred.txt
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2Fx4EdVr23jtQrSCaCevzD%2F9.png?alt=media&#x26;token=9fb6877b-0c81-4e97-937a-72e0feffff13" alt=""><figcaption></figcaption></figure>

### Answer

```
mr. meeseek hair
```

##

### What is the second ingredient in Rick’s potion?

* We can check which user are present by using the following command:

```
cd /home ; ls
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FUmY2s4x0Stvt9lFjDVgK%2F10.png?alt=media&#x26;token=b5cb9276-6c1a-47c1-b00b-34f8ae18a234" alt=""><figcaption></figcaption></figure>

* Let's check what files `rick` has using the following command:

```
cd /home/rick ; ls
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2Fcsvb2h8cQH3AP5RvdlAP%2F11.png?alt=media&#x26;token=59fcd561-07b1-4a02-99de-505608380fea" alt=""><figcaption></figcaption></figure>

* Let's see what is in to the `second ingredients`.

```
grep . /home/rick/"second ingredients"
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FHsfAK3YeGq0wG6auK1jT%2F12.png?alt=media&#x26;token=6ccf9281-9c88-4e95-bb39-73442acc8501" alt=""><figcaption></figcaption></figure>

### Answer

```
1 jerry tear
```

##

### What is the last and final ingredient?

* Let's look at the `/root` directory using the following command:

```
sudo ls /root
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FEQMkpU38XHxgq7xdLrP8%2F13.png?alt=media&#x26;token=e6036912-7f9b-4984-86ac-faeb3f39bd08" alt=""><figcaption></figcaption></figure>

* As always, we can use `grep` to read the contents of a file.

```
sudo grep . /root/3rd.txt
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FxR4GBHNmbqbSKKvp3l9s%2F14.png?alt=media&#x26;token=0e75abc1-db0a-4819-a455-ac610cf1708b" alt=""><figcaption></figcaption></figure>

### Answer

```
fleeb juice
```


---

# 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://kunalwalavalkar.gitbook.io/write-ups/tryhackme/easy/pickle-rick.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.
