1. Introduction
In this write-up, I will document my experience completing the Agent T room on TryHackMe, focusing on identifying and exploiting a Remote Code Execution (RCE) vulnerability caused by a backdoor hidden inside an early development version of PHP.
At first glance, the target looks like an ordinary web application. There is an admin dashboard, a few interface elements, and nothing particularly interesting from the front end.
However, I learned a long time ago that a website's appearance does not tell us much about the security of its underlying infrastructure.
Instead of spending too much time exploring the dashboard, I decided to start with network enumeration and investigate what was actually running behind the web server.
One detail immediately caught my attention: the PHP version exposed by the target.
It turned out that this was not just an outdated software version. It was associated with a backdoor that could allow an unauthenticated attacker to execute arbitrary commands remotely.
The interesting part of this challenge is how a seemingly harmless HTTP request can lead to complete server compromise.
2. Initial Reconnaissance – Understanding the Target
After deploying the machine on TryHackMe, I waited a couple of minutes for the target to become available.
I started with a basic Nmap scan to identify open ports and running services.
2.1. Port Scanning with Nmap
My first command was:
nmap -sC -sV <TARGET_IP>
Let's break down the options:
| Option | Description |
|---|---|
-sC |
Run Nmap's default NSE scripts |
-sV |
Detect service versions |
<TARGET_IP> |
Target machine IP address |
The scan revealed the following result:
PORT STATE SERVICE VERSION
80/tcp open http PHP cli server 5.5 or later (PHP 8.1.0-dev)
|_http-title: Admin Dashboard
There was one particularly interesting piece of information:
PHP 8.1.0-dev
At this point, I had two important observations:
- The target exposed an HTTP service on port 80.
- The server appeared to be running PHP 8.1.0-dev.
The -dev suffix caught my attention because development builds are not necessarily equivalent to stable production releases.
I decided to investigate the PHP version before spending time on unnecessary directory enumeration.
3. Web Application Enumeration
Next, I opened the target IP address in my browser.
The website displayed an admin dashboard interface. However, there was not much functionality available to interact with.
I initially considered exploring the application manually and looking for hidden directories, but the information from Nmap was already more interesting than the front end.
3.1. Inspecting HTTP Response Headers
Rather than relying only on what the browser displayed, I decided to inspect the HTTP response headers.
I used cURL:
curl -I http://<TARGET_IP>/
The -I option sends a HEAD request and displays the response headers without downloading the entire response body.
The important part of the response was:
HTTP/1.1 200 OK
X-Powered-By: PHP/8.1.0-dev
Content-type: text/html; charset=UTF-8
This confirmed the PHP version reported by Nmap.
The X-Powered-By header is useful during reconnaissance because some web applications disclose their underlying technologies through HTTP response headers.
In this case, the information was particularly valuable because it pointed toward a known security issue.
3.2. Why Version Disclosure Matters
Version disclosure alone is not necessarily a vulnerability.
However, knowing the exact software version helps an attacker identify potential weaknesses associated with that version.
My next step was to investigate whether PHP 8.1.0-dev had any publicly documented security issues.
I searched for the version and quickly discovered something interesting: an early development snapshot of PHP 8.1.0 contained a malicious backdoor.
This changed the direction of my investigation.
Instead of looking for a traditional web application vulnerability, I now had a potential remote code execution vector.
4. Vulnerability Research – The PHP 8.1.0-dev Backdoor
The vulnerability behind this challenge is particularly interesting because it was not an ordinary programming mistake.
In March 2021, PHP's Git repository was compromised, and malicious commits introduced a backdoor into the PHP source code.
The malicious code was designed to inspect incoming HTTP requests for a specially crafted header.
The header name was:
User-Agentt
Notice the double t at the end.
The backdoor checked whether the header value started with a specific string:
zerodium
If the condition was satisfied, the code following that prefix could be evaluated as PHP code through the Zend Engine.
This meant an attacker could potentially execute arbitrary commands on a vulnerable server without providing valid application credentials.
4.1. Understanding the Attack Flow
The general exploitation process looked like this:
Attacker
|
v
Send HTTP request
|
v
Include User-Agentt header
|
v
PHP backdoor checks header value
|
v
Evaluate supplied PHP expression
|
v
Execute system command
|
v
Return command output
The important distinction is that the attacker does not need to exploit a normal application input field.
The malicious functionality exists inside the PHP runtime itself.
4.2. Finding the Public Exploit
After identifying the backdoor, I searched for a public proof of concept.
I found the following entry on Exploit-DB:
EDB-ID: 49933 – PHP 8.1.0-dev 'User-Agentt' Remote Code Execution
The exploit provides a Python script that communicates with the vulnerable server and creates a simple interactive command interface.
One important detail: Exploit-DB lists the CVE field as N/A. This is a backdoor introduced through a compromised source repository, so I would not describe it as a formally assigned CVE.
I decided to use the publicly documented exploit to validate the vulnerability against the TryHackMe target.
5. Exploitation – Achieving Remote Code Execution
After identifying the relevant exploit, I prepared it on my Kali Linux environment.
5.1. Downloading the Exploit
First, I checked whether SearchSploit contained the exploit:
searchsploit "PHP 8.1.0-dev"
The search returned the relevant exploit entry.
I then copied it into my current working directory:
searchsploit -m 49933
This downloaded the exploit file from the local SearchSploit database.
I checked the file:
ls -lah
The Python exploit was now available for analysis and execution.
5.2. Understanding the Exploit Script
Before running the script, I wanted to understand what it was doing.
The most important part of the exploit was the HTTP header construction:
headers = {
"User-Agent": "Mozilla/5.0",
"User-Agentt": "zerodiumsystem('" + cmd + "');"
}
There are two headers here:
-
User-Agent: A normal browser identification header. -
User-Agentt: The specially crafted header that triggers the backdoor.
The script takes a command from the user, constructs the malicious header, and sends an HTTP request to the target.
The vulnerable PHP code evaluates the supplied PHP expression, which invokes the system command.
The script then extracts the command output from the HTTP response.
This is why the exploit provides an interactive-looking shell even though it is communicating through individual HTTP requests.
5.3. Running the Exploit
I executed the script:
python3 49933.py
The script prompted me to enter the target URL:
Enter the full host url:
http://<TARGET_IP>
After submitting the URL, the exploit established an interactive command interface.
The important point was that I had successfully moved beyond simply identifying a vulnerable service.
I now had remote command execution on the target.
5.4. Verifying Remote Command Execution
Whenever I obtain a shell during a penetration test, I prefer to verify the level of access before doing anything else.
I used basic Linux commands:
whoami
To identify the current account.
id
To inspect the user ID, group ID, and group memberships.
hostname
To identify the target system.
The results confirmed that the commands were being executed on the remote machine rather than on my local Kali environment.
More importantly, the returned privileges indicated that the initial compromise provided root-level access.
Root access obtained
This was a significant finding because the vulnerability did not merely expose application information. It allowed direct command execution with highly privileged access.
6. Post-Exploitation – Locating the Challenge File
After confirming remote access, I moved on to basic post-exploitation enumeration.
My objective was to understand the filesystem and locate the challenge's flag file.
6.1. Inspecting the Root Directory
I started with:
ls -lah /
This displayed the contents of the filesystem's root directory.
I then searched for the expected challenge file:
find / -type f -name "flag.txt" 2>/dev/null
Let's break this down:
| Component | Purpose |
|---|---|
find / |
Search starting from the filesystem root |
-type f |
Return regular files |
-name "flag.txt" |
Match files with the specified name |
2>/dev/null |
Suppress permission-related error messages |
The search identified the location of the challenge file.
6.2. Verifying the File
Once I identified the file location, I used:
cat <FLAG_FILE_PATH>
The file contained the challenge flag.
I won't include the flag value in this write-up because I want to keep the walkthrough focused on the methodology rather than revealing the final answer.
The important result is that I had successfully demonstrated the complete attack path:
Network Enumeration → Version Identification → Vulnerability Research → Remote Code Execution → Root Access → File Discovery
7. Technical Analysis – Why Was the Server Vulnerable?
This challenge demonstrates an interesting security failure involving software supply-chain security.
7.1. The PHP Repository Compromise
The backdoor was introduced through malicious commits to the PHP source code repository in March 2021.
The commits appeared to come from trusted PHP maintainers, but the repository infrastructure had been compromised.
The malicious code was quickly discovered and removed.
However, a build compiled from the compromised source snapshot could still contain the backdoor.
This is why the development version used in the challenge was vulnerable.
7.2. Why the User-Agentt Header Was Dangerous
Normally, the User-Agent HTTP header is used by clients to identify themselves.
For example:
GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0
The vulnerable PHP build also checked a second, unusual header:
User-Agentt: <value>
When the value started with the expected trigger string, the backdoor passed the remaining content to PHP's evaluation mechanism.
This created a direct path from an HTTP request to server-side code execution.
The problem was not simply that the application trusted a user-controlled header.
The deeper issue was that the PHP runtime itself contained malicious code that treated attacker-controlled input as executable PHP code.
7.3. Understanding the Impact of RCE
Remote Code Execution is one of the most serious vulnerability classes because it can allow an attacker to execute commands on a remote system.
Depending on the privileges of the vulnerable process, an attacker may be able to:
- Read sensitive files.
- Modify application data.
- Access configuration files.
- Extract credentials.
- Install malicious software.
- Establish persistence.
- Use the compromised server as a starting point for further attacks.
In this room, the impact was particularly severe because the initial command execution provided root-level privileges.
There was no need for a separate privilege escalation step.
8. Mitigation and Defensive Recommendations
From a defensive security perspective, Agent T demonstrates why software integrity and patch management are important.
There are several measures that can help prevent similar incidents.
8.1. Use Stable and Trusted Software Releases
Development builds should not be deployed directly into production environments without appropriate review.
Organizations should use stable releases obtained from trusted sources and verify their integrity.
8.2. Implement Software Supply-Chain Security
The PHP incident demonstrates that even widely used open-source projects can be affected by repository compromise.
Organizations should consider:
- Verifying software signatures and checksums.
- Reviewing source-code changes.
- Using trusted build pipelines.
- Restricting repository write permissions.
- Enforcing multi-factor authentication.
- Monitoring suspicious changes to dependencies.
8.3. Minimize Version Disclosure
Web servers should avoid unnecessarily exposing detailed software versions through HTTP headers.
For example, administrators can review and configure the X-Powered-By header to reduce unnecessary information disclosure.
However, hiding version information is only a defense-in-depth measure. It does not fix the underlying vulnerability.
8.4. Monitor Suspicious HTTP Headers
Security monitoring systems should investigate unusual HTTP request headers, especially unexpected headers that do not normally appear in legitimate application traffic.
For this particular backdoor, suspicious requests containing User-Agentt and the trigger string would be useful indicators during incident investigation.
8.5. Apply Least Privilege
Web services should not run with root privileges unless absolutely necessary.
Even if an attacker achieves remote code execution, restricting the privileges of the application process can significantly reduce the potential impact.
9. Key Takeaways
Completing Agent T reinforced several important concepts that are useful in real-world penetration testing.
1. Start with service enumeration.
Nmap helped identify the exposed HTTP service and provided an early indication of the underlying PHP version.
2. HTTP response headers can reveal useful information.
The X-Powered-By header provided an important clue that directed the investigation toward the vulnerable PHP build.
3. Always research suspicious software versions.
Identifying a version is only the beginning. Understanding its security history helps determine whether it represents a potential attack vector.
4. Understand the exploit before executing it.
Inspecting the Python exploit helped me understand how the User-Agentt header triggered the backdoor and how command output was returned.
5. RCE can lead directly to complete system compromise.
The challenge demonstrated how a single vulnerable service could provide root-level access without requiring an additional privilege escalation technique.
6. Supply-chain security matters.
Even trusted software projects can be affected by compromised repositories and malicious source-code changes.
10. Conclusion
Agent T was a straightforward but valuable exercise in web reconnaissance, vulnerability research, and remote code execution.
What initially looked like an ordinary admin dashboard turned out to be running a development build of PHP containing a dangerous backdoor.
The most important part of this challenge was not simply finding a public exploit and running it. It was understanding the relationship between the information discovered during enumeration and the vulnerability that made exploitation possible.
I started with a basic Nmap scan, identified the PHP version, inspected the HTTP response headers, researched the unusual development build, and then validated the vulnerability using the publicly documented exploit.
The result was remote command execution with root-level privileges.
My biggest takeaway from this room is that a system can become vulnerable not only because of insecure application code, but also because the software and dependencies it relies on have been compromised.
As someone interested in both cybersecurity engineering and application security, this challenge was a good reminder that security testing should cover the entire technology stack, from the web application itself to the underlying runtime, dependencies, and software supply chain.
Sometimes, the biggest weakness is not in the application we are looking at, but in the software that makes the application work.
Author: Victor Hoang
Platform: TryHackMe
Room: Agent T
Category: Web Security / Remote Code Execution
Exploit Reference: Exploit-DB 49933
Top comments (0)