Exemplo n.º 1
0
    def test_check_mac_sta_with_link_probe(self):
        """Test to ensure Factory MAC is not exposed, using sniffer data.

        Steps:
            1. Configure and start the sniffer on 5GHz band.
            2. Connect to 5GHz network.
            3. Send link probes.
            4. Stop the sniffer.
            5. Invoke scapy to read the .pcap file.
            6. Read each packet summary and make sure Factory MAC is not used.

        """
        self.pcap_procs = wutils.start_pcap(self.packet_capture, 'dual',
                                            self.test_name)
        time.sleep(SHORT_TIMEOUT)
        network = self.wpapsk_5g
        rand_mac = self.connect_to_network_and_verify_mac_randomization(
            network)
        wutils.send_link_probes(self.dut, 3, 3)
        pcap_fname = '%s_%s.pcap' % \
            (self.pcap_procs[hostapd_constants.BAND_5G][1],
             hostapd_constants.BAND_5G.upper())
        wutils.stop_pcap(self.packet_capture, self.pcap_procs, False)
        time.sleep(SHORT_TIMEOUT)
        packets = rdpcap(pcap_fname)
        self.verify_mac_not_found_in_pcap(self.sta_factory_mac, packets)
        self.verify_mac_is_found_in_pcap(self.get_sta_mac_address(), packets)
Exemplo n.º 2
0
    def test_mac_randomization_ap_sta(self):
        """Bring up STA and softAP and verify MAC randomization.

        Steps:
            1. Connect to a network and get randomized MAC.
            2. Bring up softAP on the DUT.
            3. Connect to softAP network on the client and get MAC.
            4. Verify AP and STA use different randomized MACs.
            5. Find the channel of the SoftAp network.
            6. Configure sniffer on that channel.
            7. Verify the factory MAC is not leaked.

        """
        wutils.set_wifi_country_code(self.dut, wutils.WifiEnums.CountryCode.US)
        wutils.set_wifi_country_code(self.dut_client,
                                     wutils.WifiEnums.CountryCode.US)
        mac_sta = self.connect_to_network_and_verify_mac_randomization(
            self.wpapsk_2g)
        softap = wutils.start_softap_and_verify(self, WIFI_CONFIG_APBAND_2G)
        wutils.connect_to_wifi_network(self.dut_client, softap)
        softap_info = self.dut_client.droid.wifiGetConnectionInfo()
        mac_ap = softap_info['mac_address']
        if mac_sta == mac_ap:
            raise signals.TestFailure("Same MAC address was used for both "
                                      "AP and STA: %s" % mac_sta)

        # Verify SoftAp MAC is randomized
        softap_mac = self.get_soft_ap_mac_address()
        message = (
            'Randomized SoftAp MAC and Factory SoftAp MAC are the same. '
            'Randomized SoftAp MAC = %s, Factory SoftAp MAC = %s' %
            (softap_mac, self.soft_ap_factory_mac))
        asserts.assert_true(softap_mac != self.soft_ap_factory_mac, message)

        softap_channel = hostapd_constants.CHANNEL_MAP[
            softap_info['frequency']]
        self.log.info("softap_channel = %s\n" % (softap_channel))
        result = self.packet_capture.configure_monitor_mode(
            hostapd_constants.BAND_2G, softap_channel)
        if not result:
            raise ValueError("Failed to configure channel for 2G band")
        self.pcap_procs = wutils.start_pcap(self.packet_capture, 'dual',
                                            self.test_name)
        # re-connect to the softAp network after sniffer is started
        wutils.connect_to_wifi_network(self.dut_client, self.wpapsk_2g)
        wutils.connect_to_wifi_network(self.dut_client, softap)
        time.sleep(SHORT_TIMEOUT)
        wutils.stop_pcap(self.packet_capture, self.pcap_procs, False)
        pcap_fname = '%s_%s.pcap' % \
            (self.pcap_procs[hostapd_constants.BAND_2G][1],
             hostapd_constants.BAND_2G.upper())
        packets = rdpcap(pcap_fname)
        self.verify_mac_not_found_in_pcap(self.soft_ap_factory_mac, packets)
        self.verify_mac_not_found_in_pcap(self.sta_factory_mac, packets)
        self.verify_mac_is_found_in_pcap(softap_mac, packets)
        self.verify_mac_is_found_in_pcap(self.get_sta_mac_address(), packets)
