File Upload Tricks
When uploading files , check for validation on :
File extension
Server side extension allowed ? :
Stacking / Double Extension
Using gif (shell.php)
Advanced gif
Content-Type header
Is server extension like php able to bypass the upload restriction ?
- If yes , just change content-type header to like image and it will still run as php.
Does the server validate content-type header like disallow application/json?
Magic bytes (file hex value)
Does the server check file signature ?
If no , can change file signature using
hexedit
PHP Function Exploit
imagecopyresampled
imagecreatefromstring
solution :Hide the webshell in the IDAT chunk of PNG
Rename to webshell.png.php
Shell exec
php
Examples
Content-Types of Common Files
Pictures :
JSON :
PHP :
TXT :
XML :
HTML :
JAVASCRIPT :
PDF
AUDIO
VIDEO
Last updated