TryHackMe Chocolate Factory WriteUp
TryHackMe Chocolate Factory WriteUp
Hello and Welcome to my first writeup!
Reconnaissance and Enumeration
first we scan the machine using nmap using the command:
nmap scan
ftp enumeration
we login to ftp using username: “anonymous” and password: “anonymous”
in ftp found “gum_room.jpg”
used steghide to extract it:
didnt put passphrase, b64.txt extracted.
found what looks like a /etc/shadow file. didnt find anything useful.
web enumeration
we open the webpage and find a login portal.
i used gobuster to enumerate directories.
result:
Initial Access:
we navigate to home.php, you can run commands in it.
we try the whoami command
it works! we search for users in the home directory using "ls /home"
found user charlie, we list the files, using "ls /home/charlie"
Bingo! found ssh private key.
i copied it into id_rsa file then give it the right permissions using chmod +600
test if we can login using ssh to the user. the key works!
in /var/www/html i found a file named key_rev_key, i try to run it:
changed the permissions using chmod +x key_rev_key
since its a binary, we can check the file contents using strings key_rev_key
got the key!
b'-VkgXhFf6sAEcAwrC6YR-SZbiuSb8ABXeQuvhcGSQzY='
in /var/www/html we cat
validate.php:
run validate.php , bingo we got charlies password :)
login to charlies account using “su charlie”.
user.txt
Privilege Escalation:
The first thing you should check for is sudo -l
, result:
in gtfobins, vi -c ':!/bin/sh' /dev/null
i ran it with sudo so if it works we could get root privileges sudo vi -c ':!/bin/sh' /dev/null
pwned!!
Finding the root flag
we find root.py we run it , enter the key we obtained before , and it shows us the root flag.
Happy Pwning :)
Last updated