Created
July 18, 2009 13:37
-
-
Save dap/149564 to your computer and use it in GitHub Desktop.
Store PHP code in a JPEG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# write_jpg.pl - Store PHP code inside of a JPEG | |
# Darian Anthony Patrick <[email protected]> | |
# | |
# Demonstration of masquerading PHP code inside | |
# of a file identifiable as JPEG format | |
use perl5i; | |
use IO::All; | |
#Create "JPEG image data" and "JFIF standard" magic patterns | |
my $pat = pack('H4xxxxa*', 'ffd8', 'JFIF'); | |
# Output magic patterns followed by PHP code | |
io('/tmp/this_contains_php.jpg')->print( | |
$pat, | |
'<?php echo "\nThis output is from PHP code stored inside of a \"JPEG\".\n"; ?>' | |
); | |
say 'Completed "JPEG" creation.'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment