🟩File Upload
When a web server allows users to upload files to its filesystem without validating
"Content-Type" header:
simple text like name, address: "application/x-www-form-url-encoded"
large amounts of binary data, like image or a PDF: "multipart/form-data"
"Content-Disposition" header:
If request message body is split into separate parts, each part contains a "Content-Disposition" header, which provides some basic information about the input field. and it has a "Content-Type" header which tells the server the MIME type of the data that was submitted using this input.
Exploiting
PHP web shell upload
Example
Web shell upload via path traversal
Overriding the server configuration
Load a directory-specific configuration from a file and edit it: - IIS Server: "web.config" - Apache Server: ".htaccess"
Obfuscating file extensions
Most exhaustive blacklists can potentially be bypassed using classic obfuscation techniques
Example In the "Content-Disposition" header, change the value of the filename parameter to:
or
Web shell upload via extension blacklist bypass (upload malicious .htaccess file)
Send request which upload file to server in Burp Repeater then:
Change the value of the "filename" parameter to ".htaccess"
Change the value of the "Content-Type" header to "text/plain"
Replace payload with
AddType application/x-httpd-php .l33t
Resend the request with your payload and its "filename" should be "exploit.l33t"
Now web shell was successfully uploaded.
Remote code execution via polyglot web shell upload
Exploiting file upload race conditions
Create a polyglot PHP/JPG file that is fundamentally a normal image, but contains your PHP payload in its metadata
Example
As you can see from the source code above, the uploaded file is moved to an accessible folder, where it is checked for viruses. Malicious files are only removed once the virus check is complete. This means it's possible to execute the file in the small time-window before it is removed. To solve this challenge, we can use Turbo Intruder. Turbo Intruder is a Burp Suite extension for sending large numbers of HTTP requests and analyzing the results
Exploiting file upload vulnerabilities without remote code execution
Uploading malicious client-side scripts
If you can upload HTML files or SVG images, you can potentially use tags to create stored XSS payloads.
Exploiting vulnerabilities in the parsing of uploaded files
You know that the server parses XML-based files, such as Microsoft Office .doc or .xls files, this may be a potential vector for XXE injection attacks.
Last updated