Skip to content
File upload Write-up Beginner

Author Krish Gupta

The web server allowed file uploads but blocked .php files; by renaming a PHP reverse shell to .php5, the attacker bypassed the filter and executed it to gain a shell as www-data. A SUID binary on python2.7 then allowed privilege escalation to root.

Krish Gupta Follow

Published on infosecwriteups.com

Hey everyone! Today we’re solving the TryHackMe room RootMe — a great beginner-friendly box that covers web enumeration, exploiting a file upload vulnerability to get a reverse shell, and then escalating privileges to root using a SUID binary.

Krish Gupta, on infosecwriteups.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The upload filter only blocked the .php extension, not other executable PHP extensions like .php5, and a Python interpreter had the SUID bit set, allowing privilege escalation.

Impact

An attacker could upload and execute arbitrary code, gaining a low-privileged shell, and then escalate to root due to a SUID misconfiguration.

What the attacker needed

Network access to the target; ability to upload files

How it was found

  1. Scan the target with nmap to find open ports and services.
  2. Use Gobuster to discover hidden directories, including /panel.
  3. Upload a harmless test file to confirm the upload feature works.
  4. Try uploading a PHP reverse shell with a .php extension and observe it is rejected.
  5. Rename the shell to .php5 and upload it successfully.
  6. Start a netcat listener, then access the uploaded file to trigger the reverse shell.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The website let people upload files but tried to stop dangerous ones by checking the file extension. The attacker changed the extension from .php to .php5, which the server still ran as code, giving them control of the server. Then they found a program that always runs with full administrator rights and used it to become the top-level user.

What is File upload?

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

More by Krish Gupta

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.