()
return enable_monitor_mode(monitor)
Get the wireless interface in monitor mode. 
        Defaults to only device in monitor mode if found.
        Otherwise, enumerates list of possible wifi devices
        and asks user to select one to put into monitor mode (if multiple).
        Uses airmon-ng to put device in monitor mode if needed.
        Returns the name (string) of the interface chosen in monitor mode.
Get the wireless interface in monitor mode. 
        Defaults to only device in monitor mode if found.
        Otherwise, enumerates list of possible wifi devices
        and asks user to select one to put into monitor mode (if multiple).
        Uses airmon-ng to put device in monitor mode if needed.
        Returns the name (string) of the interface chosen in monitor mode.
Get the wireless interface in monitor mode . Defaults to only device in monitor mode if found . Otherwise enumerates list of possible wifi devices and asks user to select one to put into monitor mode ( if multiple ) . Uses airmon - ng to put device in monitor mode if needed . Returns the name ( string ) of the interface chosen in monitor mode .
def get_iface():
    """
        Get the wireless interface in monitor mode. 
        Defaults to only device in monitor mode if found.
        Otherwise, enumerates list of possible wifi devices
        and asks user to select one to put into monitor mode (if multiple).
        Uses airmon-ng to put device in monitor mode if needed.
        Returns the name (string) of the interface chosen in monitor mode.
    """
    global RUN_CONFIG
    if not RUN_CONFIG.PRINTED_SCANNING:
        print GR+' [+]'+W+' scanning for wireless devices...'
        RUN_CONFIG.PRINTED_SCANNING = True
    
    proc  = Popen(['iwconfig'], stdout=PIPE, stderr=DN)
    iface = ''
    monitors = []
    for line in proc.communicate()[0].split('\n'):
        if len(line) == 0: continue
        if ord(line[0]) != 32: # Doesn't start with space
            iface = line[:line.find(' ')] # is the interface
        if line.find('Mode:Monitor') != -1:
            monitors.append(iface)
    
    if RUN_CONFIG.WIRELESS_IFACE != '':
        if monitors.count(RUN_CONFIG.WIRELESS_IFACE): return RUN_CONFIG.WIRELESS_IFACE
        print R+' [!]'+O+' could not find wireless interface %s' % ('"'+R+RUN_CONFIG.WIRELESS_IFACE+O+'"'+W)

    if len(monitors) == 1:
        return monitors[0] # Default to only device in monitor mode
    elif len(monitors) > 1:
        print GR+" [+]"+W+" interfaces in "+G+"monitor mode:"+W
        for i, monitor in enumerate(monitors):
            print "  %s. %s" % (G+str(i+1)+W, G+monitor+W)
        ri = raw_input("%s [+]%s select %snumber%s of interface to use for capturing (%s1-%d%s): %s" % \
                  (GR,     W,       G,       W,                              G, len(monitors), W, G))
        while not ri.isdigit() or int(ri) < 1 or int(ri) > len(monitors):
            ri = raw_input("%s [+]%s select number of interface to use for capturing (%s1-%d%s): %s" % \
                     (GR,   W,                                              G, len(monitors), W, G))
        i = int(ri)
        return monitors[i - 1]
    
    proc  = Popen(['airmon-ng'], stdout=PIPE, stderr=DN)
    for line in proc.communicate()[0].split('\n'):
        if len(line) == 0 or line.startswith('Interface'): continue
        #monitors.append(line[:line.find('\t')])
        monitors.append(line)
    
    if len(monitors) == 0:
        print R+' [!]'+O+" no wireless interfaces were found."+W
        print R+' [!]'+O+" you need to plug in a wifi device or install drivers.\n"+W
        exit_gracefully(0)
    elif RUN_CONFIG.WIRELESS_IFACE != '' and monitors.count(RUN_CONFIG.WIRELESS_IFACE) > 0:
        mac_anonymize(monitor)
        return enable_monitor_mode(monitor)

    elif len(monitors) == 1:
        monitor = monitors[0][:monitors[0].find('\t')]
        mac_anonymize(monitor)
        
        return enable_monitor_mode(monitor)
    
    print GR+" [+]"+W+" available wireless devices:"
    for i, monitor in enumerate(monitors):
        print "  %s%d%s. %s" % (G, i + 1, W, monitor)
    
    ri = raw_input(GR+" [+]"+W+" select number of device to put into monitor mode (%s1-%d%s): " % (G, len(monitors), W))
    while not ri.isdigit() or int(ri) < 1 or int(ri) > len(monitors):
        ri = raw_input(" [+] select number of device to put into monitor mode (%s1-%d%s): " % (G, len(monitors), W))
    i = int(ri)
    monitor = monitors[i-1][:monitors[i-1].find('\t')]
    mac_anonymize(monitor)
    
    return enable_monitor_mode(monitor)
