Hacking Google Map's Satellite Imagery

by Morcheeba

Interested in accessing Google's satellite imagery for other purposes?  The protocol isn't documented but it's fairly simple to reverse engineer.

The main application is a JavaScript application that handles the user interface.  The variable and function names have been run through an obfuscator, so the code is hard to read.  This isn't just a protection against reverse engineering - shorter names also make it quicker to download.

If you have a Google map running, you can use Safari's "Window -> Activities" screen to show all the image tiles loaded.  Each tile is a 256x256 pixel JPEG picture that is approximately 10-30 kB in size:

For example:


http://kh.google.com/kh?v=1&t=tqtsqrsttqtqttssr

The tiles come with the "©2005 Google" watermark already on them.

What's with the URL?

I was originally expecting some sort of longitude/latitude coordinates with some zoom factor, but this seems to be just a cryptic string of letters.  Well, it turns out there is a method to the madness and this format is simpler and more precise than a numeric encoding.

First off, the kh in the URL stands for Keyhole, which is the name of the satellite imagery tool company Google bought in 2004 (see www.keyhole.com).  It is also the name shared by the spy satellites operated by the National Reconnaissance Office.

The v= parameter is the JavaScript window._ktv value.  I'm not too sure what that is, but it isn't necessary in the URL.

All characters in the value of the t= parameter are either: q, r, s, or t

By searching the JavaScript, you can find a hard-coded starting point for all imagery:


http://kh.google.com/kh?t=t

When you append one of the four letters to the above link, you'll get one of these pictures:

Notice a pattern?  The appended letter specifies which quadrant to enlarge:

  q     r

  t     S

We start with the upper-left picture containing the northern hemisphere (t=tq) and add another letter - t - to zoom in on the lower-left corner.

(Note that requesting data for the dark upper corners returns a warning that Google has no coverage of that area.)


http://kh.google.com/kh?t=tqt

...and extracting the lower-right corner of that image yields:


http://kh.google.com/kh?t=tqts

The pattern is continued until the desired level of detail is reached.

Currently, there can be up to 18 characters following the t= tag, but Google could increase resolution in the future.

The technique used is a quadtree, a common computer graphics data structure used to efficiently access and store multiple resolution images.  As an added bonus, because no numbers are used, there are no rounding errors that could create artifacts at the edges of tiles.

Also, be aware that while Google has talked about opening up their API, they currently do not officially sanction this method of image retrieval.  Access to these pictures could be terminated at any time - either by making the server verify the HTTP GET header information (such as Referer), or by changing the access mechanism entirely.

Because users always download Google's most up-to-date JavaScript viewer, backwards compatibility does not need to be maintained.

Return to $2600 Index