Extract GPS from Kismet log with ElementTree

I have read a lot of noise about ElementTree but never really used it. Tonight i need to extract a bunch of GPS data from a kismet log file. Let’s give it a try

from elementtree import ElementTree

data = open('Kismet-May-22-2005-4.xml','r').read()

detection = ElementTree.XML(data)

for node in detection.getchildren():
try:
print "SSID: " + node.find('SSID').text,
except AttributeError:pass  #hidden SSID
print "BSSID: " +  node.find('BSSID').text,
gps = node.find('gps-info')
print "Lon: " + gps.find('max-lon').text +  " Lat: "  + gps.find('max-lat').text

Really simple, and seems to offer really good speed. I now have another weapon for every day work.

Arpwatch on WRT54G

While running my access point in public mode, i want to know when people log in. This can be a good way to find intruders too, but not my purpose.
I decided to run arpwatch on my linksys access point, but this is not so easy ..

1) Mail

First you need to have sendmail on the WRT. So install mini_sendmail. Add a file /usr/sbin/sendmail that contains:

#!/bin/sh
/usr/sbin/mini_sendmail -t -sIP_of_your_mail_relay

Check that it ‘s working..

2) Arpwatch

Run arpwatch on the WRT throught this script:

#!/bin/sh
IFNAME=$(nvram get wifi_ifname)

case $1 in
start)
touch /tmp/arpwatch.dat
arpwatch -f /tmp/arpwatch.dat -i $IFNAME
;;
stop)
killall arpwatch
;;
*)
echo "usage: $0 (start|stop)"
exit 1
esac

exit $?

3) Check

Wait a bit, connect to your wifi, look at your email on the gateway. (root@gw) you will see something like this:

From: root@openwrt.local.net
Subject: new station

hostname: <unknown>
ip address: 192.168.2.1
ethernet address: 0:f:66:c7:b5:b1
ethernet vendor: <unknown>
timestamp: Tuesday, January 18, 2000 14:34:01 +0000

Enjoy :)

Small is beautifull: CherryPy

Today, I decided to write a new webapp (this will be out soon). I have been off since a while in the webapp developpement, so it’s a bit hard to start this new project.

I decided to look on recent Quixote’s developpement on Alinea. I first used the same components.. after 2 hours.. nothing works :

  • issues with session management, not really hard to fix
  • big trouble with _q_traversal, _q_index .. I really hate this stuff. I don’t really understand why quixote have a so complicated framework.

After 2 hours, I switched to something more friendly: CherryPy in 10 minutes I have the base working. I really like the way you can use medusa or mod_scgi in Quixote, but Webware, CherryPy, Zope have some simple components for sessions, and url handling: And this is so hard in Quixote :(

Shuttle ST62K (aka Zen) Fan issue

Like a lot of users, i get an issue with my fan on the Shuttle Xpc. In fact, i found a lot of comments over the net, that Shuttle used some bad fan in this boxes. Some users decide to use the waranty, but i don’t want to send this back to Paris, just to have another crappy fan.

I decided to change it by myself. But finding the right fan is really hard, because it’s 80mn x 80mn x 1.5mn fan. After a long search i decided to go to a tunning shop. (They have a bunch of various CPU fan).. The guy said to me: Ok, No problem. We have a video card fan that can feet .. Oh really a video fan ?

He give me a Zalman ZM-OP1

Despite this fan doesn’t have the exact same caracteristics as the default one, it perform quite the same. And it does even less noise. So i’m really happy :)

Many thanks to the shop: Tuning Informatique (http://www.tuninginformatique.com/)

update: fix the Zalman URL

Quick and Dirty: Speed up wifi lookup of ndiswrapper

Have you see how many time, it takes to ndiswrapper to deliver the scan result ? It’s about 3,25 sec on my builtin wireless card. This is too much no ? Specialy if you want to write a application to scan for AP level.

The quick and dirty way to fix that (it works fine for me.. perhaps others..) :

  • Edit iw_ndis.c
  • Search for iw_get_scan function
  • change this
//if (time_before(jiffies, handle->scan_timestamp + 3 * HZ))
if time_before(jiffies, handle->scan_timestamp)
return -EAGAIN;

This simply drop the 3 sec wait for results.. Now I get search results in 0.25 sec ;) .. Please report if this works for you !

Homemade Omnidirectionnal Wifi Antenna

Once again, i tested several wireless design.

The spider

The spider is a simple to do (really), quarter wave omni-directional antenna. The cost: a female N :) Beside this antenna doesn’t have any gain, it prove to be really usefull, mainly for wardriving because it’s small, and offer really better performance than the default PCMCIA builtins (because it’s a omni and this is very good for out-door use)

http://www.brest-wireless.net/albums/AntenneSpider/spider_1.sized.jpg

French reader can read the complete story of this spider. Original design can be found here. Another trick, i don’t use a 32 mn line but 0.95 * 32 ~ 30 mn

The 6db one

This one require a little more job. The design came from gumph website. In fact the main issue with this one is to cut the parts at the good size. I made a 8 parts one, and give me ~ 6db. I will add 4 others soon. More infos can be found here

http://www.brest-wireless.net/albums/AntenneOmni/omni_jkx_1.sized.jpg

The full photo album is on the Brest Wireless photo gallery.

Playing music on soundcard without locking

Why this soundcard allow me to play 2 mp3 at the same time while this doesn’t.. Hum good question. In fact to support this kind of stuff the sound card should support have some sub-device, to be sure .. simply aplay -l

Here on my shuttle .. not working

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: IXP [ATI IXP], device 0: ATI IXP AC97 [ATI IXP AC97]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: IXP [ATI IXP], device 1: ATI IXP IEC958 [ATI IXP IEC958 (AC97)]
Subdevices: 1/1
Subdevice #0: subdevice #0

Here on another box (VIA C3 based)

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: V8235 [VIA 8235], device 0: VIA 8235 [VIA 8235]
Subdevices: 4/4
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
card 0: V8235 [VIA 8235], device 1: VIA 8235 [VIA 8235]
Subdevices: 1/1
Subdevice #0: subdevice #0

So yes the C3 can play 4 stream at the same time, while the AC97 doesn’t.

Another way to do this is to use software mixing

Update:

To use the software mix in Alsa: simply change the pcm.default to pcm.dmix

#pcm.default cards.pcm.default
pcm.default pcm.dmix