Lab - CTF - MrRobot
Lab - CTF - MrRobot
Robot
Overview
In this lab, you will attempt to capture three hidden flags. Using the hacker methodology, you
will work your way through this CTF scenario based on the show, Mr. Robot.
This CTF exercise has three keys hidden in different locations. Your goal is to find all three.
Each key becomes progressively difficult to find.
The level of expertise for this CTF is considered beginner-intermediate. There is no advanced
exploitation or reverse engineering.
Capture the Flags (CTFs) are events that are usually hosted at information security
conferences. These events consist of a series of challenges that vary in their degree of
difficulty and require participants to exercise different skillsets to solve. Once an individual
challenge is solved, a “flag” is given to the player, and they submit this flag to the CTF server
to earn points.
Hardware Requirements
This CTF uses a custom VM OVA file that can be imported as an appliance in either
VirtualBox or VMWare.
Caveat
Ensure your network adapters on both VM’s is set to NAT and not bridged networking.
Surprising, the download site is well maintained, and the download is quick and painless.
Save the OVA to your local machine.
For VirtualBox
Stop and think about how best to approach as if it were a pentest. Most of the methodology you
have been introduced to, so we only need to pull it from your grey matter. Relax and think
through it! It’s all going to be a learning experience so sit back and enjoy yourself.
You are encouraged to do this CTF more than once. You should run through the CTF until you
can recall most of the steps from memory because you will see this repeatedly with other CTFs.
Discovery
Treat every CTF as if you were seeing the network for the first and need to discover what the
IP address is and to locate the IP address of the Mr. Robot VM.
This is my IP range, not yours! Get accustomed to discovering the IP address of the network
you are pentesting or hacking.
The IP of 192.168.145.134 is our target. Now that we have the IP address of our target, we can
fingerprint scan to check for any open ports and probe for running services, and OS’s.
We’re now ready to conduct a Nmap scan of our target machine. There are several different
switches we could use but for this scan we can use the following syntax:
Since we know this is a web server we can run Nikto and scan for any “possible” vulnerabilities
or misconfigurations.
nikto -h 192.168.145.134
A few interesting things form our scan results.
1. We see that the server is leaking inodes via ETags in the header of /robots.txt. This
relates to the CVE-2003-1418 vulnerability. These Entity Tags are an HTTP header
which is used for Web cache validation and conditional requests from browsers for
resources.
2. Apache mod_negotiation is enabled with MultiViews, which will allow us to use a brute
force attack in order to discover existing files on a server which uses mod_negotiation.
3. The following alternatives for ‘index’ were found: index.html, and index.php. These can
be used to provide us with more info on the website.
4. OSVDB-3092: /admin/: This might be interesting… if we have a login. Good to keep that
in the back of our mind.
o /admin/index.html: Admin login page/section found - also relates to the above
scan.
5. /readme.html: This WordPress file reveals the installed version.
o Tells us this is a WordPress Site. We know we can look for WordPress
Vulnerabilities.
o /wp-links-opml.php: This WordPress script reveals the installed version.
o /wp-login/: Admin login page/section found.
o /wp-admin/wp-login.php: Wordpress login found.
6. OSVDB-3092: /license.txt: License file found may identify site software. Which can
help us get version information about plugins and services to look for exploits.
That gives us our initial footprint. Access the website in our Kali browser by navigating to
192.168.145.134 (your IP address will differ).
This is some very interesting coding. The website is interactive. You can see the commands you
can type in. Feel free to run through the commands and interact but think before you input any
information.
We already know there are leaking inodes via ETags with the /robots.txt. This file is used to
prevent crawlers from indexing portions of the website.
Make a directory for your CTF file storage and save it to your desktop.
mkdir mrrobot
We can use the wget to save these to the folder on our desktop named mrrobot.
wget http://192.168.145.134/fsocity.dic
wget http://192.168.145.134/key-1-of-3.txt
Key 1: 073403c8a58a1f80d943455fb30724b9
Open the mrrobot folder. You should see to text files present. Let’s examine the files.
fsocity.dic appears to be a dictionary file. They provided this for a reason. Most likely a
brute force attack. The file is bloated with duplicates and will take some time to parse using a
brute force attack. We clean the file and remove the duplicated to make it much smaller.
Type in the following commands online one at a time into the kali terminal.
cd mrrobot
ls
wc -l fsocity.dic
cat fsocity.dic | sort -u | wc -l
cat fsocity.dic | sort -u | uniq > Newfsocity.dic
This cuts the dictionary down from 858160 words to 11451 and creates shorter dictionary file
named Newfsociety.dic.
Key #2
We can now go ahead and try the next two locations that we got from our scan - index.html
and index.php. The .html file gets stuck with loading, so we can kill it.
The .php file goes back to the main page. View the source to see if there is anything
interesting. This is a step that is often overlooked by the inexperienced but often the developer
will leave something in the comments that can be useful to include usernames and passwords.
Right-click on the web page and from the context menu select View Page Source.
Navigate to 192.168.145.134/readme.html
No help here either. Let’s try the /license.txt file. No joy there either.
We can now check out the /wp-login.php/page. This is where we have to some
investigating. We could open the Newfsociety.dic text file and start inputting usernames until
we stop getting the invalid username error message. That would be taking a long way home.
We can also use a brute force attack to find the username using the burpsuite and Hydra.
From the left-hand menu, click on advanced. Under advanced click on the Network option.
Under network, Open the Setting for Connection
Under the proxy settings, click the radio button for the Manual proxy configuration:
In the text box for the HTTP proxy input the local host 127.0.0.1 and set the port to 8080.
We’re using burpsuite as our proxy. Click OK
From your Kali quick launch, open burpsuite. Accept the license agreement. Skip the update.
Create a temporary project and click next.
Leave burb up and running and return to your Wordpress login page. Type in a random
username and password. Minimize your browser and return to burpsuite.
Burpsuite captured the attempt giving us the form fields used for the username and the
password. We see that &pwd = password and log = username.
We need to identify these two form fields so that Hydra knows which two fields to use for a
brute force attack on guessing the username. Once Hydra tries a valid username from the
dictionary list, it will not generate an invalid username error.
Once we have the correct username, we can use wpscan to brute fore the password using the
same dictionary list. You can close out the burpsuite.
Hydra returns three valid usernames all belonging to Elliot. Elliot is the main character of the
Mr. Robot TV show.
Once you find the username, minimize your browser.
We next need to brute force the password using wpscan using the same dictionary list we
created earlier
We were able to brute force the password using the condensed dictionary list we created. The
password turns out to be Elliot’s badge number.
http://pentestmonkey.net/tools/web-shells/php-reverse-shell
php-reverse-shell-1.0.tar.gz
Click OK.
Find your download, right click and from the context menu select Move to.
Click on the Desktop and then highlight your mrrobot directory. Click on the Select button.
Right on the archived folder and from the context menu, select extract here. Open the extract
folder.
Open the php-reverse-shell.php using a text editor. Right-click on the file, and from the context
menu select, Open with other application.
At the top of the php-reverse-shell.php page on the very first line, copy and paste the following
text at the beginning of the line before the < (lesser than) sign.
We next need to modify the source code to indicate where you want the reverse shell thrown
back to (Your Kali machine)
The $ip is the IP address of my Kali machine. We know that Kali is accustomed to using port
4444 with Metasploit so it should work here just as well.
Click on File, from the context menu select Save. Open the file and verify the changes are
present.
Right-click on the newly modified php-reverse-shell.php file and from the context menu select
compress. Save the archive as a zip file.
nc -v -n -l -p 4444
Login to the Mr. Robot Wordpress site using the username and password we discovered.
From the Wordpress Dashboard, click on Plugins and then select Add New.
Click on the browse button, find your newly created zip file.
Click Install Now.
Type: whoami (prints the effective username of the current user when invoked.)
Type: hostname (used to either set or display the current host, domain or node name of the
system.)
Type: pwd (The pwd command reports the full path to the current directory)
Type: cd home (change directory to the home directory)
Type: ls (list the contents of the current directory)
We see there is another directory present called, robot. Change directory to the robot directory.
Type: cd robot
Type: ls
We have located our second key and password file that has been hashed using MD5!
Let’s use the cat command to read the contents of the password.raw-md5 file.
cat password.raw-md5
robot:c3fcd3d76192e4007dfb496cca67e13b
That's not just any password. It’s the password for the robot account. We need to break the
MD5 hash to see what it is.
There are a number of sites online that can crack an MD5 hash. To crack this hash, I am using
https://www.md5online.org/
Copy and paste the hash into the site and click on the decrypt button.
We can create a terminal using python. Type the following command at the prompt:
We now have a terminal and so let’s try and login using the robot account one more time.
Success!
Copy and save the 2nd key to your mrrobot directory as a new text file. You have now captured
two of the three keys. One more to go!
Key #3
Escalating Privileges
ls -alh
We need to get into the root folder to check the contents. We can see if the file is hiding busing
the same naming convention as the other two keys using the find command. At the prompt,
type the following:
You are root! You can now cd to the root directory and list the contents.
There is your third and final key.
Summary
All I can say is wow! Doing a CTF exercise is a great way to hone your skills. Regardless of the
outcome, you will leave as a better pentester or hacker. This first CTF took a week of research
and much trial and error to build. I choose what I thought were the best ways to complete the
requirements and there were plenty of different ways of getting the same result.
A lot of my research showed Metasploit exploits being used to establish a Meterpreter session
with the WordPress site, but I could never get the payload to work.
Much of what you will have learned will be seen again in future CFT labs as a lot of the steps are
used repeatedly.
CTF’s are a great way to bring all of what you have learned together.
I encourage you to do this CTF three or four times until you become comfortable with the
hacking methodology and the steps we used in the lab.
https://github.com/pentestmonkey/php-...
http://pastebin.com/GMwhCDtm
http://www.rebootuser.com/?p=1623#.V5...
Snooze Security