Exemplo n.º 3
0
 def verify_mac_no_leakage(self):
     time.sleep(DEFAULT_TIMEOUT)
     self.log.info("Stopping packet capture")
     wutils.stop_pcap(self.packet_capture, self.pcap_procs, False)
     # Verify factory MAC is not leaked in 2G pcaps
     pcap_fname = '%s_%s.pcap' % (self.pcap_procs[BAND_2G][1],
                                  BAND_2G.upper())
     packets = rdpcap(pcap_fname)
     wutils.verify_mac_not_found_in_pcap(self.dut1_mac, packets)
     wutils.verify_mac_not_found_in_pcap(self.dut2_mac, packets)
Exemplo n.º 4
0
 def test_set_mac_randomization_to_none(self):
     self.pcap_procs = wutils.start_pcap(self.packet_capture, 'dual',
                                         self.test_name)
     network = self.wpapsk_2g
     # Set macRandomizationSetting to RANDOMIZATION_NONE.
     network["macRand"] = RANDOMIZATION_NONE
     self.connect_to_network_and_verify_mac_randomization(
         network, status=RANDOMIZATION_NONE)
     pcap_fname = '%s_%s.pcap' % \
         (self.pcap_procs[hostapd_constants.BAND_2G][1],
          hostapd_constants.BAND_2G.upper())
     time.sleep(SHORT_TIMEOUT)
     wutils.stop_pcap(self.packet_capture, self.pcap_procs, False)
     packets = rdpcap(pcap_fname)
     self.verify_mac_is_found_in_pcap(self.sta_factory_mac, packets)
Exemplo n.º 5
0
 def teardown_test(self):
     self.dut.droid.wakeLockRelease()
     self.dut.droid.goToSleepNow()
     wutils.stop_wifi_tethering(self.dut)
     wutils.reset_wifi(self.dut)
     wutils.reset_wifi(self.dut_client)
     wutils.stop_cnss_diags(self.android_devices)
     if hasattr(self, 'packet_capture') and self.pcap_procs:
         wutils.stop_pcap(self.packet_capture[0], self.pcap_procs, False)
         self.pcap_procs = None
     try:
         if "AccessPoint" in self.user_params:
             del self.user_params["reference_networks"]
             del self.user_params["open_network"]
     except:
         pass
     self.access_points[0].close()
