I've been trying to figure how a html5 browser like chrome or firefox performs geolocation under the hood but I'm running into some difficulties.
Difficulties
To be more precise, I want to know what happens when a piece of javascript calls navigator.geolocation.getCurrentPosition (success_func)
but before success_func
actually gets called back. I want to know how the browser goes about obtaining the latitude and longitude coordinates. What's the protocol it uses? What servers does it query to obtain this information? etc.
Here's what I have determined and tried:
- Chrome and Firefox uses the MAC of nearby wifi access points to obtain geolocation by sending it to googlesapi.com. It is this MAC-wifi based implementation I am most interested in.
- By the time
success_func
gets called, the browser has already obtained the geolocation data. - I made limited progress using proxy and packet captures like tcpcatcher and wireshark. I see a query is being made to
googleapis.com:443
but of course it's over tls/ssl which means I can't read it. (using ssl monitor in tcpcatcher causes geoloc to fail in browser) - I tried using builtin devtool and console in browser but it seems to omit the communication that grabs the geoloc data. For example, using chrome's devtool (ctrl+shift+I), it does not show any
CONNECT
methods or connections togoogleapis.com
even though tcpcatcher clearly captures that during geolocation. - I've tried looking at the source to determine this but not having much luck. The problem is that browser codebases are just humongous and locating the pertinent class and source files would be difficult especially since I'm unfamiliar with their overall design. grepping for interesting keywords only goes so far.
If you guys were trying to determine and reverse the protocol a given browser uses to implement geolocation how would you guys proceed?
Other Resources
Here are some things I've already looked at that I found helpful:
- http://samy.pl/mapxss/
- https://stackoverflow.com/questions/3041113/how-exactly-does-html5s-geolocation-work
The problem is some of the info mentioned there is out-of-date and no longer accurate. My aim now is to figure out exactly what changed and how an external custom application can use this protocol itself for geolocation.
googleapis.com geolocation from mac address
into google to find the reference at developers.google.com/maps/documentation/business/geolocation/…. This includes a "WiFi access point objects" section. Jason is right, you don't need any reverse engineering.