This project went together smoother than I thought it would. The source code and application are available on it’s SourceForge page. I’m still working to create a range for the networks and then use circles as points. I’m thinking if I factor in strength, I can come up with an approximate (no where near exact) range. Unfortunately, without the right antenna, it’s not likely to come up with a direction but I can get the entry and exit and create a circle around it from that. Unfortunately, to convert the minute data to feet will take some fancy math due to variations in minutes with the longitude. More on that in a future post.
For those wanting to use the application, here are the steps to get it working.
Test with ‘sudo gpsbabel -T -i garmin -f /dev/ttyUSB0‘
If that pulls data, run ‘sudo ./garminwardriver.py‘
Open your ‘out.kml’ in Google Earth (Start Google Earth->File->Open)
And there you go, data that can be drawn on any wifi card with any GPS device (if you change the code for your device). Try it out and let me know if it works or what errors you come up with. This is just a prototype, so expect v1.01 to be out soon with updates.
I wrote this post and completely forgot to add the screen shots!
I’m very happy to say, this is a simple project, to get working in its most basic form. Note, I said it’s most basic form so no hate mail on the fact that this is nothing more than a quick script! There are plans to actually go deeper, make this open to more than my device, not use already existing programs, etc. But for the basic concept and starter, I’ve made this program use gpsbabel to get the gps information and iwlist to get the network information. I had started with pywifi but found this to be a problem because there was an overbound error. This bug will be reported, it seems it has a problem with converting an integer to a float on a 64bit machine.
So with no futher ado, here is the script:
import os, re, time
# DEATH FUNCTION
print ' [*] ERROR: %s' % msg
# ENSURE WE ARE ROOT
if os.getuid() != 0:
die('Run this program as root.')
# GET NETWORK INFO
nets = os.popen('iwlist %s scan' % dev).read()
pat = re.compile(r'ESSID:".*"')
mess = re.findall(pat, nets)
for find in mess:
# GET GPS INFO
pos = os.popen('gpsbabel -i garmin,get_posn -f %s' % dev).read()
pos = pos.splitlines().split(' ')
# RUN IT
found = getessid('eth1')
pos = getposition('/dev/ttyUSB0')
for find in found:
print 'ESSID: %s @ %s | %s' % (find,pos,pos)
if __name__ == '__main__':
So what you see here is that I’m using os.popen() to call my programs to draw data. Unfortunately, iwlist is painfully slow, to the point there’d be a five second delay on some slower machines between the call and having the data ready. This is why I want to develop the application to not be dependent on other programs, but for the time being, this works as proof of concept in the data gathering stage. It’s now just a matter of adjusting the code to run this constantly and load data to an overlay when entering and leaving an ESSID’s area.