Last active
August 29, 2015 14:06
-
-
Save elecnix/e8e1c61f6db02f2c0c77 to your computer and use it in GitHub Desktop.
Log BSSIDs and send them home
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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