def setUp(self): """ Set up the tests """ self.network_manager = interfaces.NetworkManager() self.mac_address = "00:00:00:00:00:00"
def __init__(self): self.mac_matcher = macmatcher.MACMatcher(MAC_PREFIX_FILE) self.network_manager = interfaces.NetworkManager() self.template_manager = phishingpage.TemplateManager() self.access_point = accesspoint.AccessPoint() self.fw = firewall.Fw() self.em = extensions.ExtensionManager(self.network_manager)
def __init__(self): self.mac_matcher = macmatcher.MACMatcher(MAC_PREFIX_FILE) self.network_manager = interfaces.NetworkManager() self.template_manager = phishingpage.TemplateManager() self.access_point = accesspoint.AccessPoint() self.fw = firewall.Fw() self.logFileName = self.getFileName()
def test_multiple_extensions(self): # We need a NM to init EM nm = interfaces.NetworkManager() # Init an EM and pass some shared data em = extensions.ExtensionManager(nm) em.set_extensions(constants.DEFAULT_EXTENSIONS) shared_data = {"one": 1, "two": 2, "is_freq_hop_allowed": True} em.init_extensions(shared_data) # A deauth packet appears in the air packet = ( dot11.RadioTap() / dot11.Dot11( type=0, subtype=12, addr1="00:00:00:00:00:00", addr2="00:00:00:00:00:00", addr3="00:00:00:00:00:00") / dot11.Dot11Deauth()) em._process_packet(packet) # Packets to send have been merged from the two extensions # Validate with get_packet() assert em._packets_to_send["1"] == [1, 2, 3, 4] # Output has also been merged in one list. # Validate with send_output() assert em.get_output() == ["one", "two", "three", "four", "five"]
def test_internet_access_enable_error(self): """ Test internet_access_enable by passing invalid arguement """ network_manager = interfaces.NetworkManager() with self.assertRaises(interfaces.InvalidValueError): network_manager.internet_access_enable = 'invalid'
def test_is_interface_valid_mode_internet_is_managed_by_nm_true(self): """ Tests is_interface_valid when the adapter is internet mode """ interface_name = "wlan0" self.network_manager = interfaces.NetworkManager() adapter = interfaces.NetworkAdapter(interface_name, "CARD", "00:00:00:00:00:00") adapter.is_managed_by_nm = True self.network_manager._name_to_object[interface_name] = adapter actual = self.network_manager.is_interface_valid(interface_name, "internet") message = "Failed to validate an interface with internet mode" self.assertTrue(actual, message)
def test_single_extension(self): # We need a NM to init EM nm = interfaces.NetworkManager() # Init an EM and pass some shared data em = extensions.ExtensionManager(nm) em.set_extensions(constants.DEFAULT_EXTENSIONS) shared_data = {"one": 1, "two": 2} em.init_extensions(shared_data) # A deauth packet appears in the air packet = (dot11.RadioTap() / dot11.Dot11(type=0, subtype=12, addr1="00:00:00:00:00:00", addr2="00:00:00:00:00:00", addr3="00:00:00:00:00:00") / dot11.Dot11Deauth()) em._process_packet(packet) # The extension1.py sent packet "1" and returned output # "one", "two". Validate with get_packet(), send_output() assert em._packets_to_send["1"] == [1] assert em._packets_to_send["2"] == [] assert em.get_output() == ["one", "two"]