def _pre_capture_config(self, override_configs=None): """Utility function which configures the wireless interface per the specified configurations. Operation is performed before every capture start using baseline configurations (specified when sniffer initialized) and override configurations specified here. """ final_configs = {} if self._base_configs: final_configs.update(self._base_configs) if override_configs: final_configs.update(override_configs) if sniffer.Sniffer.CONFIG_KEY_CHANNEL in final_configs: try: utils.exe_cmd( "iwconfig", self._interface, "channel", str(final_configs[sniffer.Sniffer.CONFIG_KEY_CHANNEL])) except Exception as err: raise sniffer.ExecutionError(err)
def __init__(self, interface, logger, base_configs=None): """See base class documentation """ self._base_configs = None self._capture_file_path = "" self._interface = "" self._logger = logger self._process = None self._temp_capture_file_path = "" if interface == "": raise sniffer.InvalidDataError("Empty interface provided") self._interface = interface self._base_configs = base_configs try: utils.exe_cmd("ifconfig", self._interface, "down") utils.exe_cmd("iwconfig", self._interface, "mode", "monitor") utils.exe_cmd("ifconfig", self._interface, "up") except Exception as err: raise sniffer.ExecutionError(err)
def __init__(self, interface, logger, base_configs=None): """See base class documentation """ self._base_configs = None self._capture_file_path = "" self._interface = "" self._logger = logger self._process = None self._temp_capture_file_path = "" if interface == "": raise sniffer.InvalidDataError("Empty interface provided") self._interface = interface self._base_configs = base_configs try: subprocess.check_call(['ifconfig', self._interface, 'down']) subprocess.check_call( ['iwconfig', self._interface, 'mode', 'monitor']) subprocess.check_call(['ifconfig', self._interface, 'up']) except Exception as err: raise sniffer.ExecutionError(err)