Raspberry pi wardrivers?

The gear needed for wardriving

30 posts • Page 1 of 2

Postby Antimon » Tue May 05, 2015 10:22 am

Hey, i am in the works on my wardriving Raspberry Pi rig.

I am reading a book called Kismet Hacking by Brad Haines and Frank Thornton, and from it i have learned a lot, but i wanted to come in contact with other RPi wardrivers that may have some additional pointers for me on how to get up running with the Raspberry Pi.

Have a great day guys. :)

Postby mdkFree » Wed May 06, 2015 7:50 am

I use a raspberry pi, there is nothing different between a raspberry pi and a full linux pc/laptop, regarding the setup.

Postby Antimon » Sat May 09, 2015 5:24 am

Thanks for your reply. :)

I saw this video on youtube, and i thought that it would be cool to do a little bit of reverse engineering on it. I would like to have one of my own.

https://www.youtube.com/watch?v=-yJvloXv0dc

Any ideas?

Postby clickwir » Mon Jul 13, 2015 5:09 pm

I'm currently in the middle of getting one setup as well. I had a space Pi B Rev 1 laying around and decided to put it to use... or at least try to without having to buy a new Pi.

I got one of these to help auto shutdown the Pi when the car powers off. https://mausberry-circuits.myshopify.co ... ply-switch

Haven't installed it in the car yet, but tested it with a 12V power supply and it seems to work exactly like I want. I want it to power the Pi on when the car starts and gracefully shutdown the Pi when the car powers off.

Also, without using a screen or LCD of some sort, I wanted a way to get some feedback of how my Pi is currently doing while driving. This board: https://www.modmypi.com/raspberry-pi/br ... rry%20clip and this script: https://github.com/Wardriving-for-Raspb ... iwardrive/ look like they should be able to give some good info about how my GPS and Kismet are doing.

I think I have the main control script sorted out how I want it. It basically tries to make sure no other networking stuff is running to interfere, manually restarts GPSd and then starts kismet. Once I close kismet, it compresses the output files to be ready for uploading. It's not very smart, just sequentially runs each command without checking conditions first. I'm not good at getting fancy with scripts, though I would like to. Here it is just in case anyone wants to build upon it.

Code: Select all

#!/bin/bash NOW=$(date +"%F-%H-%M") CURRENT_RUN=/home/pi/kismet/current_run ARCHIVE=/home/pi/kismet/Archive echo "::: Killing dhclient and networking" sudo killall dhclient sudo service network-manager stop echo "::: Done killing. For now..." echo "::: Sorting out GPS bits..." sudo service gpsd stop sudo gpsd -n /dev/ttyUSB0 echo "::: GPS should be sorted now." echo "::: Starting Kismet" #kismet_server --daemonize & #sleep 2 kismet sleep 1 echo "::: Telling server to shutdown" echo -e '\n!0 shutdown' | nc localhost 2501 cd $CURRENT_RUN echo "::: Compressing..." tar -cvzf $ARCHIVE/kismet-$NOW.tar.gz $CURRENT_RUN/Kis* #sleep 2 echo "::: Cleaning up..." rm -v $CURRENT_RUN/Kis* #sleep 2 echo "::: Here's $CURRENT_RUN" ls -lah $CURRENT_RUN echo "::: Here's $ARCHIVE" ls -lah $ARCHIVE
This doesn't do any auto uploading or anything like that. I'll still have to take my SD card out manually and upload it. But if I do that once a week, that's fine with me.

Postby clickwir » Tue Jul 14, 2015 4:30 pm

So I went and improved my script a bit. I made this in /home/pi/kismet and named it run_kismet.

Code: Select all

#!/bin/bash #KroniK's Bash Template #Version 1.0.3 #https://github.com/KroniK907/KroniKsBashTemplate #Copyright (c) 2014 Daniel Kranich #Licenced under MIT #======================================================================# #======================== Notes ========================# #======================================================================# #======================================================================# #======================== Default Functions ========================# #======================================================================# # ---------------------------------------------------------------- # Set Inital Variables # ---------------------------------------------------------------- NOW=$(date +"%F-%H-%M") WORKING_DIR=/home/pi/kismet CURRENT_RUN=/home/pi/kismet/current_run ARCHIVE=/home/pi/kismet/Archive LOG="$WORKING_DIR/log/log.log" ERRLOG="$WORKING_DIR/log/err.log" #Dont touch these VBSE=false # ---------------------------------------------------------------- # Function to display a verbose output when the -v option is set # # This function is basically pushed to echo, so all rules of echo # apply. # # This function accepts 2 arguments: # 1) This is what you want to log/display to console. Make sure it # is in quotes. # 2) This is an alternate log location if you wish to push the # above argument to a second log. # # Example: # log "ls -la /home/" "/var/log/otherlog.log" # ---------------------------------------------------------------- log() { Date=$(date "+%F %T") Text="$1" Log2="$2" if [[ ! -n "$D" ]] then echo "$Date: $Text" >> "$LOG" else echo "$Date: $Text" >> "$LOG" echo "$Date: $Text" >> "$Log2" fi [ "$VBSE" == true ] && echo "$Text" } # ---------------------------------------------------------------- # Function to log any errors and exit if fatal error # # This function should only be called by the error_check function # found below. # # Accepts 2 arguments: # 1) string containing descriptive error message # 2) if second argument exists, then the error is fatal and the # script will exit. # ---------------------------------------------------------------- error_log() { Date=$(date "+%F %T") #Name of last program run Progname=${0##*/} Fatal="$2" echo "$Date ${PROGNAME}: ${1:-"Unknown Error"}" 1>&2 echo "$Date ${PROGNAME}: ${1:-"Unknown Error"}" >> $ERRLOG if [[ -z "$Fatal" ]] then exit 1 fi } # ---------------------------------------------------------------- # Function to check if the previous comand was completed # succesfully # # This function can be followed by 2 arguments: # 1) A discription of the error. If none exists it will list as an # "Unknown Error" # 2) If a second argument is given, then the script will exit upon # loging the error. This argument can be literally any string # you wish (it only matters if a string exists) however for # clarity I usually use "FATAL" # # Example: # error_check "The previous command failed" "FATAL" # ---------------------------------------------------------------- error_check() { if [[ "$?" != "0" ]] then error_log "$1" "$2" fi } # ---------------------------------------------------------------- # Function to print the help display # # This is called by the -h flag in getopts below # ---------------------------------------------------------------- help_text() { echo "-v toggles verbose output" echo "-h shows the user how to use this script" echo "-x toggles bash -x output for debugging" exit 1 } # ---------------------------------------------------------------- # Function to wait for GPS Fix # # Calling this will make things pause until gpsd reports # that "mode:3" has been achieved. # mode:3 indicates at least 4 reliable satellites have # been locked onto, giving a 3D location. # ---------------------------------------------------------------- gpswait() { gpspipe -w | tr -d '"' | grep --line-buffered -m 1 "mode:3" } # ---------------------------------------------------------------- # Function to print SUCCESS in color # ---------------------------------------------------------------- success() { printf "[\033[32mSUCCESS\033[0m]\n" } # ---------------------------------------------------------------- # Function to print FAILURE in color # ---------------------------------------------------------------- failure() { printf "[\033[31mFAILURE\033[0m]\n" } # ---------------------------------------------------------------- # Function to give colorful feedback # # Simply calls functions success or failure based on # if the command completed successfully or not. # # Use: try command # ---------------------------------------------------------------- try() { result=$($* 2>&1) if [ $? -ne 0 ]; then failure echo $result # exit 1 fi success } # ---------------------------------------------------------------- # Function to give colorful feedback # # Same as the try function, but will exit the script # if the command fails. # # Useful for commands that need success for the # script to continue. # # Use: try_fail command # ---------------------------------------------------------------- try_fail() { result=$($* 2>&1) if [ $? -ne 0 ]; then failure echo $result exit 1 fi success } # ---------------------------------------------------------------- # Get any flags from the user # # Accepts 3 arguments: # -v toggles verbose output # -h shows the user how to use this script # -x toggles bash -x output for debugging # # check man getopts for info on how to add more options/arguments. # There is also a good getopts guide here: # http://rsalveti.wordpress.com/2007/04/03/bash-parsing-arguments-with-getopts/ # ---------------------------------------------------------------- while getopts :vhx opt do case $opt in v) VBSE=true;; h) help_text;; x) set -x;; :) echo "Missing Option Argument for -$OPTARG" >&2; exit 1;; *) echo "Unknown Option: -$OPTARG" >&2; exit 1;; esac done error_check "getopts-failed" "FATAL" #======================================================================# #======================== Script ========================# #======================================================================# main() { sleep 10 echo -e "\e[36m:::\e[0m \e[1m Stopping gpsd service\e[0m" try sudo service gpsd stop echo -e "\e[36m:::\e[0m \e[1m Killing any remaining gpsd instances\e[0m" try sudo killall gpsd echo -e "\e[36m:::\e[0m \e[1m Starting gpsd\e[0m" try sudo gpsd -n /dev/ttyUSB0 sleep 2 echo -e "\e[36m:::\e[0m \e[1m Restarting NTP to set time from GPS\e[0m" try sudo service ntp restart echo -e "\e[36m:::\e[0m \e[1m Waiting for GPS 3D fix\e[0m" #echo "First" #gpspipe -w | grep -m 1 '"mode":3' #echo "Second" try gpswait echo -e "\e[36m:::\e[0m \e[1m GPS should be sorted now.\e[0m" echo -e "\e[36m:::\e[0m \e[1m Stopping dhclient\e[0m" try sudo killall dhclient echo -e "\e[36m:::\e[0m \e[1m Stopping network-manager\e[0m" try sudo service network-manager stop #echo -e "\e[36m:::\e[0m \e[1m Done killing. For now..." echo -e "\e[36m:::\e[0m \e[1m Starting Kismet\e[0m" kismet_server #sleep 2 #kismet sleep 1 echo -e "\e[36m:::\e[0m \e[1m Sending extra shutdown command to Kismet to be sure\e[0m" echo -e '\n!0 shutdown' | nc localhost 2501 sleep 2 cd $CURRENT_RUN echo -e "\e[36m:::\e[0m \e[1m Compressing...\e[0m" try tar -cvzf $ARCHIVE/kismet-$NOW.tar.gz Kis* #sleep 2 echo -e "\e[36m:::\e[0m \e[1m Cleaning up...\e[0m" try rm -v $CURRENT_RUN/Kis* #sleep 2 #echo -e "\e[36m:::\e[0m \e[1m Here is $CURRENT_RUN" #ls -lah $CURRENT_RUN echo -e "\e[36m:::\e[0m \e[1m Here is $ARCHIVE\e[0m" ls -lah $ARCHIVE #sleep 1 #echo -e "\e[36m:::\e[0m \e[1m Restarting normal WiFi networking." #sudo service network-manager start #echo -e "\e[36m:::\e[0m \e[1m wlan0 down/up" #sudo ifconfig wlan0mon down && sudo ifconfig wlan0 up #echo -e "\e[36m:::\e[0m \e[1m dhclient wlan0" #sudo dhclient wlan0 & #echo -e "\e[36m:::\e[0m \e[1m Done. Normal wifi should be restored." } main "$@" exit
Next I add "@reboot /home/pi/kismet/run_kismet" to crontab -e.

