Ejemplo n.º 1
0
    def test_bad_mac_address(self):
        timestamp = 1517872027.0
        s_mac = "aa:bb:cc:dd:ee"
        essid = "Test ESSID"

        with self.assertRaises(AddrFormatError):
            probe_req = ProbeRequest(timestamp, s_mac, essid)
Ejemplo n.º 2
0
    def test_without_parameters(self):
        """
        Initialises a 'ProbeRequest' object without any parameter.
        """

        # pylint: disable=no-value-for-parameter

        with self.assertRaises(TypeError):
            _ = ProbeRequest()
Ejemplo n.º 3
0
        def parse(packet):
            """
            Parses the packet and returns a probe request object.
            """

            timestamp = packet.getlayer(RadioTap).time
            s_mac = packet.getlayer(RadioTap).addr2
            essid = packet.getlayer(Dot11ProbeReq).info.decode("utf-8")

            return ProbeRequest(timestamp, s_mac, essid)
Ejemplo n.º 4
0
    def test_print_a_probe_request(self):
        timestamp = 1517872027.0
        s_mac = "aa:bb:cc:dd:ee:ff"
        essid = "Test ESSID"

        probe_req = ProbeRequest(timestamp, s_mac, essid)

        self.assertNotEqual(
            str(probe_req).find("Mon, 05 Feb 2018 23:07:07"), -1)
        self.assertNotEqual(
            str(probe_req).find("aa:bb:cc:dd:ee:ff (None) -> Test ESSID"), -1)
Ejemplo n.º 5
0
    def test_with_only_one_parameter(self):
        """
        Initialises a 'ProbeRequest' object with only one parameter.
        """

        # pylint: disable=no-value-for-parameter

        timestamp = 1517872027.0

        with self.assertRaises(TypeError):
            _ = ProbeRequest(timestamp)
Ejemplo n.º 6
0
    def test_bad_mac_address(self):
        """
        Initialises a 'ProbeRequest' object with a malformed MAC address.
        """

        timestamp = 1517872027.0
        s_mac = "aa:bb:cc:dd:ee"
        essid = "Test ESSID"

        with self.assertRaises(AddrFormatError):
            probe_req = ProbeRequest(timestamp, s_mac, essid)  # noqa: F841
Ejemplo n.º 7
0
    def test_create_a_probe_request(self):
        """
        Creates a new 'ProbeRequest' with all the required parameters.
        """

        # pylint: disable=no-self-use

        timestamp = 1517872027.0
        s_mac = "aa:bb:cc:dd:ee:ff"
        essid = "Test ESSID"

        _ = ProbeRequest(timestamp, s_mac, essid)
Ejemplo n.º 8
0
    def test_with_only_two_parameters(self):
        """
        Initialises a 'ProbeRequest' object with only two parameters.
        """

        # pylint: disable=no-value-for-parameter

        timestamp = 1517872027.0
        s_mac = "aa:bb:cc:dd:ee:ff"

        with self.assertRaises(TypeError):
            _ = ProbeRequest(timestamp, s_mac)
Ejemplo n.º 9
0
    def test_print_a_probe_request(self):
        """
        Initialises a 'ProbeRequest' object and prints it.
        """

        timestamp = 1517872027.0
        s_mac = "aa:bb:cc:dd:ee:ff"
        essid = "Test ESSID"

        probe_req = ProbeRequest(timestamp, s_mac, essid)

        self.assertNotEqual(
            str(probe_req).find("Mon, 05 Feb 2018 23:07:07"), -1)
        self.assertNotEqual(
            str(probe_req).find(
                "aa:bb:cc:dd:ee:ff (Unknown OUI) -> Test ESSID"), -1)
    def parse(packet):
        """
        Parses the raw packet and returns a probe request object.
        """

        try:
            if packet.haslayer(Dot11ProbeReq):
                timestamp = packet.getlayer(RadioTap).time
                s_mac = packet.getlayer(RadioTap).addr2
                essid = packet.getlayer(Dot11ProbeReq).info.decode("utf-8")

                return ProbeRequest(timestamp, s_mac, essid)

            return None
        except UnicodeDecodeError:
            # The ESSID is not a valid UTF-8 string.
            return None
Ejemplo n.º 11
0
 def test_without_parameters(self):
     with self.assertRaises(TypeError):
         probe_req = ProbeRequest()
Ejemplo n.º 12
0
    def test_create_a_probe_request(self):
        timestamp = 1517872027.0
        s_mac = "aa:bb:cc:dd:ee:ff"
        essid = "Test ESSID"

        probe_req = ProbeRequest(timestamp, s_mac, essid)
Ejemplo n.º 13
0
    def test_with_only_two_parameters(self):
        timestamp = 1517872027.0
        s_mac = "aa:bb:cc:dd:ee:ff"

        with self.assertRaises(TypeError):
            probe_req = ProbeRequest(timestamp, s_mac)
Ejemplo n.º 14
0
    def test_with_only_one_parameter(self):
        timestamp = 1517872027.0

        with self.assertRaises(TypeError):
            probe_req = ProbeRequest(timestamp)