Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this a web page or an image?

http://lcamtuf.coredump.cx/squirrel/

According to the author,

This is an embedded landing page for an image. You can link to this URL and get the HTML document you are viewing right now (soon to include essential squirrel facts); or embed the exact same URL as an image on your own squirrel-themed page: <a href="http://lcamtuf.coredump.cx/squirrel/">Click here!</a> <img src="http://lcamtuf.coredump.cx/squirrel/"> No server-side hacks involved - the magic happens in your browser.

In other words, if you pop that URL into your browser it renders as a web page, but you can also use the same URL as an image source.

What kind of witchcraft is at work here?

(Edit: source code from the above link if that site ever goes offline.)

like image 991
j08691 Avatar asked Jul 20 '12 21:07

j08691


People also ask

Is there a website that can identify an image?

Google's reverse image search is a breeze on a desktop computer. Go to images.google.com(Opens in a new window), click the camera icon, and either paste in the URL for an image you've seen online, upload an image from your hard drive, or drag an image from another window.

Whats is image in website?

A site image will differentiate your site from other Study Direct sites, making it easy for your students to identify it. Site images will appear next to the title of your site anywhere that it is found on Study Direct, for example on the home page.

How can I copy a web page as a picture?

Press Ctrl + L to highlight the URL, and then Ctrl + C to copy it to the clipboard. Press Ctrl + V to paste the URL into either of the services to save the file as a picture or a PDF.

Can I take a picture of something and search the web for it?

The Google Goggles app was an image recognition mobile app using visual search technology to identify objects through a mobile device's camera. Users take a photo of a physical object, and Google searches and retrieves information about the image.


2 Answers

The file you linked is a polyglot - a combination of languages. It can be read and understood as both an image and an HTML file. It's a simple trick. If you look at the HTML source you can see this at the top:

ÿØÿà 

A quick Google shows this looks like a JPEG header. What the creator does is store the HTML in JPEG metadata, and the JPEG image data in a html comment. Pretty nifty but not magic.

To hide the JPEG header he uses CSS rules to hide the body and show only some elements:

body { visibility: hidden; } .n { visibility: visible; position: absolute; ...... } 

Also note that it isn't valid HTML, for example because the comment to hide the image data is not closed, but that browsers still happily accept and render it.

like image 127
orlp Avatar answered Sep 29 '22 00:09

orlp


Its a html page with html content along with image data.

Check out the header, it contains jpg header. In the source the first line contains ÿØÿà which is a jpeg header. The url http://lcamtuf.coredump.cx/squirrel/index.html (appended index.html), clearly shows its an html file. So apparently this may be called both as a web page or an image!

You can easily rename a jpg file (or any image file) as .html & when you open in your browser, it would just show an image, just like any other image.

A recent similar trick I remember is that renaming gif to jpg as in here, but still the data is gif & the headers contain gif.

like image 36
gopi1410 Avatar answered Sep 29 '22 00:09

gopi1410