Currently the script does not check for existing directories, so you'll have to make them first and configure your own /etc/kismet/kismet.conf. Also I've not tested it beyond my workbench here. It does have a USB GPS and USB WiFi units attached and appears to be working properly, but please look through the script and be cautious, yadda yadda yadda.

I know when I was looking at taking on this fun project, having a script to start and stop things properly was one of the things I wanted to make sure works properly. Coupled with the shutdown circuit, it appears to work right and I hope it helps someone else too.

Here's the shutdown circuit I got: https://mausberry-circuits.myshopify.co ... ply-switch
I added the call to shutdown kismet (echo -e '\n!0 shutdown' | nc localhost 2501) to the circuits script, along with a 'sleep 10' to give it time to shutdown and compress the files.

Postby WiFi-Freak » Wed Aug 19, 2015 10:32 pm

@clickwir

What distro do you use on the Pi?

Which kismet version do you use?

Thx!
Regards, WiFi-Freak
Image

Postby clickwir » Thu Aug 20, 2015 2:54 pm

I'm using Raspbian. Raspbian is Debian Weezy based, I found that it had an older version of Kismet. So I upgraded to the Raspbian version of Debian Jessie. I think all I really did was change "weezy" to "jessie" in my /etc/apt/sources.list file and run an upgrade.

Postby WiFi-Freak » Mon Aug 24, 2015 9:42 pm

Thanks for sharing clickwir !

I have installed Arch Linux as I was told that this distro is the fastest for the Pi.

I like the idea of Kai Kretzberg's ScanBox:
http://kaikretzberg.de/?p=1636


I realy like to know how he did the upload thing:
All files will be transmitted automatically to attached USB devices. It also synchronizes all files which were created before. If you don‘t plug in any USB device, the ScanBox will store files in a local folder. After booting the Box with a pen drive plugged in, it will start synchonizing your database.

