Differences between revisions 26 and 29 (spanning 3 versions)
Revision 26 as of 2007-10-14 17:43:57
Size: 28008
Comment: incremental mods for an updated openwrt version
Revision 29 as of 2007-11-08 16:41:08
Size: 13292
Comment: adding back info on how mp3's were constructed
Deletions are marked like this. Additions are marked like this.
Line 26: Line 26:
Currently, I am using the kamikaze svn tree. This description is based on the already obsolete r9287. Currently, I am using the kamikaze svn tree. This description is based on the already obsolete r9512.
Line 30: Line 30:
svn co https://svn.openwrt.org/openwrt/trunk
svn co https://svn.openwrt.org/openwrt/packages
cd /src/openwrt/trunk
git clone git://nbd.name/openwrt.git
git clone git://nbd.name/packages.git
mkdir build
cd openwrt
git clone -l -s . ../build/r9512
cd ../build/r9512
Line 34: Line 37:
cd /src/openwrt/trunk/package
for i in $(find ../../packages -type d | grep -v .svn | awk -F/ 'NF==5') ; do echo $i ; ln -s $i $(echo $i | awk -F/ '{ print $5 }') ; done

# add package infrastructure for an older version of gpsd (v2.9)
mkdir /src/openwrt/trunk/package/gpsd-old
cd /src/openwrt/trunk/package/gpsd-old
wget http://www.personaltelco.net/~russell/gpsd-old-makefile
mv gpsd-old-makefile Makefile

cd /src/openwrt/trunk
cd package
for i in $(find ../../../packages -type d | grep -v .svn | awk -F/ 'NF==6') ; do echo $i ; ln -s $i $(echo $i | awk -F/ '{ print $6 }') ; done
}}}

Right now there are two tweaks I am doing to the stock trunk. One is that I am upgrading kismet to 2007-10-R1 and I am using a tweaked svn gpsd. If you disable enough stuff and reduce array sizes enough the current gpsd is usable. I am working on getting these accepted into openwrt. In the meantime, please contact me for my patches.

{{{
cd /src/openwrt/build/r9512
Line 45: Line 46:
make
}}}

In the menuconfig, I set the Target System to (Broadcom BCM947xx/953xx [2.6]), and for kicks I also "Select all packages by default" and enable a few things (which I am currently forgetting) that don't automatically get configured in. Often, you will find packages that won't build for some reason or another. In those cases, open a ticket, deconfigure the package in menuconfig and try again. Run {{{make}}} alone to see abbreviated messages, or {{{make V=99}}} to get lots of information. The configuration I used for r9287 can be found [http://www.personaltelco.net/~russell/kamikaze/config-r9287 here].
script
make V=99
exit

}}}

In the menuconfig, I set the Target System to (Broadcom BCM947xx/953xx [2.6]), and for kicks I also "Select all packages by default" and enable a few things (which I am currently forgetting) that don't automatically get configured in. Often, you will find packages that won't build for some reason or another. In those cases, open a ticket, deconfigure the package in menuconfig and try again. Run {{{make}}} alone to see abbreviated messages, or {{{make V=99}}} to get lots of information. The configuration I used for r9512 can be found [http://www.personaltelco.net/~russell/openwrt/config-r9512-2.6 here].
Line 52: Line 55:
 * {{{/src/openwrt/trunk/bin}}} contains the flashable images
 * {{{/src/openwrt/trunk/bin/packages}}} contains the .ipk files
 * {{{/src/openwrt/build/r9512/bin}}} contains the flashable images
 * {{{/src/openwrt/build/r9512/bin/packages}}} contains the .ipk files
Line 58: Line 61:
rsync -v -a -H /src/openwrt/trunk/bin/packages/ donk.personaltelco.net:public_html/openwrt/r9287/ rsync -v -a -H /src/openwrt/build/r9512/bin/packages/ donk.personaltelco.net:public_html/openwrt/r9512/
Line 78: Line 81:
cp /src/openwrt/trunk/bin/openwrt-wgt634u-2.6-jffs2.bin /var/lib/tftpboot/wgt634u/openwrt-wgt634u-2.6-jffs2-r5952.bin cp /src/openwrt/build/r9512/bin/openwrt-wgt634u-2.6-jffs2.bin /var/lib/tftpboot/wgt634u/openwrt-wgt634u-2.6-jffs2-r9512.bin
Line 132: Line 135:
CFE> flash -noheader 192.168.0.5:wgt634u/openwrt-wgt634u-2.6-jffs2-r9287.bin flash0.os CFE> flash -noheader 192.168.0.5:wgt634u/openwrt-wgt634u-2.6-jffs2-r9512.bin flash0.os
Line 143: Line 146:
src snapshots http:///206.163.122.98~russell/kamikaze/r5952 src snapshots http:///206.163.122.98/~russell/openwrt/r9512
Line 158: Line 161:
ipkg install kmod-usb-storage kmod-usb-serial-pl2303 gpsd-old kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-sound-core kmod-usb-audio madplay
 }}}

 * Install the statically-linked MIPS binary of kismet from [http://www.kismetwireless.net/code/kismet-2006-04-R1-wrt54.tar.gz here] and copy it somewhere useful:

 {{{
ipkg install ip kmod-usb-storage kmod-usb-serial-pl2303 gpsd-beta libstdcpp kismet-server kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-sound-core kmod-usb-audio madplay
 }}}

 * modify /etc/banner to reflect the svn snapshot.

 * disable a few extraneous things:

{{{
mv /etc/init.d/httpd /etc/init.d/httpd_
}}}

 * download the "extra" files:

{{{
Line 165: Line 176:
wget http://www.kismetwireless.net/code/kismet-2006-04-R1-wrt54.tar.gz
tar xzvf kismet-2006-04-R1-wrt54.tar.gz
cp kismet-2006-04-R1-wrt54/kismet_server /usr/bin/
 }}}

 * add an /etc/kismet.conf. Here's the one I am using, derived from one from JasonMcArthur:

 {{{
# Kismet config file
# Most of the "static" configs have been moved to here -- the command line
# config was getting way too crowded and cryptic. We want functionality,
# not continually reading --help!

# Version of Kismet config
version=2005.01.R1

# Name of server (Purely for organiational purposes)
servername=Kismet

# User to setid to (should be your normal user)
suiduser=root

# Sources are defined as:
# source=cardtype,interface,name[,initialchannel]
# Card types and required drivers are listed in the README.
# The initial channel is optional, if hopping is not enabled it can be used
# to set the channel the interface listens on.
# YOU MUST CHANGE THIS TO BE THE SOURCE YOU WANT TO USE
# source=wrt54g,eth1,wireless
# For v1 hardware uncomment this:
# source=wrt54g,eth2,wireless
source=madwifi_g,wifi0,wgt634u

# Comma-separated list of sources to enable. This is only needed if you defined
# multiple sources and only want to enable some of them. By default, all defined
# sources are enabled.
# For example:
# enablesources=prismsource,ciscosource

# Do we channelhop?
channelhop=true

# How many channels per second do we hop? (1-10)
channelvelocity=5

# By setting the dwell time for channel hopping we override the channelvelocity
# setting above and dwell on each channel for the given number of seconds.
#channeldwell=10

# Do we split channels between cards on the same spectrum? This means if
# multiple 802.11b capture sources are defined, they will be offset to cover
# the most possible spectrum at a given time. This also controls splitting
# fine-tuned sourcechannels lines which cover multiple interfaces (see below)
channelsplit=true

# Basic channel hopping control:
# These define the channels the cards hop through for various frequency ranges
# supported by Kismet. More finegrain control is available via the
# "sourcechannels" configuration option.
#
# Don't change the IEEE80211<x> identifiers or channel hopping won't work.

# Users outside the US might want to use this list:
# defaultchannels=IEEE80211b:1,7,13,2,8,3,14,9,4,10,5,11,6,12
defaultchannels=IEEE80211b:1,6,11,2,7,3,8,4,9,5,10

# 802.11g uses the same channels as 802.11b...
defaultchannels=IEEE80211g:1,6,11,2,7,3,8,4,9,5,10

# 802.11a channels are non-overlapping so sequential is fine. You may want to
# adjust the list depending on the channels your card actually supports.
# defaultchannels=IEEE80211a:36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,149,153,157,161,184,188,192,196,200,204,208,212,216
defaultchannels=IEEE80211a:36,40,44,48,52,56,60,64

# Combo cards like Atheros use both 'a' and 'b/g' channels. Of course, you
# can also explicitly override a given source. You can use the script
# extras/listchan.pl to extract all the channels your card supports.
defaultchannels=IEEE80211ab:1,6,11,2,7,3,8,4,9,5,10,36,40,44,48,52,56,60,64

# Fine-tuning channel hopping control:
# The sourcechannels option can be used to set the channel hopping for
# specific interfaces, and to control what interfaces share a list of
# channels for split hopping. This can also be used to easily lock
# one card on a single channel while hopping with other cards.
# Any card without a sourcechannel definition will use the standard hopping
# list.
# sourcechannels=sourcename[,sourcename]:ch1,ch2,ch3,...chN

# ie, for us channels on the source 'prism2source' (same as normal channel
# hopping behavior):
# sourcechannels=prism2source:1,6,11,2,7,3,8,4,9,5,10

# Given two capture sources, "prism2a" and "prism2b", we want prism2a to stay
# on channel 6 and prism2b to hop normally. By not setting a sourcechannels
# line for prism2b, it will use the standard hopping.
# sourcechannels=prism2a:6

# To assign the same custom hop channel to multiple sources, or to split the
# same custom hop channel over two sources (if splitchannels is true), list
# them all on the same sourcechannels line:
# sourcechannels=prism2a,prism2b,prism2c:1,6,11

# Port to serve GUI data
tcpport=2501
# People allowed to connect, comma seperated IP addresses or network/mask
# blocks. Netmasks can be expressed as dotted quad (/255.255.255.0) or as
# numbers (/24)
allowedhosts=127.0.0.1
# Maximum number of concurrent GUI's
maxclients=5

# Do we have a GPS?
gps=true
# Host:port that GPSD is running on. This can be localhost OR remote!
gpshost=127.0.0.1:2947
# Do we lock the mode? This overrides coordinates of lock "0", which will
# generate some bad information until you get a GPS lock, but it will
# fix problems with GPS units with broken NMEA that report lock 0
gpsmodelock=false

# Packet filtering options:
# filter_tracker - Packets filtered from the tracker are not processed or
# recorded in any way.
# filter_dump - Packets filtered at the dump level are tracked, displayed,
# and written to the csv/xml/network/etc files, but not
# recorded in the packet dump
# filter_export - Controls what packets influence the exported CSV, network,
# xml, gps, etc files.
# All filtering options take arguments containing the type of address and
# addresses to be filtered. Valid address types are 'ANY', 'BSSID',
# 'SOURCE', and 'DEST'. Filtering can be inverted by the use of '!' before
# the address. For example,
# filter_tracker=ANY(!00:00:DE:AD:BE:EF)
# has the same effect as the previous mac_filter config file option.
# filter_tracker=...
# filter_dump=...
# filter_export=...

# Alerts to be reported and the throttling rates.
# alert=name,throttle/unit,burst
# The throttle/unit describes the number of alerts of this type that are
# sent per time unit. Valid time units are second, minute, hour, and day.
# Burst describes the number of alerts sent before throttling takes place.
# For example:
# alert=FOO,10/min,5
# Would allow 5 alerts through before throttling is enabled, and will then
# limit the number of alerts to 10 per minute.
# A throttle rate of 0 disables throttling of the alert.
# See the README for a list of alert types.
alert=NETSTUMBLER,5/min,2
alert=WELLENREITER,5/min,2
alert=LUCENTTEST,5/min,2
alert=DEAUTHFLOOD,5/min,4
alert=BCASTDISCON,5/min,4
alert=CHANCHANGE,5/min,4
alert=AIRJACKSSID,5/min,2
#alert=PROBENOJOIN,5/min,2
alert=DISASSOCTRAFFIC,5/min,2
alert=NULLPROBERESP,5/min,5
#alert=BSSTIMESTAMP,5/min,5

# Known WEP keys to decrypt, bssid,hexkey. This is only for networks where
# the keys are already known, and it may impact throughput on slower hardware.
# Multiple wepkey lines may be used for multiple BSSIDs.
# wepkey=00:DE:AD:C0:DE:00,FEEDFACEDEADBEEF01020304050607080900

# Is transmission of the keys to the client allowed? This may be a security
# risk for some. If you disable this, you will not be able to query keys from
# a client.
allowkeytransmit=true

# How often (in seconds) do we write all our data files (0 to disable)
#writeinterval=300
#writeinterval=20
writeinterval=1800

# Where do we get our manufacturer fingerprints from? Assumed to be in the
# default config directory if an absolute path is not given.
ap_manuf=ap_manuf
client_manuf=client_manuf

# Use metric measurements in the output?
metric=false

# Do we write waypoints for gpsdrive to load? Note: This is NOT related to
# recent versions of GPSDrive's native support of Kismet.
waypoints=false
# GPSMap waypoint file. This WILL be truncated.
waypointdata=%h/.gpsdrive/way_kismet.txt

# How many alerts do we backlog for new clients? Only change this if you have
# a -very- low memory system and need those extra bytes, or if you have a high
# memory system and a huge number of alert conditions.
alertbacklog=50

# File types to log, comma seperated
# dump - raw packet dump
# network - plaintext detected networks
# csv - plaintext detected networks in CSV format
# xml - XML formatted network and cisco log
# weak - weak packets (in airsnort format)
# cisco - cisco equipment CDP broadcasts
# gps - gps coordinates
logtypes=gps,network,csv,xml

# Do we track probe responses and merge probe networks into their owners?
# This isn't always desireable, depending on the type of monitoring you're
# trying to do.
trackprobenets=true

# Do we log "noise" packets that we can't decipher? I tend to not, since
# they don't have anything interesting at all in them.
noiselog=false

# Do we log corrupt packets? Corrupt packets have enough header information
# to see what they are, but someting is wrong with them that prevents us from
# completely dissecting them. Logging these is usually not a bad idea.
corruptlog=true

# Do we log beacon packets or do we filter them out of the dumpfile
#beaconlog=true
beaconlog=false

# Do we log PHY layer packets or do we filter them out of the dumpfile
phylog=true

# Do we mangle packets if we can decrypt them or if they're fuzzy-detected
mangledatalog=true

# Do we do "fuzzy" crypt detection? (byte-based detection instead of 802.11
# frame headers)
# valid option: Comma seperated list of card types to perform fuzzy detection
# on, or 'all'
fuzzycrypt=wtapfile,wlanng,wlanng_legacy,wlanng_avs,hostap,wlanng_wext

# What type of dump do we generate?
# valid option: "wiretap"
dumptype=wiretap
# Do we limit the size of dump logs? Sometimes ethereal can't handle big ones.
# 0 = No limit
# Anything else = Max number of packets to log to a single file before closing
# and opening a new one.
dumplimit=0

# Do we write data packets to a FIFO for an external data-IDS (such as Snort)?
# See the docs before enabling this.
#fifo=/tmp/kismet_dump

# Default log title
logdefault=wgt634u

# logtemplate - Filename logging template.
# This is, at first glance, really nasty and ugly, but you'll hardly ever
# have to touch it so don't complain too much.
#
# %n is replaced by the logging instance name
# %d is replaced by the current date as Mon-DD-YYYY
# %D is replaced by the current date as YYYYMMDD
# %t is replaced by the starting log time
# %i is replaced by the increment log in the case of multiple logs
# %l is replaced by the log type (dump, status, crypt, etc)
# %h is replaced by the home directory
# ie, "netlogs/%n-%d-%i.dump" called with a logging name of "Pok" could expand
# to something like "netlogs/Pok-Dec-20-01-1.dump" for the first instance and
# "netlogs/Pok-Dec-20-01-2.%l" for the second logfile generated.
# %h/netlots/%n-%d-%i.dump could expand to
# /home/foo/netlogs/Pok-Dec-20-01-2.dump
#
# Other possibilities: Sorting by directory
# logtemplate=%l/%n-%d-%i
# Would expand to, for example,
# dump/Pok-Dec-20-01-1
# crypt/Pok-Dec-20-01-1
# and so on. The "dump", "crypt", etc, dirs must exist before kismet is run
# in this case.
logtemplate=%n-%d-%i.%l

# Where do we store the pid file of the server?
piddir=/var/run/

# Where state info, etc, is stored. You shouldnt ever need to change this.
# This is a directory.
configdir=/tmp/.kismet/

# cloaked SSID file. You shouldn't ever need to change this.
ssidmap=ssid_map

# Group map file. You shouldn't ever need to change this.
groupmap=group_map

# IP range map file. You shouldn't ever need to change this.
ipmap=ip_map
 }}}

 * Remove annoying OpenWrt-standard files that aren't needed or get in the way:
  * /etc/hotplug.d/block/01-mount
  * /etc/init.d/S50httpd

 * Make a home directory:
 {{{
mkdir -p /home/kismet
 }}}

 * Add various scripts:
  * /etc/init.d/S90usbfs
  {{{
#!/bin/sh
#
# mount /proc/bus/usb
mount -t usbfs none /proc/bus/usb/
  }}}

  * /etc/init.d/S95setclock
wget http://206.163.122.98/~russell/r9512-extra-files.tar.gz
cd /
tar xzvf /tmp/r9512-extra-files.tar.gz
}}}

  Among the extra files are:

  * /etc/init.d/setclock
Line 489: Line 196:
DEV=/dev/usb/tts/0 DEV=/dev/ttyUSB0
Line 498: Line 205:
if ! pidof gpsd ; then
        gpsd -n ${DEV}
fi

sleep 5

${PLAY} ${SOUNDDIR}/fixing.mp3

date -s $(awk -F, -f /usr/lib/setclock.awk ${DEV})
Line 499: Line 216:
if pidof gpsd ; then if pidof gpsd ; then  
Line 501: Line 218:
        PID=$(pidof gpsd)
        kill ${PID}
        wait ${PID}
fi

# restart gpsd in no-wait mode
echo "restarting gpsd"
gpsd -n -p ${DEV}

# looking for gps fix
while [ $(echo "s" | nc 127.0.0.1 2947 | sed 's/^GPSD,S=//') -le "0" ] ; do
        echo "waiting for a fix"
        ${PLAY} ${SOUNDDIR}/fixing.mp3
        sleep 1
done

# looking for a gps date/time
while true ; do
        echo "d" | nc 127.0.0.1 2947 | sed 's/^GPSD,D=//' | tr 'ZT:-' ' ' > /tmp/gpsdate
        if [ $(cut -d' ' -f1 /tmp/gpsdate) -ge 2006 ]; then
                echo "got a date"
                ${PLAY} ${SOUNDDIR}/setting-clock.mp3
                date -s $(awk '{ printf("%s%s%s%s%s.%d",$2,$3,$4,$5,$1,int($6+0.5)) }' /tmp/gpsdate)
                break
        fi
        echo "waiting for a date"
        ${PLAY} ${SOUNDDIR}/waiting.mp3
        sleep 1
