#!/bin/bash
##
### check-wps.sh - Check WPS-enabled routers for password change(provided you have the PIN)
##
#
export MODE
export BSSID=$2
export PIN=$3
export IFACE=$1
usage() {
echo ""
echo " $0 - Check WPS-enabled router's password"
echo " by frog on August 20th, 2012"
echo " Usage: $0 <interface> <bssid> <PIN>"
echo ""
}
checkMode() {
MODE=`iwconfig $IFACE | grep Mode`
MODE=`echo ${MODE:30:7}`
if [ $MODE = "Monitor" ]; then
MODE="Monitor"
else
MODE="Managed"
fi
}
checkRoot() {
if [ `whoami` != "root" ]; then
echo "Login as root and try again."
exit
fi
}
checkArgs() {
if [ -z $IFACE ]; then
echo "Set interface and try again."
usage
exit
fi
if [ -z $BSSID ]; then
echo "Set BSSID and try again."
usage
exit
fi
if [ -z $PIN ]; then
echo "Set PIN and try again."
usage
exit
fi
}
checkReaver() {
if [ -z `which reaver` ]; then
echo "Install reaver and try again."
exit
fi
}
checkPIN() {
if [ $MODE = "Monitor" ]; then
reaver -i $IFACE -b $BSSID -p $PIN -s /dev/null
elif [ $MODE = "Managed" ]; then
ifconfig $IFACE down; iwconfig $IFACE mode monitor
ifconfig $IFACE up
reaver -i $IFACE -b $BSSID -p $PIN -s /dev/null
ifconfig $IFACE down; iwconfig $IFACE mode managed
ifconfig $IFACE up
dhclient $IFACE 2>/dev/null
fi
}
#
##
### Start
checkRoot
checkReaver
checkArgs
checkMode
checkPIN
### End
##
#
EDIT: I got around the session resume issue by telling reaver to resume session from /dev/null; I changed the script above accordingly.
EDIT: Add dhcp request to maintain a local IP address after program is run.(only when you run the program with your interface in managed mode)