Skip to content

Instantly share code, notes, and snippets.

@elecnix
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elecnix/e8e1c61f6db02f2c0c77 to your computer and use it in GitHub Desktop.
Save elecnix/e8e1c61f6db02f2c0c77 to your computer and use it in GitHub Desktop.
Log BSSIDs and send them home
#!/bin/sh
# Config
HOME_HOSTNAME=destination.host
HOME_PORT=2413
LOG_BASEDIR=/tmp/wicycle/log
# Scan
NOW=$(date -Iseconds)
HOME_BASEURL=http://$HOME_HOSTNAME:$HOME_PORT
SCAN=$(iw dev wlan0 scan | grep ^BSS | sed -e 's/BSS \(.*\)(.*/\1/' | sort | uniq)
# Log
mkdir -p $LOG_BASEDIR
for bssid in $SCAN ; do
echo $NOW >> $(echo $LOG_BASEDIR/$bssid|tr : .)
done
count=$(echo "$SCAN" | wc -l)
logger wicycle-log Logging $count networks
# Send log
for bssid in `ls $LOG_BASEDIR` ; do
file=$LOG_BASEDIR/$bssid
echo "Sending $file"
echo $'POST /log/'`echo $bssid`$' HTTP/1.1\r\nUser-Agent:wicycle/0.1\r\nContent-type: application/x-www-form-urlencoded\r\nContent-length: '`wc -c < $file`$'\r\nConnection: Close\r\n\r\n'`cat $file` | nc $HOME_HOSTNAME $HOME_PORT || echo Failed
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment