A Logo

Feel free to include my content in your page via my
RSS feed

Help Irongeek.com pay for
bandwidth and research equipment:

Search Irongeek.com:

Affiliates:
ISDPodcast Button
RootSecure Button
Social-engineer-training Button
Irongeek Button

Web Hosting:
Dreamhost Logo
Help Irongeek.com pay for bandwidth and research equipment:

paypalpixle




Wigle Data to Google Earth (KML File)
Wigle Data to Google Earth (KML File)

Google Earth showing Wireless Access Points found by WiGLE along the Louisville, KY riverfront.

        WiGLE is an online database of Wireless Access Points (802.11A/B/G) that is contributed to by folks using Netstumbler, Kismet and other war driving tools. WiGLE has a web interface of its own as well as Java desktop client called JiGLE.  There is also a Google Maps interface for the data made by Meblah, but rendering a map with DHTML can be slow. That's why I wrote a PHP script that can take the cached data from JiGLE (found in the \JiGLE\WiGLEnet\data directory after you do a query) and turn it into a KML (Keyhole Markup Language) file that's easy to import into the Google Earth desktop application. With the generated KML file and Google Earth it's easy to view and parse the access point found by WiGLE users.

        To use the script make sure you have PHP installed on your box and issue a command like the following:

                php wigle-to-kml.php _39.0_-87.0_38.0_-86.0.autocache > mywaps.kml

        I generated my KML files by copying the autocache file from \JiGLE\WiGLEnet\data on my Windows box to a Linux box then using the PHP script, but you may be able to do it all from a Windows box if you have PHP installed. I then took the resulting KML file (mywaps.kml) and opened it in Google Earth on my Windows box. You will notice when you open the KML file that there are two different icons for WAPs:

          Obviously, the one on the left is for Access Points without WEP/WPA and the one on the right is for ones with WEP/WPA enabled. If someone wants to make be some better icons I'll use them.

 

 

 Happy Mapping.

 

Updated: 2/28/2007:

I Wrote a better app for WiGLE/Google Earth mapping.

Updated: 6/15/2006:

Download the source: wigle-to-kml.txt (Right click and save)

Once you have it downloaded change the file extension from ".txt" to ".php". I use to host a Gzipped version of the script, but this seemed to confuse the MS Windows folks. :) I've tested it with the latest Google Earth (4.0.1565 Beta) and it still seems to work fine. If you have a large data set from a big metropolitan area expect Google Earth to be rather slow. WiFi access point maps of Louisville Kentucky makes Google Earth grind, I don't want to imagine what places like New York or LA would make it do. If you want to turn your KML file output into a compresses KMZ file just Zip it and change the extension from ".zip" to ".kmz" and your done. For examples of how to use this script and its output see the two links below:

See the video HERE

WiFi Map of Louisville, Ky in KMZ format: HERE

Source Code:
<?php
//wigle-to-kml.php version 1.2
//Wigle to KML (Keyhole Markup Language) Script
// by Adrian "Irongeek" Crenshaw http://www.irongeek.com
//Turns an .autocache file (Found in JiGLE\WiGLEnet\data directory) into a kml file that can be loaded into Google Earth
//Example usage: php wigle-to-kml.php _39.0_-87.0_38.0_-86.0.autocache > mywaps.kml
//WAP Icon based on Netstumbler's
// Filter help from http://www.analysisandsolutions.com/code/phpxml.htm
// Ver 1.1 Put WEPed WAPS in separate Folder so you do not have to view them.
// Ver 1.2 Changed how bad characters are stripped from the SSID so they would not mess up the XML.
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<kml xmlns=\"http://earth.google.com/kml/2.0\">
<Folder>
<name>WiGLE Data</name>
<open>1</open>
";
PrintKMLFolder($argv[1], 'Wigle WiFi Map (WEP On)', 'Y');
PrintKMLFolder($argv[1], 'Wigle WiFi Map (WEP Off)', 'N');
echo "</Folder>
</kml>";

function PrintKMLFolder($InputFileName, $FolderName, $WEPStatus)
{
$handle = fopen($InputFileName, "r");
echo "<Folder>
<name>$FolderName</name>
<open>1</open>
";
$data = fgetcsv($handle, 1000, "~"); // Skip first line
while (($data = fgetcsv($handle, 1000, "~")) !== FALSE) {
$ssid = $data[2];
// Escape ampersands that aren't part of entities.
$ssid= preg_replace('/&(?!\w{2,6};)/', '&amp;', $ssid );
// Remove all non-visible characters except SP, TAB, LF and CR.
$ssid = preg_replace('/[^\x20-\x7E\x09\x0A\x0D]/', "\n", $ssid );

if($data[9]==$WEPStatus){
echo "<Placemark>
<description>
<![CDATA[
SSID: $ssid<BR>
BSSID: $data[3]<BR>
WEP: $data[9]<BR>
CHANNEL: $data[5]<BR>
QOS: $data[11]
]]>
</description>
<name><![CDATA[$ssid]]></name>
<Style>
<IconStyle>
<Icon>";
//Choose Folder and Icon depending on WEP status.
if($data[9]=='N') {
echo "<href>http://irongeek.com/images/wap.png</href>";
} else {
echo "<href>http://irongeek.com/images/wapwep.png</href>";
}
echo "</Icon>
</IconStyle>
</Style>
<Point id=\"khPoint557\">
<coordinates>$data[1],$data[0],0</coordinates>
</Point>
</Placemark>";
}
}
echo "\n</Folder>\n";
fclose($handle);
return;
}
?>



Printable version of this article

15 most recent posts on Irongeek.com:


If you would like to republish one of the articles from this site on your webpage or print journal please contact IronGeek.

Copyright 2014, IronGeek
Louisville / Kentuckiana Information Security Enthusiast