Php-Jpeg-Injector Injects php payloads into jpeg images. Related to this post.
Exploiting PHP-GD Image Create From jpeg() Function
Proof-of-concept to exploit the flaw in the PHP-GD built-in function, image create from jpeg(). Inspired by one of Reddit’s comment on my previous thread regarding exploiting the image create from gif() PHP-GD function.
This is the script to generate the payload
<?php $jpg = imagecreatefromjpeg('image.jpg'); imagejpeg($jpg, 'poc.jpg'); imagedestroy($jpg); ?> This is the hexadecimal dump for the image.jpg before the recreation. Nothing fancy here, just some junk and EXIF data.
So this is what happens after the recreation of JPEG file, all the EXIF data is removed and not much empty space where we can append the PHP backdoor.
However, there are several important parts in the JPEG file format which can be exploited.
So according to this JPEG file format, where would be the place to put the PHP backdoor?. Search for the Start of Scan (SOS) marker which is FF DA, as you can see there are Scan Header Length and Scan Header after the SOS marker. The place to be put PHP backdoor is right after the Scan Header (00 0C 03 01 00 02 11 03 11 00 3F 00).
Run through the payload script again, and then the PHP backdoor will not get removed even after multiple times going through recreation process
<?php $jpg = imagecreatefromjpeg('poc.jpg'); imagejpeg($jpg, 'exploit.jpg'); imagedestroy($jpg); ?>
Starship is a powerful, minimal, and highly customizable cross-shell prompt designed to enhance the terminal…
Lemmy is an innovative, open-source platform designed for link aggregation and discussion, providing a decentralized…
The latest release of ImHex v1.37.0 introduces a host of exciting features and improvements, enhancing…
Ghauri is a cutting-edge, cross-platform tool designed to automate the detection and exploitation of SQL…
Writing tools have become indispensable for individuals looking to enhance their writing efficiency, accuracy, and…
PatchWerk is a proof-of-concept (PoC) tool designed to clean NTDLL syscall stubs by patching syscall…