def enable_monitor(channel=None):
 tmp = init_app('iwconfig', True)
 iface = None
 for line in tmp.split('\n'):
  if line.startswith('wlan'):
   try:
    iface = line.split(' ')[0]
    if (channel is None):
     tmp = getoutput('airmon-ng start {0}'.format(iface))
    else:
     tmp = getoutput('airmon-ng start {0} {1}'.format(iface, channel))
    debug(("started '%s' in monitor mode" % iface))
   except Exception as j:
    Error(('Error enabling monitor mode: %s' % j))
   break
 return get_monitor_adapter()

def enable_monitor ( channel = None ) : tmp = init_app ( 'iwconfig' , True ) iface = None for line in tmp . split ( '\n' ) : if line . startswith ( 'wlan' ) : try : iface = line . split ( ' ' ) [ 0 ] if ( channel is None ) : tmp = getoutput ( 'airmon-ng start {0}' . format ( iface ) ) else : tmp = getoutput ( 'airmon-ng start {0} {1}' . format ( iface , channel ) ) debug ( ( "started '%s' in monitor mode" % iface ) ) except Exception as j : Error ( ( 'Error enabling monitor mode: %s' % j ) ) break return get_monitor_adapter ( )
enable monitor mode on the wireless adapter channel is the channel to monitor on .