done

echo "cleaning up"
PID=$(pidof gpsd)
kill ${PID}
wait ${PID}
rm -f /tmp/gpsdate
        PID=$(pidof gpsd)
        kill ${PID}
        wait ${PID}
fi
                                
Line 538: Line 224:
  }}}

  * /etc/init.d/S97kismet
}}}

  * /usr/lib/setclock.awk

  {{{
$1 ~ /GPRMC/ && $3 ~ /A/ { printf "%s%s%s%s20%s.%s",substr($10,3,2),substr($10,1,2),substr($2,1,2),substr($2,3,2),substr($10,5,2),substr($2,5,2) ; exit }
$1 ~ /GPRMC/ && $3 !~ /A/ { nofix++ ; if (nofix % 5 == 0) { system("/usr/bin/play /usr/share/sounds/fixing.mp3") } }
}}}

  * /etc/init.d/kismet
Line 551: Line 245:
  }}}

  * /usr/sbin/kismet_wrapper: This version watches for the presence of a USB device (a Linksys DBT-120 bluetooth dongle, but the script can be adapted to look for any vendor id) and starts/stops kismet_server accordingly.
}}}

  * /usr/bin/play

  {{{
#!/bin/sh

/usr/bin/madplay -Q -a -10 --no-tty-control $@
}}}

  * /usr/sbin/kismet_wrapper
