'Handles command-line arguments, sets global variables.'

def handle_args(self):

    set_encrypt = False
    set_hscheck = False
    set_wep = False
    capfile = ''
    opt_parser = self.build_opt_parser()
    options = opt_parser.parse_args()
    try:
        if ((not set_encrypt) and (options.wpa or options.wep or options.wps)):
            self.WPS_DISABLE = True
            self.WPA_DISABLE = True
            self.WEP_DISABLE = True
            set_encrypt = True
        if options.recrack:
            self.SHOW_ALREADY_CRACKED = True
            print (((GR + '    [+]') + W) + '    including    already    cracked    networks    in    targets.')
        if options.wpa:
            if options.wps:
                print (((((((GR + '    [+]') + W) + '    targeting    ') + G) + 'WPA') + W) + '    encrypted    networks.')
            else:
                print (((((((((((GR + '    [+]') + W) + '    targeting    ') + G) + 'WPA') + W) + '    encrypted    networks    (use    ') + G) + '-wps') + W) + '    for    WPS    scan)')
            self.WPA_DISABLE = False
        if options.wep:
            print (((((((GR + '    [+]') + W) + '    targeting    ') + G) + 'WEP') + W) + '    encrypted    networks')
            self.WEP_DISABLE = False
        if options.wps:
            print (((((((GR + '    [+]') + W) + '    targeting    ') + G) + 'WPS-enabled') + W) + '    networks.')
            self.WPS_DISABLE = False
        if options.pixie:
            print (((((((GR + '    [+]') + W) + '    targeting    ') + G) + 'WPS-enabled') + W) + '    networks.')
            print (((((((GR + '    [+]') + W) + '    using    only    ') + G) + 'WPS    Pixie-Dust') + W) + '    attack.')
            self.WPS_DISABLE = False
            self.WEP_DISABLE = True
            self.PIXIE = True
        if options.channel:
            try:
                self.TARGET_CHANNEL = int(options.channel)
            except ValueError:
                print ((((((O + '    [!]') + R) + '    invalid    channel:    ') + O) + options.channel) + W)
            except IndexError:
                print ((((O + '    [!]') + R) + '    no    channel    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    channel    set    to    %s' % ((G + str(self.TARGET_CHANNEL)) + W)))
        if options.mac_anon:
            print ((((((GR + '    [+]') + W) + '    mac    address    anonymizing    ') + G) + 'enabled') + W)
            print ((O + '                        not:    only    works    if    device    is    not    already    in    monitor    mode!') + W)
            self.DO_NOT_CHANGE_MAC = False
        if options.interface:
            self.WIRELESS_IFACE = options.interface
            print (((GR + '    [+]') + W) + ('    set    interface    :%s' % ((G + self.WIRELESS_IFACE) + W)))
        if options.monitor_interface:
            self.MONITOR_IFACE = options.monitor_interface
            print (((GR + '    [+]') + W) + ('    set    interface    already    in    monitor    mode    :%s' % ((G + self.MONITOR_IFACE) + W)))
        if options.nodeauth:
            self.SEND_DEAUTHS = False
            print (((GR + '    [+]') + W) + ('    will    not    deauthenticate    clients    while    scanning%s' % W))
        if options.essid:
            try:
                self.TARGET_ESSID = options.essid
            except ValueError:
                print ((((R + '    [!]') + O) + '    no    ESSID    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    targeting    ESSID    "%s"' % ((G + self.TARGET_ESSID) + W)))
        if options.bssid:
            try:
                self.TARGET_BSSID = options.bssid
            except ValueError:
                print ((((R + '    [!]') + O) + '    no    BSSID    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    targeting    BSSID    "%s"' % ((G + self.TARGET_BSSID) + W)))
        if options.showb:
            self.SHOW_MAC_IN_SCAN = True
            print ((((((GR + '    [+]') + W) + '    target    MAC    address    viewing    ') + G) + 'enabled') + W)
        if options.all:
            self.ATTACK_ALL_TARGETS = True
            print ((((((GR + '    [+]') + W) + '    targeting    ') + G) + 'all    access    points') + W)
        if options.power:
            try:
                self.ATTACK_MIN_POWER = int(options.power)
            except ValueError:
                print (((R + '    [!]') + O) + ('    invalid    power    level:    %s' % ((R + options.power) + W)))
            except IndexError:
                print ((((R + '    [!]') + O) + '    no    power    level    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    minimum    target    power    set    to    %s' % ((G + str(self.ATTACK_MIN_POWER)) + W)))
        if options.tx:
            try:
                self.TX_POWER = int(options.tx)
            except ValueError:
                print (((R + '    [!]') + O) + ('    invalid    TX    power    leve:    %s' % ((R + options.tx) + W)))
            except IndexError:
                print ((((R + '    [!]') + O) + '    no    TX    power    level    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    TX    power    level    set    to    %s' % ((G + str(self.TX_POWER)) + W)))
        if options.quiet:
            self.VERBOSE_APS = False
            print ((((((GR + '    [+]') + W) + '    list    of    APs    during    scan    ') + O) + 'disabled') + W)
        if options.check:
            try:
                capfile = options.check
            except IndexError:
                print ((((R + '    [!]') + O) + '    unable    to    analyze    capture    file') + W)
                print ((((R + '    [!]') + O) + '    no    cap    file    given!\n') + W)
                self.exit_gracefully(1)
            else:
                if (not os.path.exists(capfile)):
                    print ((((R + '    [!]') + O) + '    unable    to    analyze    capture    file!') + W)
                    print (((((((R + '    [!]') + O) + '    file    not    found:    ') + R) + capfile) + '\n') + W)
                    self.exit_gracefully(1)
        if options.update:
            self.upgrade()
            exit(0)
        if options.cracked:
            if (len(self.CRACKED_TARGETS) == 0):
                print ((((((R + '    [!]') + O) + '    There    are    no    cracked    access    points    saved    to    ') + R) + 'cracked.db\n') + W)
                self.exit_gracefully(1)
            print (((((((GR + '    [+]') + W) + '    ') + W) + 'previously    cracked    access    points') + W) + ':')
            for victim in self.CRACKED_TARGETS:
                if (victim.wps != False):
                    print ('                    %s    (%s)    :    "%s"    -    Pin:    %s' % (((C + victim.ssid) + W), ((C + victim.bssid) + W), ((G + victim.key) + W), ((G + victim.wps) + W)))
                else:
                    print ('                    %s    (%s)    :    "%s"' % (((C + victim.ssid) + W), ((C + victim.bssid) + W), ((G + victim.key) + W)))
            print ''
            self.exit_gracefully(0)
        if ((not set_hscheck) and (options.tshark or options.cowpatty or options.aircrack or options.pyrit)):
            self.WPA_HANDSHAKE_TSHARK = False
            self.WPA_HANDSHAKE_PYRIT = False
            self.WPA_HANDSHAKE_COWPATTY = False
            self.WPA_HANDSHAKE_AIRCRACK = False
            set_hscheck = True
        if options.strip:
            self.WPA_STRIP_HANDSHAKE = True
            print ((((((GR + '    [+]') + W) + '    handshake    stripping    ') + G) + 'enabled') + W)
        if options.wpadt:
            try:
                self.WPA_DEAUTH_TIMEOUT = int(options.wpadt)
            except ValueError:
                print (((R + '    [!]') + O) + ('    invalid    deauth    timeout:    %s' % ((R + options.wpadt) + W)))
            except IndexError:
                print ((((R + '    [!]') + O) + '    no    deauth    timeout    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    WPA    deauth    timeout    set    to    %s' % ((G + str(self.WPA_DEAUTH_TIMEOUT)) + W)))
        if options.wpat:
            try:
                self.WPA_ATTACK_TIMEOUT = int(options.wpat)
            except ValueError:
                print (((R + '    [!]') + O) + ('    invalid    attack    timeout:    %s' % ((R + options.wpat) + W)))
            except IndexError:
                print ((((R + '    [!]') + O) + '    no    attack    timeout    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    WPA    attack    timeout    set    to    %s' % ((G + str(self.WPA_ATTACK_TIMEOUT)) + W)))
        if options.crack:
            self.WPA_DONT_CRACK = False
            print ((((((GR + '    [+]') + W) + '    WPA    cracking    ') + G) + 'enabled') + W)
            if options.dic:
                try:
                    self.WPA_DICTIONARY = options.dic
                except IndexError:
                    print (((R + '    [!]') + O) + '    no    WPA    dictionary    given!')
                else:
                    if os.path.exists(options.dic):
                        print (((GR + '    [+]') + W) + ('    WPA    dictionary    set    to    %s' % ((G + self.WPA_DICTIONARY) + W)))
                    else:
                        print (((R + '    [!]') + O) + ('    WPA    dictionary    file    not    found:    %s' % options.dic))
            else:
                print (((R + '    [!]') + O) + '    WPA    dictionary    file    not    given!')
                self.exit_gracefully(1)
        if options.tshark:
            self.WPA_HANDSHAKE_TSHARK = True
            print ((((((GR + '    [+]') + W) + '    tshark    handshake    verification    ') + G) + 'enabled') + W)
        if options.pyrit:
            self.WPA_HANDSHAKE_PYRIT = True
            print ((((((GR + '    [+]') + W) + '    pyrit    handshake    verification    ') + G) + 'enabled') + W)
        if options.aircrack:
            self.WPA_HANDSHAKE_AIRCRACK = True
            print ((((((GR + '    [+]') + W) + '    aircrack    handshake    verification    ') + G) + 'enabled') + W)
        if options.cowpatty:
            self.WPA_HANDSHAKE_COWPATTY = True
            print ((((((GR + '    [+]') + W) + '    cowpatty    handshake    verification    ') + G) + 'enabled') + W)
        if (((not set_wep) and options.chopchop) or options.fragment or options.caffeelatte or options.arpreplay or options.p0841 or options.hirte):
            self.WEP_CHOPCHOP = False
            self.WEP_ARPREPLAY = False
            self.WEP_CAFFELATTE = False
            self.WEP_FRAGMENT = False
            self.WEP_P0841 = False
            self.WEP_HIRTE = False
        if options.chopchop:
            print ((((((GR + '    [+]') + W) + '    WEP    chop-chop    attack    ') + G) + 'enabled') + W)
            self.WEP_CHOPCHOP = True
        if options.fragment:
            print ((((((GR + '    [+]') + W) + '    WEP    fragmentation    attack    ') + G) + 'enabled') + W)
            self.WEP_FRAGMENT = True
        if options.caffeelatte:
            print ((((((GR + '    [+]') + W) + '    WEP    caffe-latte    attack    ') + G) + 'enabled') + W)
            self.WEP_CAFFELATTE = True
        if options.arpreplay:
            print ((((((GR + '    [+]') + W) + '    WEP    arp-replay    attack    ') + G) + 'enabled') + W)
            self.WEP_ARPREPLAY = True
        if options.p0841:
            print ((((((GR + '    [+]') + W) + '    WEP    p0841    attack    ') + G) + 'enabled') + W)
            self.WEP_P0841 = True
        if options.hirte:
            print ((((((GR + '    [+]') + W) + '    WEP    hirte    attack    ') + G) + 'enabled') + W)
            self.WEP_HIRTE = True
        if options.fakeauth:
            print ((((((GR + '    [+]') + W) + '    ignoring    failed    fake-authentication    ') + R) + 'disabled') + W)
            self.WEP_IGNORE_FAKEAUTH = False
        if options.wepca:
            try:
                self.WEP_CRACK_AT_IVS = int(options.wepca)
            except ValueError:
                print (((R + '    [!]') + O) + ('    invalid    number:    %s' % ((R + options.wepca) + W)))
            except IndexError:
                print ((((R + '    [!]') + O) + '    no    IV    number    specified!') + W)
            else:
                print (((GR + '    [+]') + W) + ("    Starting    WEP    cracking    when    IV's    surpass    %s" % ((G + str(self.WEP_CRACK_AT_IVS)) + W)))
        if options.wept:
            try:
                self.WEP_TIMEOUT = int(options.wept)
            except ValueError:
                print (((R + '    [!]') + O) + ('    invalid    timeout:    %s' % ((R + options.wept) + W)))
            except IndexError:
                print ((((R + '    [!]') + O) + '    no    timeout    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    WEP    attack    timeout    set    to    %s' % (((G + str(self.WEP_TIMEOUT)) + '    seconds') + W)))
        if options.pps:
            try:
                self.WEP_PPS = int(options.pps)
            except ValueError:
                print (((R + '    [!]') + O) + ('    invalid    value:    %s' % ((R + options.pps) + W)))
            except IndexError:
                print ((((R + '    [!]') + O) + '    no    value    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    packets-per-second    rate    set    to    %s' % (((G + str(options.pps)) + '    packets/sec') + W)))
        if options.wepsave:
            self.WEP_SAVE = True
            print ((((((GR + '    [+]') + W) + '    WEP    .cap    file    saving    ') + G) + 'enabled') + W)
        if options.wpst:
            try:
                self.WPS_TIMEOUT = int(options.wpst)
            except ValueError:
                print (((R + '    [!]') + O) + ('    invalid    timeout:    %s' % ((R + options.wpst) + W)))
            except IndexError:
                print ((((R + '    [!]') + O) + '    no    timeout    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    WPS    attack    timeout    set    to    %s' % (((G + str(self.WPS_TIMEOUT)) + '    seconds') + W)))
        if options.wpsratio:
            try:
                self.WPS_RATIO_THRESHOLD = float(options.wpsratio)
            except ValueError:
                print (((R + '    [!]') + O) + ('    invalid    percentage:    %s' % ((R + options.wpsratio) + W)))
            except IndexError:
                print ((((R + '    [!]') + O) + '    no    ratio    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    minimum    WPS    tries/attempts    threshold    set    to    %s' % (((G + str(self.WPS_RATIO_THRESHOLD)) + '') + W)))
        if options.wpsretry:
            try:
                self.WPS_MAX_RETRIES = int(options.wpsretry)
            except ValueError:
                print (((R + '    [!]') + O) + ('    invalid    number:    %s' % ((R + options.wpsretry) + W)))
            except IndexError:
                print ((((R + '    [!]') + O) + '    no    number    given!') + W)
            else:
                print (((GR + '    [+]') + W) + ('    WPS    maximum    retries    set    to    %s' % (((G + str(self.WPS_MAX_RETRIES)) + '    retries') + W)))
    except IndexError:
        print '\nindexerror\n\n'
    if (capfile != ''):
        self.RUN_ENGINE.analyze_capfile(capfile)
    print ''
