Skip to content
RCE Write-up Beginner

Python Web Penetration Testing — Day 11: Remote Code Execution

The application accepted any file type in its uploader and saved it to a web-accessible directory, so an uploaded PHP file was executed by the server. The author used this to run commands and obtain a reverse shell as the web server user.

Aman Sharma Follow

Published on osintteam.blog

Free Link

Aman Sharma, on osintteam.blog

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

Likely the upload handler did not check the file type or extension and stored files in a directory from which the web server executes scripts.

Impact

An attacker could execute arbitrary commands on the server, read files, access database credentials, and pivot to the internal network.

What the attacker needed

A file upload feature; server executes uploaded files

How it was found

  1. Upload a PHP file disguised as an image to the file uploader.
  2. The server saves the file and executes it when accessed.
  3. Set up a listener and send a reverse shell command through the uploaded file.
  4. Receive a connection back as the www-data user.

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.

A file upload feature that lets you put any kind of file on the server is dangerous if the server then runs that file as a program. Here, the author uploaded a small script written in PHP (a language many websites use) and the server ran it, giving the author a way to type commands on the machine. This is called remote code execution because the attacker can run their own code on someone else's computer.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Aman Sharma

View all

34 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.