Make a jpeg or gif run php or javascript

frenchsquared

Registered Member
Joined
Jun 21, 2010
Messages
51
Reaction score
4
Has anyone heard of a way to get a jpeg to run a line of php or javascript.
I don't want to hack a server. I need a way to have an image set a cookie.
I just want a way to verify if a user loaded my image.

Clearly the image isnt hosted on my server or this would be easy.

I need the image to actually run some other code from a different domain
to set the cookie.

Think re-targeting advertising... not hacking...

I have googled this, for weeks. I don't want to exploit getimagesize();
 
i think you could use JavaScript to kick in when a image finally loads and then set cookie using javascript .
Edit :
my bad i didnt rad the JS part .
I think that's not possible , jpeg is just a format
 
it is super easy if you have access to the server the image will be on, or if you could us a php image
neither of these are an option. I have to upload the image to one of the larger advertising networks.
they distribute the image to there networks. So I have no idea where the images would end up.

But... If I could set a cookie... I could do lots of re-targeting advertising.

Basically, I need a hack that can add a virus to an image. Only this isn't a real virus
since it does not replicate or do any damage.
 
You want to upload pic to fb and cs all visitors of your fan page. Am I right?
It cant be done.
 
you would need to find a massive exploit in a browser / or a major flaw in an image standard.

this stuff is so widely used and scrutinized, its a very hard thing to do.

you won't find a wordpress plugin for that =)
 
<?php
$imgPng = imageCreateFromPng($strImagePath);
imageAlphaBlending($imgPng, true);
imageSaveAlpha($imgPng, true);


/* Output image to browser */
header("Content-type: image/png");
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1);
imagePng($imgPng);
?>


This will output a png while setting the cookie just call the php script on your html like following
<img src="link/to/your/phpfile.php"/>
 
if you are serious about this type of stuff, follow security mailing lists, everyday there are 0 days exploits/bugs reported that can be used toward your purpose.

but you need to know your stuff, and this stuff tend to get patched pretty quickly, the window of opportunity is small.
 
Back
Top