Line 561: Line 264:
CMDSTR="/usr/bin/kismet_server -r -f /etc/kismet.conf" CMDSTR="/usr/bin/kismet_server -f /etc/kismet.conf"
MNT=/mnt/usbdrive
DEV=/dev/ttyUSB0
Line 585: Line 290:
            while [ ! -c /dev/usb/tts/0 ]; do             while [ ! -c ${DEV} ]; do
Line 593: Line 298:
            gpsd -p /dev/usb/tts/0             gpsd ${DEV}
Line 606: Line 311:
                mount /dev/sda1 /home/kismet                 mount /dev/sda1 ${MNT}
Line 611: Line 316:
            cd /home/kismet             cd ${MNT}
Line 620: Line 325:
             ${PLAY} ${SOUNDDIR}/kismet-stopped.mp3
             cd /tmp
             while grep -q '^/dev/sda1' /proc/mounts ; do
              ${PLAY} ${SOUNDDIR}/unmounting-storage.mp3
                 umount /home/kismet
             
sleep 1
             done
             
${PLAY} ${SOUNDDIR}/storage-unmounted.mp3
             ${PLAY} ${SOUNDDIR}/rebooting.mp3
             reboot
                ${PLAY} ${SOUNDDIR}/kismet-stopped.mp3
                cd /tmp
                while grep -q '^/dev/sda1' /proc/mounts ; do
                 ${PLAY} ${SOUNDDIR}/unmounting-storage.mp3
                    umount ${MNT}
                
sleep 1
                done
                
${PLAY} ${SOUNDDIR}/storage-unmounted.mp3
                ${PLAY} ${SOUNDDIR}/rebooting.mp3
                reboot
Line 636: Line 341:
                if [ -c /dev/usb/tts/0 ]; then                 if [ -c ${DEV} ]; then
Line 638: Line 343:
                    gpsd -p /dev/usb/tts/0                     gpsd ${DEV}
Line 662: Line 367:
                umount /home/kismet                 umount ${MNT}
Line 681: Line 386:
  }}}

  * Make scripts executable:
  {{{
chmod 755 /etc/init.d/S90usbfs
chmod 755 /etc/init.d/S95setclock
chmod 755 /etc/init.d/S97kismet
chmod 755 /usr/sbin/kismet_wrapper
  }}}

=== Adding Sound ===

For this, you need a usb-audio device and some additional software:

 * I am using the Turtle Beach Audio Advantage Micro device (CompUSA, roughly $25)

 * Install sound packages:
 {{{
ipkg install kmod-alsa
ipkg install kmod-soundcore
ipkg install madplay
 }}}
}}}
Line 705: Line 389:
Line 708: Line 393:
 }}}

 * Create a wrapper for madplay (to enclose the options). The soundopts feature in the kismet.conf file is broken because of the way they are concatenated in the call to execve().
 {{{
cat > /usr/bin/play <<EOF
#!/bin/sh

/usr/bin/madplay -Q -a -10 --no-tty-control $@
EOF
chmod 755 /usr/bin/play
 }}}

 * Insert the following into /etc/kismet.conf
 {{{
# Do we use sound?
# Not to be confused with GUI sound parameter, this controls wether or not the
# server itself will play sound. Primarily for headless or automated systems.
sound=true
# Path to sound player
soundplay=/usr/bin/play
# Optional parameters to pass to the player
# soundopts=
# soundopts=--volume=.3
# New network found
sound_new=/usr/share/sounds/network.mp3
# Wepped new network
# sound_new_wep=${prefix}/com/kismet/wav/new_wep_network.wav
# Network traffic sound
sound_traffic=/usr/share/sounds/traffic.mp3
# Network junk traffic found
sound_junktraffic=//usr/share/kismet/wav/junk_traffic.mp3
# GPS lock aquired sound
# sound_gpslock=/usr/share/kismet/wav/foo.wav
# GPS lock lost sound
# sound_gpslost=/usr/share/kismet/wav/bar.wav
# Alert sound
sound_alert=//usr/share/kismet/wav/alert.mp3
 }}}
}}}

Netgear WGT634U-based Network Stumbler

The Jason McArthur Version

As early as the summer or early autumn of 2005, JasonMcArthur began working on a Netgear WGT634U-based stumbler device, based on OpenWgt and a 2.4.20 kernel.

  • [Need OpenWgt-based stumbler construction instructions here]

The Russell Senior Version

In early March of 2006, RussellSenior began sponging off of JasonMcArthur's work and assistance. Eventually, because he didn't have access to JasonMcArthur's build environment, and because he was seeing some problems that he didn't understand and needed to fiddle with, he began diverging from JasonMcArthur's image, and began playing with an OpenWrt-derived stumbler instead, principally because he understood how to build packages using its buildroot environment.

This is a description of how RussellSenior goes about building a stumbler device based on the NetgearWgt643u and OpenWrt. This is experimental software. Follow these instructions at your own risk.

Hardware

  • Netgear WGT634U
  • USB2 hub
  • USB storage device
  • USB GPS device (such as the GlobalSat BU-353)

  • 3.3V serial console cable for WGT634U
  • random, compact USB device (used as an enable-key)

Building OpenWrt Software

Currently, I am using the kamikaze svn tree. This description is based on the already obsolete r9512.

cd /src/openwrt
git clone git://nbd.name/openwrt.git
git clone git://nbd.name/packages.git
mkdir build
cd openwrt
git clone -l -s . ../build/r9512
cd ../build/r9512
ln -s /src_archive/openwrt/dl .  # an existing archive of downloaded packages
cd package
for i in $(find ../../../packages -type d | grep -v .svn | awk -F/ 'NF==6') ; do echo $i ; ln -s $i $(echo $i | awk -F/ '{ print $6 }') ; done

Right now there are two tweaks I am doing to the stock trunk. One is that I am upgrading kismet to 2007-10-R1 and I am using a tweaked svn gpsd. If you disable enough stuff and reduce array sizes enough the current gpsd is usable. I am working on getting these accepted into openwrt. In the meantime, please contact me for my patches.

cd /src/openwrt/build/r9512
make menuconfig
script
make V=99
exit

