Differences between revisions 11 and 12
Revision 11 as of 2006-10-06 19:30:50
Size: 26604
Comment: reformulated the clock setting script
Revision 12 as of 2006-10-06 19:46:01
Size: 26649
Comment: refined S95setclock
Deletions are marked like this. Additions are marked like this.
Line 603: Line 603:
if $(pidof gpsd); then
        echo "killing gpsd"
        killall gpsd
if $(pidof gpsd); then 
        echo "killing gpsd"
PID=$(pidof gpsd)
        kill ${PID}
        wait ${PID}
Line 631: Line 633:
killall gpsd
rm /tmp/gpsdate
PID=$(pidof gpsd)
kill ${PID}
wait ${PID}

rm -f /tmp/gpsdate

Netgear WGT634U-based Network Stumbler

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. Based on the excellent trailblazing work and example provided by JasonMcArthur.


  • 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 buildroot-ng svn tree. This description is based on the already obsolete r4902.

cd /src/openwrt
svn co https://svn.openwrt.org/openwrt/branches/buildroot-ng 
svn co https://svn.openwrt.org/openwrt/packages 
cd /src/openwrt/buildroot-ng/openwrt/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

# add package infrastructure for an older version of gpsd (v2.9)

mkdir /src/openwrt/buildroot-ng/openwrt/package/gpsd-old
cat > /src/openwrt/buildroot-ng/openwrt/package/gpsd-old <<EOF
include $(TOPDIR)/rules.mk



PKG_BUILDDEP=libpthread uclibcxx

include $(INCLUDE_DIR)/package.mk

define Package/gpsd-old
  DEPENDS:=+libpthread +uclibcxx
  DESCRIPTION:=An interface daemon for GPS receivers

