Pickle Rick
LAST UPDATED 23-MAY-2025
Last updated
LAST UPDATED 23-MAY-2025
Last updated
When I visited the webpage I was greeted with a note that relates to the theme of the CTF. However, there seem to be nothing interesting or relevant to the technical details of the machine.
Next, I used the Chrome developer tools to inspect the source code, and I found the following comment:
Note to self, rememberusername!
Username: R1ckRul3s
This tells me that there exists a username R1ckRul3s
.
The wordlists used in this section are present in the root directory: /usr/share/wordlists/SecLists/Discovery/Web-Content
(1) Basic discovery
common.txt
From the results, it appears that the /robots.txt
path exists. Upon visiting, it returns:
Wubbalubbadubdub
Seems like a strange text, could it be another username, a clue, or perhaps a password? We will leave it here for now.
(2) Fingerprinting the web server
We have found out that the web server uses Apache.
(3) Enumerating PHP
PHP is commonly used as the underlying programming language on an Apache web server. Thus, I decided to enumerate common PHP filenames and directories. Note that the commands listed below are similar to the ones used in the first part above, just with addition of flags, and change of wordlist.
common.txt
Extra -x php
option
Common-PHP-Filenames.txt
It appears that we have found a few .php
files such as login.php
, portal.php
and denied.php
.
The ffuf
tool can be used to enumerate the directories too:
Next, I visited the path /login.php
, and was presented with a login page. I utilized the information we have gathered earlier to discover the username and password combination of R1ckRul3s
and Wubbalubbadubdub
respectively.
Enumerating the webpage
After logging in, the webpage was redirected to/portal.php
.
The following comment was found in the source code:
Vm1wR1UxTnRWa2RUV0d4VFlrZFNjRlV3V2t0alJsWnlWbXQwVkUxV1duaFZNakExVkcxS1NHVkliRmhoTVhCb1ZsWmFWMVpWTVVWaGVqQT0==
This is a string that has been base64-encoded multiple times. The plaintext value turns out to be rabbit hole
. Well, is this a clue, perhaps a directory path value, name of a file, or simply something just to throw us off?
The main interface presented an input form that accepts commands for a Linux environment. This form will be used to enumerate the Linux system and find the ingredients.
I was having difficulty finding the third ingredient from the file system, as most of my attempts at enumerating the directories returned an empty response. Thus, I decided to further enumerate the webpage.
Upon visiting /denied.php
,
We are presented with a message: "Only the REAL rick can view this page." This made me wonder, by REAL rick, does this mean we have to somehow access this page via the root account?
(1) SQL Injection attempt
I attempted a SQL injection attack on the login form, in hopes of potentially discovering the name and password combination of the root, or higher privilege account.
The database used in the system seems to either not use an SQL-based database, or is simply not vulnerable to a SQL injection attack.
As mentioned before, access to the third ingredient most likely requires a privileged account. Thus, I attempted to escalate my privileges.
(2) Linux privilege escalation enumeration
The output (ALL) NOPASSWD: ALL
tells us that the current user is allowed to run sudo
without any password. This means that we are able to gain an unauthenticated superuser privilege.
Finding the last and final ingredient
After further enumeration on the file system, I found out that the 3rd ingredient is in the /root
directory.
(1) Attempts to initiate a reverse shell (for a stable shell experience)
Attacker machine
1.1 Netcat (does not work)
The attacker machine does not receive any connections
1.2 Perl (works)
The attacker machine receives a shell environment
(2) Persistence
Now that we have a session with superuser privileges (sudo
), we can load our SSH public key to the .ssh/authorized_keys
file. Specifically, the key will be added to the file under the home directory for the root user: /root
, allowing us to gain persistence as the root user.
From the attacker machine
2.1 Generate a SSH keypair
2.2 Load the public key (reverse shell connection)
Now, we can SSH into the server as the root
user by providing our private key:
Assuming that the admin does not clean up the .ssh/authorized_keys
file, we can access our backdoor with a root shell anytime as needed.
NOTE: Yes, ofcourse I removed the backdoor access after I was done testing.