def get_iface ( ) : global RUN_CONFIG if not RUN_CONFIG . PRINTED_SCANNING : print GR + ' [+]' + W + ' scanning for wireless devices...' RUN_CONFIG . PRINTED_SCANNING = True proc = Popen ( [ 'iwconfig' ] , stdout = PIPE , stderr = DN ) iface = '' monitors = [ ] for line in proc . communicate ( ) [ 0 ] . split ( '\n' ) : if len ( line ) == 0 : continue if ord ( line [ 0 ] ) != 32 : # Doesn't start with space iface = line [ : line . find ( ' ' ) ] # is the interface if line . find ( 'Mode:Monitor' ) != - 1 : monitors . append ( iface ) if RUN_CONFIG . WIRELESS_IFACE != '' : if monitors . count ( RUN_CONFIG . WIRELESS_IFACE ) : return RUN_CONFIG . WIRELESS_IFACE print R + ' [!]' + O + ' could not find wireless interface %s' % ( '"' + R + RUN_CONFIG . WIRELESS_IFACE + O + '"' + W ) if len ( monitors ) == 1 : return monitors [ 0 ] # Default to only device in monitor mode elif len ( monitors ) > 1 : print GR + " [+]" + W + " interfaces in " + G + "monitor mode:" + W for i , monitor in enumerate ( monitors ) : print "  %s. %s" % ( G + str ( i + 1 ) + W , G + monitor + W ) ri = raw_input ( "%s [+]%s select %snumber%s of interface to use for capturing (%s1-%d%s): %s" % ( GR , W , G , W , G , len ( monitors ) , W , G ) ) while not ri . isdigit ( ) or int ( ri ) < 1 or int ( ri ) > len ( monitors ) : ri = raw_input ( "%s [+]%s select number of interface to use for capturing (%s1-%d%s): %s" % ( GR , W , G , len ( monitors ) , W , G ) ) i = int ( ri ) return monitors [ i - 1 ] proc = Popen ( [ 'airmon-ng' ] , stdout = PIPE , stderr = DN ) for line in proc . communicate ( ) [ 0 ] . split ( '\n' ) : if len ( line ) == 0 or line . startswith ( 'Interface' ) : continue #monitors.append(line[:line.find('\t')]) monitors . append ( line ) if len ( monitors ) == 0 : print R + ' [!]' + O + " no wireless interfaces were found." + W print R + ' [!]' + O + " you need to plug in a wifi device or install drivers.\n" + W exit_gracefully ( 0 ) elif RUN_CONFIG . WIRELESS_IFACE != '' and monitors . count ( RUN_CONFIG . WIRELESS_IFACE ) > 0 : mac_anonymize ( monitor ) return enable_monitor_mode ( monitor ) elif len ( monitors ) == 1 : monitor = monitors [ 0 ] [ : monitors [ 0 ] . find ( '\t' ) ] mac_anonymize ( monitor ) return enable_monitor_mode ( monitor ) print GR + " [+]" + W + " available wireless devices:" for i , monitor in enumerate ( monitors ) : print "  %s%d%s. %s" % ( G , i + 1 , W , monitor ) ri = raw_input ( GR + " [+]" + W + " select number of device to put into monitor mode (%s1-%d%s): " % ( G , len ( monitors ) , W ) ) while not ri . isdigit ( ) or int ( ri ) < 1 or int ( ri ) > len ( monitors ) : ri = raw_input ( " [+] select number of device to put into monitor mode (%s1-%d%s): " % ( G , len ( monitors ) , W ) ) i = int ( ri ) monitor = monitors [ i - 1 ] [ : monitors [ i - 1 ] . find ( '\t' ) ] mac_anonymize ( monitor ) return enable_monitor_mode ( monitor )