class WifiModule(Module): """ Module proxy class for WiFi-related modules """ config = Config({ Option( 'INTERFACE', "WiFi interface in monitor mode", True, choices=lambda o: o.root.mon_interfaces, ): None, }) path = "auxiliary/wifi" requirements = { 'state': { "INTERFACES": { None: [True, None, None] } }, 'system': ["wireless-tools/iwconfig"] } requirements_messages = { 'state': { 'INTERFACES': "At least one interface in monitor mode is required", } } def preload(self): return self.prerun() def prerun(self): if len(self.console.root.mon_interfaces) == 0: self.logger.warning("No interface in monitor mode defined ; please" " use the 'toggle' command") return False self.config['INTERFACE'] = self.console.root.mon_interfaces[0]
class WifiModule(Module): config = Config({ Option( 'INTERFACE', "WiFi interface", True, ): "wlx9cefd5fd9a0d", }) path = "auxiliary/wifi"
class WifiAttackModule(WifiModule): """ Module proxy class for WiFi-related modules handling a target """ config = Config({ Option('ESSID', "Target AP's ESSID", True, choices=lambda o: o.state['TARGETS'].keys()): None, }) def preload(self): if super(WifiAttackModule, self).preload() is False: return False t = self.console.state['TARGETS'] if len(t) == 0: self.logger.warning( "No target available yet ; please use the 'scan' command") return False self.config['ESSID'] = v = t[list(t.keys())[0]]['essid'] self.logger.debug("ESSID => {}".format(v))
class WifiAttackModule(WifiModule): config = Config({ Option( 'BSSID', "AP's BSSID", True, ): "00:00:00:00:00:00", }) def preamble(self): if self.console.state.get('MONITOR_IF') is None: self.logger.warning("No interface in monitor mode defined ; please" " use module 'auxiliary/wifi/monitor_mode'") return False if self.console.state.get('TARGETS') is None or \ len(self.console.state['TARGETS']) == 0: self.logger.warning("No target available yet ; please use module " "'auxiliary/wifi/find_*'") return False _ = self.console.state['TARGETS'] self.config['BSSID'] = v = _[list(_.keys())[0]][0] self.logger.debug("BSSID => {}".format(v)) self.config.option('BSSID').choices = [v[0] for k, v in _.items()] return True