Introduction
The project scans wifi networks in the area to retrieve names, speeds and MAC addresses that can then be used to make a geo-location request to Google's servers and was written using C# in VS2010 to produce a class library.
A service is provided to poll for new wifi connects every ten seconds or so and these connections are returned in a collection ready to be used as you like or saved as an XML table by calling Save(XMLFileName);
so that the data can be used by other programs.
Background
I was concerned with just what Google was uploading when someone in the area made a geo-location request and how my data was being used plus I wanted to build geo-location into the browser I have been working on.
Using the Code
Included is the full source code for the project along with output class library that has been compiled as a DLL and all the calls to the library use static
methods as shown below to make the code simple to use. Sample code is provided in the file Sample.cs.
Full credit given to NativeWifi who produces some of the open source Windows API calls used in the project .
WifiScanner.WifiConnection.Start(10000);
Thread.Sleep(30000);
WifiScanner.WifiConnection.Stop();
string Json=WifiScanner.WifiConnection.GetGeoLocation();
WifiScanner.WifiConnection.Clear();
Viewing the request sent to Google from your browser is not easy since it uses encrypted SSL packets but a little trick that works in Firefox is to type "About:config
" into the URL and then search for "Google
" and to then edit the Geo.Wifi.Url
value from being HTTPS to HTTP and to then make a geo-location request from the browser that uses a proxy server that allows you to inspect the outbound HTTP request header and XML post data.
POST /geolocation/v1/geolocate?key=abcdFakeKey HTTP/1.1
Host: www.xgoogleapis.com
Connection: keep-alive
Content-Length: 662
Pragma: no-cache
Cache-Control: no-cache
Content-Type: application/json
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Accept-Encoding: gzip, deflate
{"wifiAccessPoints":[{"age":1,"macAddress":"11-1d-aa-a6-13-38",
"signalStrength":-43},{"age":1,"macAddress":"11-1d-aa-a6-13-33",
"signalStrength":-44},{"age":1,"macAddress":"3a-b1-db-2c-53-a5",
"signalStrength":-56},{"age":1,"macAddress":"16-2d-26-35-d5-a8",
"signalStrength":-61},{"age":1,"macAddress":"11-21-14-d6-ee-82",
"signalStrength":-66},{"age":1,"macAddress":"16-21-14-d6-ee-82",
"signalStrength":-66},{"age":1,"macAddress":"e4-f4-c6-86-26-b8",
"signalStrength":-66},{"age":1,"macAddress":"1a-21-14-d6-ee-82",
"signalStrength":-68},{"age":1,"macAddress":"e4-f4-c6-86-26-b3",
"signalStrength":-68},{"age":1,"macAddress":"84-1b-5e-bb-2a-b8",
"signalStrength":-86}]}
This is my first project that I have released on CodeProject but keep watching if you want a fully working remote desktop or want to learn how to get "Play to" working in Windows without having to open lots of ports or to have all the correct Windows services running.
Enjoy!