In the menuconfig, I set the Target System to (Broadcom BCM947xx/953xx [2.6]), and for kicks I also "Select all packages by default" and enable a few things (which I am currently forgetting) that don't automatically get configured in. Often, you will find packages that won't build for some reason or another. In those cases, open a ticket, deconfigure the package in menuconfig and try again. Run make alone to see abbreviated messages, or make V=99 to get lots of information. The configuration I used for r9512 can be found [http://www.personaltelco.net/~russell/openwrt/config-r9512-2.6 here].

When the build is complete, the resulting files will be found thusly:

  • /src/openwrt/build/r9512/bin contains the flashable images

  • /src/openwrt/build/r9512/bin/packages contains the .ipk files

Now, you can copy the ipkg repository somewhere wget'able, e.g.:

rsync -v -a -H /src/openwrt/build/r9512/bin/packages/ donk.personaltelco.net:public_html/openwrt/r9512/

Checking out the WGT634U

If this is a new device, it is probably a good idea to check it out on the stock firmware first to make sure it functions.

  • apply power
  • use another computer to associate over the wireless

The Flash Environment

There is more than one way to flash the newly-built image onto the WGT634U.

CFE TFTP Flash-From-Console Method

This is the method I tend to use. For this, you will need a TFTP server and a serial console cable. On my debian/unstable box, I use the tftpd-hpa package.

  • copy the image file to the TFTP server directory.
    cp /src/openwrt/build/r9512/bin/openwrt-wgt634u-2.6-jffs2.bin /var/lib/tftpboot/wgt634u/openwrt-wgt634u-2.6-jffs2-r9512.bin
  • open the WGT634U case by removing 4 screws from the bottom. These are either ordinary phillips (often seen on the refurbs) or T-8 torx screws.
  • connect the serial console to the WGT634U
  • connect a LAN network cable to the WAN port (nearest the USB port)
  • while holding Ctrl-C on the serial console, apply power:
    CFE version 1.0.34 for BCM95365R (32bit,SP,LE)
    Build Date: Tue Feb 24 03:21:41 CST 2004 (root@jackylinux)
    Copyright (C) 2000,2001,2002 Broadcom Corporation.
    
    Add MAC client version(DNI).
    Initializing Arena.
    Initializing Devices.
    et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller
    CPU type 0x29007: 200MHz
    Total memory: 0x2000000 bytes (32MB)
    
    Total memory used by CFE:  0x81BB1280 - 0x82000000 (4517248)
    Initialized Data:          0x81BB1280 - 0x81BB3E90 (11280)
    BSS Area:                  0x81BB3E90 - 0x81BB45D0 (1856)
    Local Heap:                0x81BB45D0 - 0x81FB45D0 (4194304)
    Stack Area:                0x81FB45D0 - 0x81FB65D0 (8192)
    Text (code) segment:       0x81FB65E0 - 0x81FFFFB0 (301520)
    Boot area (physical):      0x01B70000 - 0x01BB0000
    Relocation Factor:         I:E23B65E0 - D:01BB0280
    
    configure vlans
    *****************************************************************
    *********************** VLAN Driver initial  ********************
    *****************************************************************
    Process LAN port(2-5) vlan Architecture...
    SUCCESS: trying to create VLAN 0 for switch
    SUCCESS: trying to add LAN port
    
    Process WAN port(2-5) vlan Architecture...
    SUCCESS: trying to create VLAN 0 for switch
    SUCCESS: trying to add WAN port
    SUCCESS: enable ports  success
    configure vlans...done
    Automatic startup canceled via Ctrl-C
    CFE> ^C
    CFE> 
  • Configure the network. This is easiest if there is a DHCP server on the network:
    CFE> ifconfig eth0 -auto
    Device eth0:  hwaddr 00-0F-B5-97-29-39, ipaddr 192.168.0.145, mask 255.255.255.0
            gateway 192.168.0.1, nameserver 192.168.0.1, domain personaltelco.net
    *** command status = 0
  • Now, flash the image you want to use and reboot:
    CFE> flash -noheader 192.168.0.5:wgt634u/openwrt-wgt634u-2.6-jffs2-r9512.bin flash0.os
    CFE> reboot

Configuration

  • To get a console prompt, wait until the bootup has finished, and press enter to wake up a shell.
  • In order to take advantage of your kamikaze ipkg's, you first need to modify /etc/ipkg.conf. The wget that is installed in the starting image is the busybox version, which currently shoots itself in the head if it finds an AAAA (ipv6) record and there is no ipv6 routing infrastructure available. So get around this by using an ipv4 ipaddr in the URL:
    src snapshots http:///206.163.122.98/~russell/openwrt/r9512
    #src snapshots http://openwrt.org/downloads/snapshots/brcm-2.6/packages
    dest root /
    dest ram /tmp
  • To update your WGT634U using this package archive:
    ipkg update
  • Now, start adding packages:
    ipkg install ip kmod-usb-storage kmod-usb-serial-pl2303 gpsd-beta libstdcpp kismet-server kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-sound-core kmod-usb-audio madplay
  • modify /etc/banner to reflect the svn snapshot.
  • disable a few extraneous things:

mv /etc/init.d/httpd /etc/init.d/httpd_
  • download the "extra" files:

cd /tmp
wget http://206.163.122.98/~russell/r9512-extra-files.tar.gz
cd /
tar xzvf /tmp/r9512-extra-files.tar.gz
  • Among the extra files are:
  • /etc/init.d/setclock
    #
    # /etc/init.d/S95setclock
    # 
    # Find gps device and set clock via gpsd
    #
    # Russell Senior 2006 <russell@personaltelco.net>
    
    PLAY=/usr/bin/play
    SOUNDDIR=/usr/share/sounds
    DEV=/dev/ttyUSB0
    
    # wait for a usb-serial device to appear
    while [ ! -c ${DEV} ]; do
            echo "waiting for usb-serial device"
            ${PLAY} ${SOUNDDIR}/insert-gps.mp3
            sleep 2
    done
    
    if ! pidof gpsd ; then
            gpsd -n ${DEV}
    fi
    
    sleep 5
    
    ${PLAY} ${SOUNDDIR}/fixing.mp3
    
    date -s $(awk -F, -f /usr/lib/setclock.awk ${DEV})
    
    # kill any pre-existing gpsd
    if pidof gpsd ; then  
            echo "killing gpsd"
            PID=$(pidof gpsd)   
            kill ${PID} 
            wait ${PID}         
    fi                          
                                    
    ${PLAY} ${SOUNDDIR}/cleaned-up.mp3
  • /usr/lib/setclock.awk
    $1 ~ /GPRMC/ && $3 ~ /A/ { printf "%s%s%s%s20%s.%s",substr($10,3,2),substr($10,1,2),substr($2,1,2),substr($2,3,2),substr($10,5,2),substr($2,5,2) ; exit }
    $1 ~ /GPRMC/ && $3 !~ /A/ { nofix++ ; if (nofix % 5 == 0) { system("/usr/bin/play /usr/share/sounds/fixing.mp3") } }
  • /etc/init.d/kismet
    if pidof kismet_wrapper ; then
            PID=$(pidof kismet_wrapper)
            kill ${PID}
            wait ${PID}
    fi
    
    /usr/sbin/kismet_wrapper &
  • /usr/bin/play
    /usr/bin/madplay -Q -a -10 --no-tty-control $@
  • /usr/sbin/kismet_wrapper
    # watches for presence of a VENDOR ID on the usb bus to determine
    # whether ${CMD} should run
    
    CMD=kismet_server
    CMDSTR="/usr/bin/kismet_server -f /etc/kismet.conf"
    MNT=/mnt/usbdrive
    DEV=/dev/ttyUSB0
    VENDOR="0a12"
    INTERVAL=5
    
    PLAY=/usr/bin/play
    SOUNDDIR=/usr/share/sounds
    
    while ( true ); do
        echo "starting loop"
        if grep -q "Vendor=${VENDOR}" /proc/bus/usb/devices ; then
            # enable key is inserted
            echo "enable key inserted"
            if ! pidof ${CMD} ; then
                # ${CMD} isn't already running, so execute ${CMDSTR} to start
    
                if pidof gpsd ; then
                    PID=$(pidof gpsd)
                    echo "killing gpsd ${PID}"
                    kill ${PID}
                    wait ${PID}
                    ${PLAY} ${SOUNDDIR}/gpsd-stopped.mp3
                fi
    
                # wait for a usb-serial device to appear
                while [ ! -c ${DEV} ]; do
                    echo "waiting for usb-serial device"
                    ${PLAY} ${SOUNDDIR}/insert-gps.mp3
                    sleep 2
                done
    
                # restarting gpsd in the normal waiting mode
                echo "restarting gpsd"
                gpsd ${DEV} 
    
                ${PLAY} ${SOUNDDIR}/gpsd-started.mp3
    
                while [ ! -b /dev/sda1 ]; do
                    echo "waiting for /dev/sda1"
                    ${PLAY} ${SOUNDDIR}/insert-storage.mp3
                    sleep 2
                done 
    
                while ! grep -q '^/dev/sda1' /proc/mounts ; do
                    echo "mounting storage"
                    ${PLAY} ${SOUNDDIR}/mounting-storage.mp3
                    mount /dev/sda1 ${MNT} 
                    sleep 1
                done
                ${PLAY} ${SOUNDDIR}/storage-mounted.mp3
    
                cd ${MNT}
    
                echo "starting ${CMD}"
                ${PLAY} ${SOUNDDIR}/starting-kismet.mp3
                ${CMDSTR} &
                
                sleep 3
                # check to see if kismet died (like after the 4th restart)
                if ! pidof ${CMD} ; then
                    ${PLAY} ${SOUNDDIR}/kismet-stopped.mp3
                    cd /tmp
                    while grep -q '^/dev/sda1' /proc/mounts ; do
                        ${PLAY} ${SOUNDDIR}/unmounting-storage.mp3
                        umount ${MNT} 
                        sleep 1
                    done
                    ${PLAY} ${SOUNDDIR}/storage-unmounted.mp3
                    ${PLAY} ${SOUNDDIR}/rebooting.mp3
                    reboot
                fi
            else
                # kismet is running, make sure gpsd is also
                if ! pidof gpsd ; then
                    echo WARNING: gpsd is not running!
                    ${PLAY} ${SOUNDDIR}/no-gpsd.mp3
                    if [ -c ${DEV} ]; then
                        echo "restarting gpsd"
                        gpsd ${DEV} 
                        ${PLAY} ${SOUNDDIR}/gpsd-started.mp3
                    fi
                fi
            fi
        else
            # enable key is NOT inserted
            echo "enable key not inserted"
            if pidof ${CMD} ; then
                #  is running, so kill it
    
                echo "stopping ${CMD}"
                ${PLAY} ${SOUNDDIR}/stopping-kismet.mp3
                PID=$(pidof ${CMD})
                kill ${PID}
                wait ${PID}
                echo "finished waiting on ${PID}"
                ${PLAY} ${SOUNDDIR}/kismet-stopped.mp3
    
                cd /tmp
                
                while grep -q '^/dev/sda1' /proc/mounts ; do
                    echo "unmounting storage"
                    ${PLAY} ${SOUNDDIR}/unmounting-storage.mp3
                    umount ${MNT} 
                    sleep 1
                done
                ${PLAY} ${SOUNDDIR}/storage-unmounted.mp3
    
                echo "stopping gpsd"
                ${PLAY} ${SOUNDDIR}/stopping-gpsd.mp3
                PID=$(pidof gpsd)
                kill ${PID}
                wait ${PID}
                echo "finished waiting on ${PID}"
                ${PLAY} ${SOUNDDIR}/gpsd-stopped.mp3
             else
                ${PLAY} ${SOUNDDIR}/waiting.mp3
            fi
        fi
        echo "sleeping ${INTERVAL} seconds"
        sleep ${INTERVAL}
    done            
  • I used a combination of festival and toolame to create mp3's for madplay:
    echo "string" | text2wave - > string.wav
    toolame string.wav string.mp3

WgtStumbler (last edited 2007-11-23 18:02:18 by localhost)