Exemplo n.º 6
0
    def test_check_mac_in_wifi_scan(self):
        """Test to ensure Factory MAC is not exposed, in Wi-Fi scans

        Steps:
          1. Configure and start the sniffer on both bands.
          2. Perform a full scan.
          3. Stop the sniffer.
          4. Invoke scapy to read the .pcap file.
          5. Read each packet summary and make sure Factory MAC is not used.

        """
        self.pcap_procs = wutils.start_pcap(self.packet_capture, 'dual',
                                            self.test_name)
        wutils.start_wifi_connection_scan(self.dut)
        time.sleep(SHORT_TIMEOUT)
        wutils.stop_pcap(self.packet_capture, self.pcap_procs, False)
        pcap_fname = '%s_%s.pcap' % \
            (self.pcap_procs[hostapd_constants.BAND_2G][1],
             hostapd_constants.BAND_2G.upper())
        packets = rdpcap(pcap_fname)
        self.verify_mac_not_found_in_pcap(self.sta_factory_mac, packets)
    def test_ib_multi_data_path_mac_random_test(self):
        """Verify there is no factory MAC Address leakage during the Aware discovery, NDP creation,
        socket setup and IP service connection."""

        p_dut = self.android_devices[0]
        s_dut = self.android_devices[1]
        mac_addresses = []
        factory_mac_addresses = []
        sec_types = [self.ENCR_TYPE_PMK, self.ENCR_TYPE_PASSPHRASE]

        self.log.info("Starting packet capture")
        pcap_procs = wutils.start_pcap(
            self.packet_capture, 'dual', self.test_name)

        factory_mac_1 = p_dut.droid.wifigetFactorymacAddresses()[0]
        p_dut.log.info("Factory Address: %s", factory_mac_1)
        factory_mac_2 = s_dut.droid.wifigetFactorymacAddresses()[0]
        s_dut.log.info("Factory Address: %s", factory_mac_2)
        factory_mac_addresses.append(factory_mac_1)
        factory_mac_addresses.append(factory_mac_2)

        # Start Aware and exchange messages
        publish_session = self.start_aware(p_dut, True)
        subscribe_session = self.start_aware(s_dut, False)
        mac_addresses.append(publish_session["mac"])
        mac_addresses.append(subscribe_session["mac"])
        discovery_event = autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED)
        subscribe_session["peerId"] = discovery_event['data'][aconsts.SESSION_CB_KEY_PEER_ID]

        msg_id = self.get_next_msg_id()
        s_dut.droid.wifiAwareSendMessage(subscribe_session["discId"], subscribe_session["peerId"],
                                         msg_id, self.ping_msg, aconsts.MAX_TX_RETRIES)
        autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT)
        pub_rx_msg_event = autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED)
        publish_session["peerId"] = pub_rx_msg_event['data'][aconsts.SESSION_CB_KEY_PEER_ID]

        msg_id = self.get_next_msg_id()
        p_dut.droid.wifiAwareSendMessage(publish_session["discId"], publish_session["peerId"],
                                         msg_id, self.ping_msg, aconsts.MAX_TX_RETRIES)
        autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT)
        autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED)

        # Create Aware NDP
        p_req_keys = []
        s_req_keys = []
        for sec in sec_types:
            ndp_info = self.create_date_path(p_dut, publish_session, s_dut, subscribe_session, sec)
            p_req_keys.append(ndp_info["pubReqKey"])
            s_req_keys.append(ndp_info["subReqKey"])
            mac_addresses.append(ndp_info["pubIfMac"])
            mac_addresses.append(ndp_info["subIfMac"])

        # clean-up
        for p_req_key in p_req_keys:
            p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
        for s_req_key in s_req_keys:
            s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
        p_dut.droid.wifiAwareDestroyAll()
        s_dut.droid.wifiAwareDestroyAll()

        self.log.info("Stopping packet capture")
        wutils.stop_pcap(self.packet_capture, pcap_procs, False)

        self.verify_mac_no_leakage(pcap_procs, factory_mac_addresses, mac_addresses)
 def on_fail(self, test_name, begin_time):
     # Sleep to ensure all failed packets are captured.
     time.sleep(5)
     wutils.stop_pcap(self.pcap, self.pcap_procs, False)
     self.dut.take_bug_report(test_name, begin_time)
     self.dut.cat_adb_log(test_name, begin_time)
 def on_pass(self, test_name, begin_time):
     wutils.stop_pcap(self.pcap, self.pcap_procs, True)
Exemplo n.º 10
0
 def on_fail(self, test_name, begin_time):
     if hasattr(self, 'packet_capture'):
         wutils.stop_pcap(self.packet_capture, self.pcap_procs, False)
     self.dut.take_bug_report(test_name, begin_time)
     self.dut.cat_adb_log(test_name, begin_time)
Exemplo n.º 11
0
 def on_pass(self, test_name, begin_time):
     if hasattr(self, 'packet_capture'):
         wutils.stop_pcap(self.packet_capture, self.pcap_procs, True)