Executable PHP in a GIF image

Status
Not open for further replies.
there is a much easier way. It's called the gd image library LOL. Look it up sometime

LOL I was talking about the GD. The GD library alone cannot help him display a php file WHILST still having the extension ".gif" they are just php functions. Thats when htaccess comes in.
 
Placing a code in image files still works! Awesome as always. Just make sure your server interprets the filetype as PHP. At the end of the php file use the GD library to display the image you like. thats it.
 
there is a tool called edjpgcom that hide a php in jpg file . I don't know if it acts like php scripts or not .
 
what about redirecting via .htaccess? I've seen this done before to stuff cookies.
 
there is a tool called edjpgcom that hides php in jpg files. I don't know if it acts like php scripts or not.


that program lets you edit comments in .jpg files.
doubtful the code would run when you view the .jpg

tsp
 
Yes it is possible don't have the time to code it right now but here's a hint of what I did last time I did it.

-Use htaccess to interpret that particular file as a php script i.e. first .gif is actually just a php file with .gif as an extension.

-Execute your php script, careful not to echo or print anything to the browser.

-Finally open your gif with your php file i.e. first .gif opens real .gif and prints the correct stuff to the browser.


fwiw... there is a web site that explains how to do this in detail, and has code that you can download and edit. i just saw it a few days ago.

do a search on 'cookie stuffing script' and you'll likely find it.

tsp
 
guys .. it not hard to create php commands ins in jpg files.

create a php file as normal. upload it to the server ... rename it to the image type you want. make your server (via htaccess file in this specific folder) handle this jpg or whatever image file as a php file. done :-)
 
Thats what my code posted above, its a way to have a dynamic sig built each time the image is called.
 
i just tried forcing the server to consider a jpg file
as a php file, but it didn't work.

this is the code, why isn't it working?

<Files test5.jpg>
ForceType application/x-httpd-php
</Files>

tsp
 
Just take a look at the link in my sig, its a php file, it spits out a random text, and a random color, and if i wanted to i could change the font at-will.

Pretty neat genjutsu :-)
Now that you say it i recognized it too :D
 
try and put the file in its own directory and then add this to your htaccess

AddType application/x-httpd-php .php .jpg .gif

Then in your php file make sure you have a correct header

eg

header("Content-type: image/png");


Look at the code I wrote its used for taking a image file and then over lays a random quote to it :-)
 
i just tried forcing the server to consider a jpg file
as a php file, but it didn't work.

this is the code, why isn't it working?

<Files test5.jpg>
ForceType application/x-httpd-php
</Files>

tsp

Try this...works for me with hostgator

<Files test5.jpg>
AddHandler application/x-httpd-php5 jpg
</files>
 
note: some servers won't accept 'forcetype'
so you must use 'sethandler' instead.

i've got it half right... still getting some errors.
will keep working on it...

tsp
 
Try this...works for me with hostgator

<files test5.jpg>
AddHandler application/x-httpd-php5 jpg
</files>


not quite... this is the correct format, you
must add a period before jpg -- like this:

<files test5.jpg>
AddHandler application/x-httpd-php5 .jpg
</files>

tested it and it works! :D

tsp
 
not quite... this is the correct format, you
must add a period before jpg -- like this:

<files test5.jpg>
AddHandler application/x-httpd-php5 .jpg
</files>

tested it and it works! :D

tsp

I'm messing with php to learn , so this would be on the .htaccess right?
We're telling the server to read all .php5 as .jpg
Wouldn't only the command AddHandler application/x-httpd-php5 .jpg
Be enough? Why include
<files test5.jpg>
</files>

?
 
Last edited:
I'm messing with php to learn , so this would be on the .htaccess right?
We're telling the server to read all .php5 as .jpg
Wouldn't only the command AddHandler application/x-httpd-php5 .jpg
Be enough? Why include
<files test5.jpg>
</files>


Yes, you are correct. In my case I only want to effect one file.
 
one thing i'm trying to do is to keep people from directly viewing a certain file (this has to do with cs).

this code doesn't work properly:

<?php
if(!$_SERVER['HTTP_REFERER']){
//
} else {
header("Location: http://www.ebay.com/?affid=12345");
}
?>

has anyone written anything on blocking direct access, so if someone enters the full url, they get taken to a different file or page? i don't want anyone to see that i'm using a fake image to stuff cookies. if they view the image it takes them to the ebay page.

this has been mentioned here, but nobody said how to do it.... :confused:
 
I'm messing with php to learn , so this would be on the .htaccess right?
We're telling the server to read all .php5 as .jpg
Wouldn't only the command AddHandler application/x-httpd-php5 .jpg
Be enough? Why include
<files test5.jpg>
</files>

?

The test5 is just the name of jpg file that you want to be treated as a php file. I think you could probably tell it to treat multiple files too...I just haven't needed to. It should be:
<files yourfilename.jpg>
</files>
 
one thing i'm trying to do is to keep people from directly viewing a certain file (this has to do with cs).

this code doesn't work properly:

<?php
if(!$_SERVER['HTTP_REFERER']){
//
} else {
header("Location: http://www.ebay.com/?affid=12345");
}
?>

has anyone written anything on blocking direct access, so if someone enters the full url, they get taken to a different file or page? i don't want anyone to see that i'm using a fake image to stuff cookies. if they view the image it takes them to the ebay page.

this has been mentioned here, but nobody said how to do it.... :confused:

The problem is $_SERVER['HTTP_REFERER'] will be set even if it is empty.. So you need to do the check based on the length of the string.. :)

if (strlen($_SERVER['HTTP_REFERER'])) {
// not blank
} else {
// blank
}
 
Status
Not open for further replies.
Back
Top