Logo

dev-resources.site

for different kinds of informations.

File upload bypass using MIME-type

Published at
5/20/2022
Categories
kali
hackthebox
php
mimetype
Author
giannisftaras
Categories
4 categories in total
kali
open
hackthebox
open
php
open
mimetype
open
Author
13 person written this
giannisftaras
open
File upload bypass using MIME-type

There are many methods web developers incorporate in their applications in order to allow only certain file types to be uploaded. In the case of a slideshow of a photo booth web application, developers mostly check for a correct file extension (.jpg , .png , etc.) as well as its mime-type Content-type: image/jpeg in order to ensure that the file uploaded is indeed allowed and only an image.

Bypassing the file extension to upload a payload is straightforward and easy. We just change the file extension from payload.php to payload.php.gif

The mime-type check bypass is again relatively simple but most penetration testers tend to make it seem more complicated than it really is. A good example of that is when we try to incorporate a PHP script in a regular image, which in most cases is very difficult to achieve, and it doesnโ€™t guarantee that the payload will indeed work. This happens because in some cases the server does not recognize the file to contain executable code and it simply tries to display it as an image.

The easy way is to trick the mime-type security check in order to think that the file weโ€™ve uploaded is an image but in reality the web server is going to recognize it as a PHP script file.

To do so we only need to add one line at the start of our script: GIF89a;

GIF89a is a GIF file header. When the file gets reviewed by mime_content_type("myfile"); it gets fooled in order to think that it is an image instead of a PHP shell.

GIF89a;
<?php
  system('whoami'); # shellcode goes here
?>
Enter fullscreen mode Exit fullscreen mode
kali Article's
30 articles in total
Favicon
[Boost]
Favicon
Worms, Bots, and Botnets: How Hackers Take Over the Internet!
Favicon
Create a Powerful Hacking Lab: Install Kali Linux in Minutes!
Favicon
Kali Linux for Ethical Hacking: The Ultimate Toolkit for Cybersecurity Professionals
Favicon
Kali Linux For Beginner
Favicon
Install Kali NetHunter On Your Android Device
Favicon
Not bad but not good enough
Favicon
Beyond Basics: Traversing Kali Linux Tools
Favicon
Encrypt/Decrypt File Using Openssl
Favicon
Thrash with BASH
Favicon
Download Bluetooth in Kali Linux
Favicon
Realizando ataques de forรงa bruta em containers docker usando hydra
Favicon
Deauthentication Attack using Kali Linux
Favicon
HiDPI In Kali Linux Through RDP | Hyper-V
Favicon
Kali Linux on Android Devices
Favicon
Mengatasi Install Kali Linux Berhenti di Detect Network Hardware
Favicon
Grub-customizer won't change your GRUB theme in Kali Linux? Try this
Favicon
Deploying your Kali-linux templates with Cloud-init, under Proxmox VE
Favicon
Linux top 15 shell commend.
Favicon
3 Easy Commands to Install Postman in Kali Linux
Favicon
Installing Snort on Kali Linux
Favicon
KALI LINUX: Common Commands that you should know : PART 2
Favicon
Kali vs Ubuntu
Favicon
Fast nmap scanning
Favicon
File upload bypass using MIME-type
Favicon
How to get Kali tools and Snap on a Chromebook
Favicon
Installing Libre Office in Kali Linux
Favicon
Adaptador de red wireless BCM4360 en Kali Linux
Favicon
Kali VPN Tweaks for TryHackMe
Favicon
Top 6 Ethical Hacking Tools

Featured ones: