Thursday, November 19, 2009

Kismet init

Here's a script to add to /etc/init.d that will start kismet_drone on router startup. Put this code in a file called "kismet_drone" (or whatever you want to call it):

#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org

START=65
PROG=/usr/bin/kismet_drone
start() {
        $PROG
}

stop() {
        killall kismet_drone
}

 Once this is done do the following:

cd /etc/rc.d
ln -s ../init.d/kismet_drone S65kismet_drone

Now kismet_drone will start whenever the router is restarted. The "stop" command doesn't work very well, I'm still working on fixing that issue.

Monday, November 16, 2009

Flashing the Flashed

If your router is already flashed with DD-WRT, the easiest way to get the drone working is to use SCP and MTD. Here's the quick 'n' dirty:

#SCP .trx file to router
scp filename.trx root@routerip:/tmp/

#SSH into router
ssh -lroot routerip

#Start the flash
cd /tmp
mtd -r write filename.trx linux

At this point the router will begin the flash process. Be patient, don't jump the gun and pull the plug on the router (potential brickage might follow). This usually takes 3-5 minutes, just wait for the router to reboot, then you will have to telnet back in and do the configure thing all over again.

Thursday, November 12, 2009

OpenWRT Kismet Files - Part Deux

So, here are a couple of things to do after flashing your router.

After flash:

Edit /usr/local/etc/kismet.conf on server to add in drone source.

ncsource=drone:host=x.x.x.x,port=2501,name=drone1

(if you have more drones, add them here as well:
ncsource=drone:host=x.x.x.x,port=2501,name=drone2
ncsource=drone:host=x.x.x.x,port=2501,name=drone3
)

Edit /etc/kismet/kismet_drone.conf on drone to add source.

ncsource=wlan0

You can also set allowedhosts in the kismet.conf/kismet_drone.conf files if you want only specific hosts to talk to the drones.

Drone setting:
droneallowedhosts=x.x.x.0/24,x.x.x.x

Server setting:
listen=tcp://hostip:2501

Set your timezone on the drone:
echo timezone > /etc/TZ

Example: echo EST+5 > /etc/TZ

date mmddhhmmccyy

Example: date 111212002009

Wednesday, October 28, 2009

Kismet + SMS + Ruby

I'm working on a script that connects to my Kismet server, pulls the client MAC addresses, and then queries a Microsoft SMS server to pull back usernames. Eventually the script will send an email once it finds a user that has an established wireless connection. This is a little easier for me because any wireless is bad wireless in my environment. Not sure if anyone else would be interested, but leave a comment and I can post the script when it's done.

Thursday, October 22, 2009

OpenWRT Kismet Files

***Files have been updated with an NTP client added***
Here they are, let me know if there are any issues with the links...

TRX File
BIN File

Friday, August 14, 2009

Kismet-Newcore OpenWRT Cross-Compile

So, after much headbanging, I believe I have been able to cross-compile Kismet-newcore (just Kismet now) for the WRT54GL on OpenWRT Kamikaze trunk.

This guide will hopefully help people build Kismet for use on OpenWRT flashed devices. I can't say that it is 100% perfect, or complete, but I can say that with some tweaking, Kismet will build and will at least install on a WRT54GL. Since the Broadcom drives do not allow monitor mode, there is limited use for Kismet, but hopefully this will work on other devices. I just tried this and it seems to work in monitor mode (WooHoo!). I'd love to try it out, but I only own the WRT54GL, so that is all I can comment on. If anyone can try it out on other devices, please let me know how/if it works. Also, if there are any errors in the guide, please feel free to point them out and I will correct as necessary.

(Thx DJ Flux for the make/Makefile-fu)

#Download OpenWRT SVN trunk
svn checkout svn://svn.openwrt.org/openwrt/trunk/ ~/trunk/

#Download Kismet SVN trunk
svn co https://www.kismetwireless.net/code/svn/trunk ~/kismet-devel

#Change to trunk directory
cd ~/trunk/

#Update packages
./scripts/feeds update

#Install necessary packages for Kismet
./scripts/feeds install -d m uclibcxx
./scripts/feeds install -d m libpcre


-You should see output similar to this:
mike@openwrt:~/openwrt/trunk$ ./scripts/feeds install -d m uclibcxx
++ mkdir -p /home/mike/openwrt/trunk/staging_dir/toolchain-mipsel_gcc-3.4.6_uClibc-0.9.30.1
++ cd /home/mike/openwrt/trunk/staging_dir/toolchain-mipsel_gcc-3.4.6_uClibc-0.9.30.1
++ mkdir -p stamp lib usr/include usr/lib
Installing package 'uclibc++'

mike@openwrt:~/openwrt/trunk$ ./scripts/feeds install -d m libpcre
++ mkdir -p /home/mike/openwrt/trunk/staging_dir/toolchain-mipsel_gcc-3.4.6_uClibc-0.9.30.1
++ cd /home/mike/openwrt/trunk/staging_dir/toolchain-mipsel_gcc-3.4.6_uClibc-0.9.30.1
++ mkdir -p stamp lib usr/include usr/lib
Installing package 'pcre'


#Create Kismet package directory

cd package
mkdir kismet-newcore
mkdir kismet-newcore/files
mkdir kismet-newcore/patches


#Create kismet-devel tarball

cd ~/
tar czvf kismet-devel.tar.gz kismet-devel/


#Now copy or move the kismet-devel.tar.gz to a webserver
-I ended up creating a code directory in /var/www/ (/var/www/code) and placed the file there

#Create or copy Kismet package Makefile
kismet-newcore files
***UPDATE(The included Makefile points to 127.0.0.1/code)***

#Copy kismet_drone.conf to kismet-newcore/files directory
**This file is included in the above tarball**
-This is just the default file with gps server turned off (I don't have GPS available)

#Configure the image environment
make menuconfig

#Choose your Target System/Subtarget/Target Profile and select packages/features
-There are two ways to add the extra items:
-Add as a built-in package (creates larger images, but less hassle with installing packages)
-Only use if you have enough RAM for the larger images
-Add as a package (smaller images, but requires package be copied to device and installed manually)

-select libraries-> libncurses, libnl, libpcre, libpcap

#Build images
make world
-This step can be done before or after kismet is selected. If it's done before, you won't get the errors, and it will at least build clean the first time through. After kismet is added to the packages and selected, there will be errors that need to be resolved before the make will finish.
-This could take some time, so be patient. Also, note any errors.

-Example output:

mike@openwrt:~/openwrt/trunk$ make world
make[1] world
make[2] tools/install
make[3] -C tools/m4 compile
make[3] -C tools/m4 install
make[3] -C tools/autoconf compile
make[3] -C tools/autoconf install
make[3] -C tools/automake compile
make[3] -C tools/automake install
make[3] -C tools/bison compile
make[3] -C tools/bison install
make[3] -C tools/sed compile
make[3] -C tools/sed install
make[3] -C tools/pkg-config compile
make[3] -C tools/pkg-config install
make[3] -C tools/mklibs compile
make[3] -C tools/mklibs install
make[3] -C tools/sstrip compile
make[3] -C tools/sstrip install
make[3] -C tools/ipkg-utils compile
make[3] -C tools/ipkg-utils install
make[3] -C tools/genext2fs compile
make[3] -C tools/genext2fs install
make[3] -C tools/lzma-old compile
make[3] -C tools/lzma-old install
make[3] -C tools/squashfs compile
make[3] -C tools/squashfs install
make[3] -C tools/lzma compile
make[3] -C tools/lzma install
make[3] -C tools/squashfs4 compile
make[3] -C tools/squashfs4 install
make[3] -C tools/mtd-utils compile
make[3] -C tools/mtd-utils install
make[3] -C tools/mkimage compile
make[3] -C tools/mkimage install
make[3] -C tools/firmware-utils compile
make[3] -C tools/firmware-utils install
make[3] -C tools/patch-cmdline compile
make[3] -C tools/patch-cmdline install
make[3] -C tools/quilt compile
make[3] -C tools/quilt install
make[3] -C tools/yaffs2 compile
make[3] -C tools/yaffs2 install
make[2] toolchain/install
make[3] -C toolchain/binutils prepare
make[3] -C toolchain/binutils compile
make[3] -C toolchain/binutils install
make[3] -C toolchain/gcc prepare
make[3] -C toolchain/kernel-headers prepare
make[3] -C toolchain/kernel-headers compile
make[3] -C toolchain/kernel-headers install
make[3] -C toolchain/uClibc prepare
make[3] -C toolchain/gcc compile
make[3] -C toolchain/uClibc compile
make[3] -C toolchain/gcc install
make[3] -C toolchain/uClibc install
make[2] target/compile
make[3] -C target/linux compile
make[2] package/cleanup
make[2] package/compile
make[3] -C package/base-files compile
make[3] -C package/broadcom-diag compile
make[3] -C package/wireless-tools compile
make[3] -C package/broadcom-wl compile
make[3] -C package/busybox compile
make[3] -C package/dnsmasq compile
make[3] -C package/dropbear compile
make[3] -C feeds/packages/libs/pcre compile
make[3] -C feeds/packages/libs/uclibc++ compile
make[3] -C package/libtool host-compile
make[3] -C package/libtool compile
make[3] -C package/iptables compile
make[3] -C package/firewall compile
make[3] -C package/kernel compile
make[3] -C package/libnl compile
make[3] -C package/libpcap compile
make[3] -C package/lua compile
make[3] -C package/mtd compile
make[3] -C package/ncurses compile
make[3] -C package/nvram compile
make[3] -C package/opkg compile
make[3] -C package/linux-atm compile
make[3] -C package/ppp compile
make[3] -C package/switch compile
make[3] -C package/uci compile
make[2] package/install
make[3] -C package/base-files install
make[3] -C package/broadcom-diag install
make[3] -C package/broadcom-wl install
make[3] -C package/busybox install
make[3] -C package/dnsmasq install
make[3] -C package/dropbear install
make[3] -C package/firewall install
make[3] -C package/iptables install
make[3] -C package/kernel install
make[3] -C package/libnl install
make[3] -C package/lua install
make[3] -C package/mtd install
make[3] -C package/ncurses install
make[3] -C package/nvram install
make[3] -C package/opkg install
make[3] -C package/ppp install
make[3] -C package/switch install
make[3] -C package/uci install
make[3] -C package/wireless-tools install
make[2] package/rootfs-prepare
make[3] package/preconfig
make[2] target/install
make[3] -C target/linux install
make[6] -C target/linux/brcm-2.4/image/lzma-loader clean install
make[2] package/index


#After initial build
make menuconfig

#Select Network->Wireless->kismet-drone

#Build image again
make
-This will error out because the Kismet Makefile needs to be tweaked
Kismet Makefile Example

**See updated post**
#Edit Kismet Makefile

cd ~/trunk/build_dir/target-mipsel_uClibc-0.9.30.1/kismet-2009-06-R1
vi Makefile



-Change the following flags:

CFLAGS = -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/target-mipsel_uClibc-0.9.30.1/usr/include/uClibc++ -I/include -I/usr/include/ncurses

CXXFLAGS = -Wall -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/target-mipsel_uClibc-0.9.30.1/usr/include/uClibc++ -fno-builtin -fno-rtti -nostdinc++

CPPFLAGS = -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/target-mipsel_uClibc-0.9.30.1/usr/include/uClibc++ -I/include -I/usr/include/ncurses



-To: (You are adding the "+" before the "=")

CFLAGS += -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/target-mipsel_uClibc-0.9.30.1/usr/include/uClibc++ -I/include -I/usr/include/ncurses

CXXFLAGS += -Wall -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/target-mipsel_uClibc-0.9.30.1/usr/include/uClibc++ -fno-builtin -fno-rtti -nostdinc++

CPPFLAGS += -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/target-mipsel_uClibc-0.9.30.1/usr/include/uClibc++ -I/include -I/usr/include/ncurses



-Change the following line:
all: Makefile $(DEPEND) $(PS) $(CS) $(DRONE) $(NC)

-To:
all: Makefile $(DEPEND) $(PS) $(CS) $(DRONE)


#New make command line:
-This is all one line, remove the "\"

CCFLAGS="$CCFLAGS -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include/uClibc++" \ CXXFLAGS="$CXXFLAGS -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include/uClibc++" \ CPPFLAGS="$CPPFLAGS -I/home/mike/openwrt/trunk/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include/uClibc++" make V=99


-There may be some errors at this point, or at least warnings.

#Once the make completes successfully, you can flash your router with whatever method you choose.
#I won't go into the flashing details in this tutorial.

#Once the router is flashed, you will need to copy over packages if you created them as modules, and not built-in

-Packages to copy to wrt54gl:
kismet-drone_2009-06-R1-1_mipsel.ipk
libpcap_1.0.0-1_mipsel.ipk
libpcre_7.9-1_mipsel.ipk
uclibcxx_0.2.2-2_mipsel.ipk

-The easiest way is to SCP them over to the /tmp directory on the router.

#SSH into router and install the packages

ssh 192.168.1.1
cd /tmp
opkg install uclibcxx_0.2.2-2_mipsel.ipk
opkg install libpcre_7.9-1_mipsel.ipk
opkg install libpcap_1.0.0-1_mipsel.ipk
opkg install kismet-drone_2009-06-R1-1_mipsel.ipk