Thursday, September 11, 2008

Google Android Reverse Geocoder Hack

I'm trying to publicize the Google Android Reverse Geocoder.
The problem is that the response comes in an unknown binary file format.
Only the Android.jar can decrypt it, and I can't decompile the JAR (cause it's not java bytecodes) to see how he does it.
Anyone has any brilliant idea on this matter?


The code follows:
Geocoder g = new Geocoder(this);
List
la = g.getFromLocation(51 , 0, 1); //somewhere in UK

then the Android makes a HTTP post to "http://www.google.com/loc/m/api" and from there comes the fiendish binary response.

5 comments:

sahn0 said...

Hi, I noticed your thread in android-developers, and I have some pointers.

First, you can use jad (search google) to decompile android.jar. I looked into Geocoder.java and getFromLocation method uses ILocationManager.getFromLocation. This interface is not implemented in android.jar and comes from one of pre-installed apks, I suppose.

Now, you need to find relevant apk file inside emulator, and decompile it. Apk is simple zip archive, and contains classes.dex, which is all its classes in .dex format. To decompile classes.dex, you can probably use dx.jar, which comes with sdk (tools\lib). There is com.android.dx.command.dump.Main class, which I *suppose* can help you to decode dex files.

Hope this helps.

m1ke said...

Thanks for the new URL :)

Now I am stuck with a "version mismatch" error. Did anyone dissect the packet yet?

Thanks,
Michael

Jader Dias said...

sahn0 is pointing the right way! thanks!

I haven't found the code that decodes the incoming packet, but I have already decompiled the whole API.

I don't know who is m1ke, or which URL he is talking about.

m1ke said...

Heh, I am just trying to figure out how to turn cell id's into lat/lng's :)

I was talking about http://www.google.com/loc/m/api, it used to be glm/mmap, no?

Jader Dias said...

I´m new to Android, so I don´t know if the URL has changed. But I recommend you to WireShark your application so you can find out which URL is being requested.