From charlesreid1

Aircrack on Widy

This page covers the use of Aircrack on Widy to gather information about wireless traffic.

Installing

To install aircrack, connect the Widy to an internet connection (easiest to do using the Lua interface to pick a wifi network and enter a password), and use the opkg tool to install aircrack:

$ opkg install aircrack-ng

Testing

Test with a simple airodump command:

$ airodump-ng

Make sure you can see all the things.

Collecting

To collect wifi data, we can use one script to collect data using aircrack (easy peasy, don't have to bother writing our own dump script) and create new files at specified intervals.

Script to Dump

The following script creates new aircrack output files at intervals of 15 seconds:

import subprocess
import os
import time
from datetime import datetime

script_name = "AircrackIntervals.py"

# each experiment will be Nhours in duration
Nhours = 2

# each CSV file will be Nseconds in duration
Nseconds = 15

# figure out how many files there will be
Nfiles = (Nhours*3600)/Nseconds

# create a unique file prefix for this experiment
prefix = datetime.now().strftime('%Y-%m-%d_%H-%m')

print("[%s] About to put card in monitor mode."%(script_name) )
subprocess.call(['ifconfig','wlan0','down'])
subprocess.call(['iwconfig','wlan0','mode','monitor'])
subprocess.call(['ifconfig','wlan0','up'])
print "Done."

for i in range(Nfiles):

    # construct the airodump command and pipe all its output to /dev/null so it doesn't blow up the syslog
    FNULL = open(os.devnull,'w')
    the_cmd = ['airodump-ng','wlan0','-w',prefix,'--output-format','csv']

    # call it
    p = subprocess.Popen(the_cmd,stdout=FNULL, stderr=subprocess.STDOUT)

    # wait for it
    time.sleep(Nseconds)

    # aaaaand bail
    p.kill()

print("[%s] Success!"%s(script_name) )

Linking Aircrack to Buttons

To run the aircrack script when the slider button is set on 3G/4G, add a call to the Python script in /etc/hotplug.d/button/button:

#!/bin/sh
sleep 1 # give it a second, in case the user has butterfingers
logger "log: $BUTTON -- $ACTION"

if [ $ACTION == "released" ] ; then
    if [ $BUTTON == "BTN_1" ] ; then
        logger "Slider WISP"

    elif [ $BUTTON == "BTN_0" ] ; then
        logger "Slider 3G 4G"
        cd /root/wifi-data/collect
        python AircrackIntervals.py

    fi
elif [ $BUTTON == "BTN_0" ] || [ $BUTTON == "BTN_1" ] ; then
    logger "Slider AP"

fi

Flags