The interval between saving is 300 seconds by default.
I tried to contact the author of the ScanBox with serval mails but did get no respond.
If someone can help me with this file upload thing please let me now.
Regards, WiFi-Freak
Image

Postby mahalinga » Fri Aug 28, 2015 5:25 pm

Hey guys,

I'm currently planning a permanent "WiPi" installation. I want to mount a Raspberry Pi Model B, Alfa USB WiFi adapter, and a USB GPS in the trunk of my car and basically leave them there full time. I want the Pi to boot up and launch Kismet whenever the car starts, and then gracefully shut down then the car is shut off. In addition, if the car is parked in my garage, I want it to automatically connect to my WiFi AP and upload all new Kismet files captured since the last upload.

I'm thinking of using a PicoPS DC-DC ATX power supply from Mini-Box - overkill, I know, but I happen to have one lying around that I'm not using. The GPS antenna is magnetic mount and waterproof, but I'm looking for a solution for the WiFi antenna. Ideally I could find a no-holes-drilled trunk lip mounted WiFi antenna that's omnidirectional, has reasonable gain, and a RP-SMA connector to plug into the Alfa. Any suggestions?

Postby WiFi-Freak » Wed Sep 02, 2015 6:18 pm

Hey guys,

I'm currently planning a permanent "WiPi" installation. I want to mount a Raspberry Pi Model B, Alfa USB WiFi adapter, and a USB GPS in the trunk of my car and basically leave them there full time. I want the Pi to boot up and launch Kismet whenever the car starts, and then gracefully shut down then the car is shut off. In addition, if the car is parked in my garage, I want it to automatically connect to my WiFi AP and upload all new Kismet files captured since the last upload.

I'm thinking of using a PicoPS DC-DC ATX power supply from Mini-Box - overkill, I know, but I happen to have one lying around that I'm not using. The GPS antenna is magnetic mount and waterproof, but I'm looking for a solution for the WiFi antenna. Ideally I could find a no-holes-drilled trunk lip mounted WiFi antenna that's omnidirectional, has reasonable gain, and a RP-SMA connector to plug into the Alfa. Any suggestions?
https://mausberry-circuits.myshopify.co ... 1327900328
Regards, WiFi-Freak
Image

Postby mahalinga » Tue Sep 08, 2015 3:55 am

Thanks for that link - I'd never seen that one before. It's a lot cheaper than the M3-ATX, too. :mrgreen:

Postby strasharo » Mon Nov 16, 2015 1:47 pm

Is there any alternative for those Mausberry car switches? On both of them it says that there sold out and it's not possible to order them at the moment. :(

Postby khmann3 » Fri Nov 20, 2015 4:24 am

error
Last edited by khmann3 on Fri Nov 20, 2015 4:28 am, edited 2 times in total.

Postby khmann3 » Fri Nov 20, 2015 4:26 am

I certainly understand the desire to do things "properly" and shut the box down nicely, but my experience with logging Kismet to SD or USB with EXT4... it just doesn't matter. It may behoove you to create a separate "aligned" partition table entry for the log storage, and pass along -E stride,stripe_width parameters during filesystem creation (assume erase block size of 128k at _minimum_). But hundreds and hundreds of power-cycles on EXT4 *unjournaled* filesystems, I still haven't had a problem that required me to fsck or otherwise fix. EXT4 seems to recognize when it powered down while writing and makes the directory read-only, so my boot script does this:

Code: Select all

if [ -d "/mnt/log" ]; then i=1 while [ -d "/mnt/log-$i" ]; do i=$(($i + 1)) done mv /mnt/log /mnt/log-$i mkdir /mnt/log cd /mnt/log kismet_server --daemonize &> /dev/null fi
I also considered the idea of the auto-upload, but not seeing a fool-proof way to automate, I settled for swapping USB sticks into an extension cable for now.

Code: Select all

IMEI 004999010640000

Postby morbz » Tue Feb 02, 2016 1:50 pm

Anyone looking for an easy way to nicely poweroff the pi should look into this: https://github.com/claudiodangelis/unplug2shutdown

I set it so that when I remove my wifi adapter, the rpi shuts down.
I also copied that script and created another one that when I connect a specific wifi adapter (ath9k_htc, the best for creating an ap), it starts hostapd and udhcpd on that wlan, so I can connect to my pi wirelessly and retrieve data/edit configs.

30 posts • Page 1 of 2

Return to “Net Hugging Hardware and Software”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest