def test_new_packet(self): """ Tests the 'new_packet' method. """ config = Config() new_packets = Queue() sniffer = PacketSniffer(config, new_packets) self.assertEqual(sniffer.new_packets.qsize(), 0) packet = RadioTap() \ / Dot11( addr1="ff:ff:ff:ff:ff:ff", addr2="aa:bb:cc:11:22:33", addr3="dd:ee:ff:11:22:33" ) \ / Dot11ProbeReq() \ / Dot11Elt( info="Test" ) sniffer.new_packet(packet) self.assertEqual(sniffer.new_packets.qsize(), 1) ProbeRequestParser.parse(sniffer.new_packets.get(timeout=1))
def test_no_probe_request_layer(self): """ Creates a non-probe-request Wi-Fi packet and parses it with the 'ProbeRequestParser.parse()' function. """ with self.assertRaises(TypeError): packet = RadioTap() / self.dot11_layer ProbeRequestParser.parse(packet)
def test_fuzz_packets(self): """ Parses 1000 randomly-generated probe requests with the 'ProbeRequestParser.parse()' function. """ # pylint: disable=no-self-use for i in range(0, 1000): packet = RadioTap() / fuzz(Dot11() / Dot11ProbeReq() / Dot11Elt()) ProbeRequestParser.parse(packet)
def test_empty_essid(self): """ Creates a probe request packet with an empty ESSID field and parses it with the 'ProbeRequestParser.parse()' function. """ packet = RadioTap() \ / self.dot11_layer \ / Dot11ProbeReq() \ / Dot11Elt( info="" ) ProbeRequestParser.parse(packet)
def test_no_probe_request_layer(self): """ Creates a non-probe-request Wi-Fi packet and parses it with the 'ProbeRequestParser.parse()' function. """ # pylint: disable=no-self-use packet = RadioTap() \ / Dot11( addr1="ff:ff:ff:ff:ff:ff", addr2="aa:bb:cc:11:22:33", addr3="dd:ee:ff:11:22:33" ) ProbeRequestParser.parse(packet)
def test_empty_essid(self): """ Creates a probe request packet with an empty ESSID field and parses it with the 'ProbeRequestParser.parse()' function. """ # pylint: disable=no-self-use packet = RadioTap() \ / Dot11( addr1="ff:ff:ff:ff:ff:ff", addr2="aa:bb:cc:11:22:33", addr3="dd:ee:ff:11:22:33" ) \ / Dot11ProbeReq() \ / Dot11Elt( info="" ) ProbeRequestParser.parse(packet)
def test_new_packet(self): """ Tests the 'new_packet' method. """ config = Config() new_packets = Queue() sniffer = FakePacketSniffer(config, new_packets) self.assertEqual(sniffer.new_packets.qsize(), 0) sniffer.new_packet() self.assertEqual(sniffer.new_packets.qsize(), 1) sniffer.new_packet() self.assertEqual(sniffer.new_packets.qsize(), 2) sniffer.new_packet() self.assertEqual(sniffer.new_packets.qsize(), 3) ProbeRequestParser.parse(sniffer.new_packets.get(timeout=1)) ProbeRequestParser.parse(sniffer.new_packets.get(timeout=1)) ProbeRequestParser.parse(sniffer.new_packets.get(timeout=1))
def new_parser(self): """ Creates a new parsing thread. """ self.parser = ProbeRequestParser(self.config, self.new_packets)