Geolocation wifi Scanner and Finder - CodeProject


: 2


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.


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);//Poll wifi connections every ten seconds
Thread.Sleep(30000);                    //Wait for three polls to complete
WifiScanner.WifiConnection.Stop();      //stop polling for new connections
string Json=WifiScanner.WifiConnection.GetGeoLocation(); //Ask Google for the json string
WifiScanner.WifiConnection.Clear();     //Clear any internal data

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
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


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.