How is an image created by a PHP script? - php

I was looking at an possibly fraudulent eBay auction. However I am confused by an image within it, since it does not appear to be an image.
youneedtobuy.intothis.org/win.php
The complete HTML content of the url above is:
<body>
<img src="http://youneedtobuy.intothis.org/win.php" >
</body>
Here is a screen copy of the image, with the email address blurred out by me. There is no JS scripting, no CSS to speak of, just one line of code.
So, essentially the scammer can insert an 'image' into their eBay ad, and that image won't be scanned by normal tools.
How is this image created? And how could the friendly folks at ebay include a scanner in their system that has the ability to "see" this image (and preclude the scam from re-occurring?)

The image is likely created using PHP's file_get_contents() function. For example, the following PHP script will display the contents of myimage.jpg to the browser, but the file could be called show-image.php:
<?php
header("Content-Type: image/jpeg");
header("Content-Length: ".(string)(filesize('myimage.jpg')));
echo file_get_contents('myimage.jpg');
?>
As you can see, this is achieved by telling PHP to serve up the image/jpeg MIME type.

Any image can be returned by a script instead of a real file.
An alternative answer shows methods of doing this, but by using a script one can serve different images to different users, log IP address and other information thus tracking viewers etc.
It is also a common technique used to return thumbnail or summary images. e.g. using PHP and ImageMagick to generate an image of the first page of a PDF file.
Incidentally the image will be scanned by normal tools - they simply look for the image tags, not what extension the file has. What you are really saying is that the text contained within the image won't be processed or analysed, and the image does invite you to directly connect to someone, which is against eBays terms and conditions.

Related

Way to put PHP code into raw image pages

Is it possible to put PHP code into raw images?
For example:
http://gifsec.com/wp-content/uploads/GIF/2014/05/GIF-When-white-guys-dance.gif
If you go to that url you'll just see the raw image on a white page. Is it possible to somehow put code into this raw page? For example, you may want to put Google analytics tracking into raw image files so you can track people on reddit sharing raw files.
Not that I know of, what you may want to consider is having people share the link to that file so they can download it and then put code into the page that link redirects to that tracks or counts visitors. Tracking the visitor is harder and leads into ethical issues, so I would just set up google analytics and put their code into that page.
No,
http://gifsec.com/wp-content/uploads/GIF/2014/05/GIF-When-white-guys-dance.gif
is a resource on your server. that URL simply directs the browser to where the image is stored on the server.
to achieve what you want. simply create a page and include the image into
http://gifsec.com/GIF-When-white-guys-dance
<img src=''> on this page you can then add your Google analytic code.
Images are transferred from server to browser with binary encoding. this is why it will not work how you are thinking
You can hide anything you want in an image file. This is called steganography. The problem is that the code won't be executed unless it's uploaded to a server that is specifically set up to extract and run it.
It's not silly, just difficult. What you would have to do is use a PHP script to process it back. As such, your dance.gif would become dance.php and you would link to that. It will add some overhead to your server to do this so just be aware, however, this would allow you to track it via PHP. You could then import that data into Google Analytics at a later date.
Here's some pseudo code (we'll call this dance.php)
<?php
//Insert some tracking here, like a Database INSERT statement
$img = imagecreatefromgif('/path/to/dance.gif');
header('Content-Type: image/gif');
imagegif($image);
imagedestroy($image);
Then in your HTML
<img src="dance.php">
What you need is called pixel tracking also called web bug.
Take a look at this answer:
https://stackoverflow.com/a/13079838/797495

How to Crawl a PHP generated image

I have a website textscloud.com In this website i make the image with the PHP GD library. Here is a link to a demo:
In this page i allow the user to download the image on which text will pe printed. download link is like
This download.php file has a header for making the image with PHP GD Library and download the file like this
header("Content-type: image/png");
But google didn't crawl these images. Does anyone know the solution? I can't store these image in server.
You don't mention how you are feeding the beast, so I suggest you start by providing google a site map via their webmaster toolkit. You can specifically list the images that you want crawled. Google provides good help articles to get you going.
Google can't index images that are not stored permanently, I'm quite sure it can't even index images without context (i.e. which are not part of a describing/linking page).
You can try to:
Send a cache header to allow caching of the image.
Rewrite the actual url to someting like: http://textscloud.com/get_img/download/VkZaU1FtUXdNVVZWVkZKT1ZWUXdPUT09.png (should match your filename header)

PHP Using imagegrabscreen

How could I use imagegrabscreen to get a thumbnail image and a full size image of a specific website.
I was thinking that I could have an array that I feed the wanted uri's into but I am a bit stuck on how I would set the wxh of the image I need to grab. I also think that I would need a thumbnail class and a fullimage class and call them when required.
Any better Ideas?
Keep in mind that imagaegrabscreen is Windows-only. If you have multiple displays set up, this function will only grab the primary display. Also, for this to work, your Apache service must be set to Allow service to interact with desktop otherwise you will just get a blank image.
This discussion covers the use of imagegrabscreen pretty well: Getting imagegrabscreen to work
There are a lot of other discussions about saving webpages as images, too - here are a few:
Website screenshots
Web Page Screenshots with PHP?
How can I generate a screenshot of a webpage using a server-side script?
PHP: How to capture browser window screen with php?
What is the best way to create a web page thumbnail?
Screenshot of current page using PHP
shell tool which renders web site including javascript
In any languages, Can I capture a webpage and save it image file? (no install, no activeX)

Masking or hiding the path to a background image

I'm displaying pieces of an image in a large grid created from divs. I'm using the background-image and background-position to display portions of the image. The problem I'm running in to is that a user can simply open up firebug and see the entire image (which defeats the purpose of the game).
I've attempted to mask the path using a php script as the URL but if the user navigates to the php file, they can still see the image. It would appear that anything I do with the CSS is entirely client side so denying everything outside the localhost in my .htaccess won't work.
Any suggestions?
The over arching goal is to have an automated way to split and display pieces of the image into a grid.
If you deliver the whole image to the browser, the browser holds the image and has every right to show it to a user. I don't think you can prevent the browser from showing it. I'm afraid you will have to deliver the image in pieces, or perhaps write your whole game using <canvas> and play around with images as pixel data. :)

Image Preview using AJAX in PHP

How should i create a preview of image to be uploaded before it is actually submitted using AJAX in PHP?
Without uploading the image, this is going to be impossible in JavaScript as far as I can see, because security limitations are going to prevent you from determining the selected file in the file upload, and embedding that file in an img tag (as it used to be possible five years ago.)
You will be more lucky with Flash-based uploaders. I have seen some that offer the kind of functionality you want.
Update: Here's one that offers a preview function. From what I can see, it base64 encodes the local image and serves it to the surrounding HTML page as a inline data <img> tag. This is great because it might integrate well into your site. It does not work with any version of Internet Explorer, though.
Here's a fully Flash based solution that does previews in all browsers.
you first have to upload the document to server. Than you can show like.
<img src="uploads/file1_12224.jpg" />
The "file" input type doesn't expose the local file location of the file to be uploaded. It does "appear" to because as a user you can see the location, but the web page never knows this value. Without the local file address, you can't show a preview of the image on the web page using plain HTML or JavaScript.

Categories