define Build/Configure
        ( cd $(PKG_BUILD_DIR); rm -rf config.cache; \
                $(TARGET_CONFIGURE_OPTS) \
                CFLAGS="$(TARGET_CFLAGS)" \
                CXXFLAGS="$(TARGET_CFLAGS) -fno-builtin -fno-rtti -nostdinc++ -nodefaultlibs"  \
                CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
                LDFLAGS="-nodefaultlibs -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
                LIBS="-luClibc++ -lc -lm -lnotimpl" \
                ./configure \
                        --target=$(GNU_TARGET_NAME) \
                        --host=$(GNU_TARGET_NAME) \
                        --build=$(GNU_HOST_NAME) \
                        --program-prefix="" \
                        --program-suffix="" \
                        --prefix=/usr \
                        --exec-prefix=/usr \
                        --bindir=/usr/bin \
                        --datadir=/usr/share \
                        --includedir=/usr/include \
                        --infodir=/usr/share/info \
                        --libdir=/usr/lib \
                        --libexecdir=/usr/lib \
                        --localstatedir=/var \
                        --mandir=/usr/share/man \
                        --sbindir=/usr/sbin \
                        --sysconfdir=/etc \
                        $(DISABLE_LARGEFILE) \
                        $(DISABLE_NLS) \
                        --enable-shared \
                        --enable-static \
                        --with-gnu-ld \
                        --without-x \

define Build/Compile
        cp $(PKG_BUILD_DIR)/libtool $(PKG_BUILD_DIR)/libtool.orig
        sed 's/-lstdc++ //' < $(PKG_BUILD_DIR)/libtool.orig > $(PKG_BUILD_DIR)/libtool
        $(MAKE) -C $(PKG_BUILD_DIR) \

define Package/gpsd-old/install
        install -d -m0755 $(1)/usr/lib
        install -m0755 $(PKG_BUILD_DIR)/.libs/libgps.so* $(1)/usr/lib/
        install -d -m0755 $(1)/usr/sbin/
        install -m0755 $(PKG_BUILD_DIR)/.libs/gpsd $(1)/usr/sbin/

define Build/InstallDev
        mkdir -p $(STAGING_DIR)/usr/include
        $(CP) $(PKG_BUILD_DIR)/gps{,d}.h $(STAGING_DIR)/usr/include/
        mkdir -p $(STAGING_DIR)/usr/lib
        $(CP) $(PKG_BUILD_DIR)/.libs/libgps.{a,so*} $(STAGING_DIR)/usr/lib/

define Build/UninstallDev
        rm -rf $(STAGING_DIR)/usr/include/gps{,d}.h \

$(eval $(call BuildPackage,gpsd-old))

cd /src/openwrt/buildroot-ng/openwrt
make menuconfig

In the menuconfig, I set the Target System to (Broadcom BCM47xx/53xx [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 r4902 can be found [http://www.personaltelco.net/~russell/buildroot-ng/config-r4902 here].

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

  • /src/openwrt/buildroot-ng/openwrt/bin contains the flashable images

  • /src/openwrt/buildroot-ng/openwrt/bin/packages contains the .ipk files

Additionally, as of my recent attempts, the Packages file that is needed for the ipkg utility to function properly later on is apparently not constructed (maybe I missed it), but I developed a script that does it for me:



rm -f ${PKGSFIL}

for i in $(find ${CTRLDIR} -name 'control' | grep CONTROL) ; 
  do echo $i ; 
  PACKAGE=$(grep ^Package: $i | cut -d' ' -f2) ; 
  VERSION=$(grep ^Version: $i | cut -d' ' -f2) ; 
  ARCH=$(grep ^Architecture: $i | cut -d' ' -f2) ; 
  if [ -f ${IPKG} ] ; then
      SIZE=$(wc -c ${IPKG} | cut -d' ' -f1) ; 
      MD5=$(md5sum ${IPKG} | cut -d' ' -f1) ; 
      cat $i >> ${PKGSFIL} ; 
      echo "Filename: ${FILENAME}" >> ${PKGSFIL} ; 
      echo "Size: ${SIZE}" >> ${PKGSFIL} ; 
      echo "MD5Sum: ${MD5}" >> ${PKGSFIL} ; 
      echo "" >> ${PKGSFIL} ; 
      echo "${FILENAME} NOT FOUND!"

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

rsync -v -a -H /src/openwrt/buildroot-ng/openwrt/bin/packages/ donk.personaltelco.net:public_html/buildroot-ng/r4902/

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/buildroot-ng/openwrt/bin/openwrt-wgt634u-2.6-jffs2.bin /var/lib/tftpboot/wgt634u/openwrt-wgt634u-2.6-jffs2-r4902.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
  • 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, mask
            gateway, nameserver, domain personaltelco.net
    *** command status = 0
  • You can blank out the flash using specially prepared wipe images. Note that the file size that you can TFTP is limited so this must be done in two steps. This might in fact be unnecessary, but it works for me:
    CFE> flash -noheader flash0.os
    CFE> flash -noheader -offset=3932160 flash0.os
  • Now, flash the image you want to use and reboot:
    CFE> flash -noheader flash0.os
    CFE> reboot


  • To get a console prompt, wait until the bootup has finished, and press enter to wake up a shell.
  • You can configure your ethernet network as follows (assuming you have a DHCP server available):
    udhcpc -i eth0
  • In order to take advantage of your buildroot-ng ipkg's, you first need to modify /etc/ipkg.conf:
    src snapshots http://www.personaltelco.net/~russell/buildroot-ng/r4902
    #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 kmod-usb2
    ipkg install kmod-usb-storage
    ipkg install kmod-usb-serial-pl2303
    ipkg install gpsd-old
    ipkg install kmod-fs-vfat
    ipkg install kmod-nls-cp437
    ipkg install kmod-nls-iso8859-1
  • 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:

    cd /tmp
    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
    # Name of server (Purely for organiational purposes)
    # User to setid to (should be your normal user)
    # 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.
    # source=wrt54g,eth1,wireless
    # For v1 hardware uncomment this:
    # source=wrt54g,eth2,wireless
    # 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?
    # How many channels per second do we hop?  (1-10)
    # 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.
    # 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)
    # 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
    # 802.11g uses the same channels as 802.11b...
    # 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 
    # 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.
    # 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
    # People allowed to connect, comma seperated IP addresses or network/mask
    # blocks.  Netmasks can be expressed as dotted quad (/ or as
    # numbers (/24)
    # Maximum number of concurrent GUI's
    # Do we have a GPS?
    # Host:port that GPSD is running on.  This can be localhost OR remote!
    # 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
    # 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.
    # 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.
    # How often (in seconds) do we write all our data files (0 to disable)
    # Where do we get our manufacturer fingerprints from?  Assumed to be in the
    # default config directory if an absolute path is not given.
    # Use metric measurements in the output?
    # Do we write waypoints for gpsdrive to load?  Note:  This is NOT related to
    # recent versions of GPSDrive's native support of Kismet.
    # GPSMap waypoint file.  This WILL be truncated.
    # 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.
    # 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
    # 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.
    # 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.
    # 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.
    # Do we log beacon packets or do we filter them out of the dumpfile
    # Do we log PHY layer packets or do we filter them out of the dumpfile
    # Do we mangle packets if we can decrypt them or if they're fuzzy-detected
    # 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'
    # What type of dump do we generate? 
    # valid option: "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.
    # Do we write data packets to a FIFO for an external data-IDS (such as Snort)?
    # See the docs before enabling this.
    # Default log title
    # 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.
    # Where do we store the pid file of the server?
    # Where state info, etc, is stored.  You shouldnt ever need to change this.
    # This is a directory.
    # cloaked SSID file.  You shouldn't ever need to change this.
    # Group map file.  You shouldn't ever need to change this.
    # IP range map file.  You shouldn't ever need to change this.
  • Add various scripts:
    • /etc/init.d/S95setclock
      cat > /etc/init.d/95setclock <<EOF
      # /etc/init.d/S95setclock
      # Find gps device and set clock via gpsd
      # Russell Senior 2006 <russell@personaltelco.net>
      # wait for a usb-serial device to appear
      while [ ! -c /dev/usb/tts/0 ]; do
              echo "waiting for usb-serial device"
              sleep 2
      # kill any pre-existing gpsd
      if $(pidof gpsd); then 
              echo "killing gpsd"
              PID=$(pidof gpsd)
              kill ${PID}
              wait ${PID}
      # restart gpsd in no-wait mode
      echo "restarting gpsd"
      gpsd -n -p /dev/usb/tts/0
      # looking for gps fix
      while [ $(echo "s" | nc 2947 | sed 's/^GPSD,S=//') -le "0" ] ; do 
              echo "waiting for a fix"
              sleep 1
      # looking for a gps date/time
      while true ; do
              echo "d" | nc 2947 | sed 's/^GPSD,D=//' | tr 'ZT:-' '    ' > /tmp/gpsdate
              if [ $(cut -d' ' -f1 /tmp/gpsdate) -ge 2006 ]; then
                      echo "got a date"
                      date -s $(awk '{ printf("%s%s%s%s%s.%d",$2,$3,$4,$5,$1,int($6+0.5)) }' /tmp/gpsdate)
              echo "waiting for a date"
              sleep 1
      echo "cleaning up"
      PID=$(pidof gpsd)
      kill ${PID}
      wait ${PID}
      rm -f /tmp/gpsdate
      chmod 755 /etc/init.d/S95setclock

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
  • Copy some sound files (compatible with madplay) to /usr/share/kismet/wav. I used audacity to encode the kismet .wav files as .mp3's.
  • 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
    /usr/bin/madplay -Q -a -10 --no-tty-control $@
    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.
    # Path to sound player                                                        
    # Optional parameters to pass to the player                                   
    # soundopts=                                                                  
    # soundopts=--volume=.3                                                       
    # New network found                                                           
    # Wepped new network                                                          
    # sound_new_wep=${prefix}/com/kismet/wav/new_wep_network.wav                  
    # Network traffic sound                                                       
    # Network junk traffic found                                                  
    # 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                                                                   

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