Ejemplo n.º 1
0
 def test_eapol_logoff_message_packs(self):
     expected_packed_message = bytes.fromhex(
         "0180c2000003001906eab88c888e01020000")
     message = EapolLogoffMessage(
         src_mac=MacAddress.from_string("00:19:06:ea:b8:8c"))
     packed_message = MessagePacker.ethernet_pack(
         message, MacAddress.from_string("00:19:06:ea:b8:8c"),
         MacAddress.from_string("01:80:c2:00:00:03"))
     self.assertEqual(expected_packed_message, packed_message)
Ejemplo n.º 2
0
 def test_failure_message_packs(self):
     expected_packed_message = bytes.fromhex(
         "000000000001001906eab88c888e0100000404ff0004")
     message = FailureMessage(
         src_mac=MacAddress.from_string("00:19:06:ea:b8:8c"),
         message_id=255)
     packed_message = MessagePacker.ethernet_pack(
         message, MacAddress.from_string("00:19:06:ea:b8:8c"),
         MacAddress.from_string("00:00:00:00:00:01"))
     self.assertEqual(expected_packed_message, packed_message)
Ejemplo n.º 3
0
 def test_success_message_packs(self):
     expected_packed_message = bytes.fromhex(
         "0180c2000003001906eab88c888e0100000403ff0004")
     message = SuccessMessage(
         src_mac=MacAddress.from_string("00:19:06:ea:b8:8c"),
         message_id=255)
     packed_message = MessagePacker.ethernet_pack(
         message, MacAddress.from_string("00:19:06:ea:b8:8c"),
         MacAddress.from_string("01:80:c2:00:00:03"))
     self.assertEqual(expected_packed_message, packed_message)
Ejemplo n.º 4
0
 def test_tls_message_packs(self):
     expected_packed_message = bytes.fromhex("000000111101444444444444888e"
                                             "010000b2026900b20d0016030100a7010000a303038c8007fa4ffe8f11fbe62debce4a1385e70be51efe77b105d205d2dc9ae815a5000038c02cc030009fcca9cca8ccaac02bc02f009ec024c028006bc023c0270067c00ac0140039c009c0130033009d009c003d003c0035002f00ff01000042000b000403000102000a000a0008001d0017001900180016000000170000000d0020001e060106020603050105020503040104020403030103020303020102020203")  # pylint: disable=line-too-long
     message = TlsMessage(src_mac=MacAddress.from_string("44:44:44:44:44:44"),
                          message_id=105, code=Eap.RESPONSE,
                          flags=0x00, extra_data=bytes.fromhex('16030100a7010000a303038c8007fa4ffe8f11fbe62debce4a1385e70be51efe77b105d205d2dc9ae815a5000038c02cc030009fcca9cca8ccaac02bc02f009ec024c028006bc023c0270067c00ac0140039c009c0130033009d009c003d003c0035002f00ff01000042000b000403000102000a000a0008001d0017001900180016000000170000000d0020001e060106020603050105020503040104020403030103020303020102020203'))  # pylint: disable=line-too-long
     packed_message = MessagePacker.ethernet_pack(
         message, MacAddress.from_string("44:44:44:44:44:44"),
         MacAddress.from_string("00:00:00:11:11:01"))
     self.assertEqual(expected_packed_message, packed_message)
Ejemplo n.º 5
0
 def test_identity_request_message_packs(self):  # pylint: disable=invalid-name
     expected_packed_message = bytes.fromhex(
         "0180c2000003001906eab88c888e010000050101000501")
     message = IdentityMessage(
         src_mac=MacAddress.from_string("00:19:06:ea:b8:8c"),
         message_id=1,
         code=Eap.REQUEST,
         identity="")
     packed_message = MessagePacker.ethernet_pack(
         message, MacAddress.from_string("00:19:06:ea:b8:8c"),
         MacAddress.from_string("01:80:c2:00:00:03"))
     self.assertEqual(expected_packed_message, packed_message)
Ejemplo n.º 6
0
 def test_legacy_nak_message_packs(self):
     expected_packed_message = bytes.fromhex("0180c2000003000000111101888e"
                                             "01000006026800060315")
     message = LegacyNakMessage(
         src_mac=MacAddress.from_string("00:00:00:11:11:01"),
         message_id=104,
         code=Eap.RESPONSE,
         desired_auth_types=[(21).to_bytes(length=1, byteorder='big')])
     packed_message = MessagePacker.ethernet_pack(
         message, MacAddress.from_string("00:00:00:11:11:01"),
         MacAddress.from_string("01:80:c2:00:00:03"))
     self.assertEqual(expected_packed_message, packed_message)
Ejemplo n.º 7
0
 def send_eap_messages(self):
     """Send EAP messages to Supplicant forever."""
     while self.running():
         sleep(0)
         eap_queue_message = self.eap_output_messages.get()
         self.logger.info("Sending message %s from %s to %s",
                          eap_queue_message.message,
                          str(eap_queue_message.port_mac),
                          str(eap_queue_message.src_mac))
         self.eap_socket.send(
             MessagePacker.ethernet_pack(eap_queue_message.message,
                                         eap_queue_message.port_mac,
                                         eap_queue_message.src_mac))
Ejemplo n.º 8
0
 def test_identity_response_message_packs(self):  # pylint: disable=invalid-name
     expected_packed_message = bytes.fromhex(
         "0180c2000003001422e9545e888e0100001102000011014a6f686e2e4d63477569726b"
     )
     message = IdentityMessage(
         src_mac=MacAddress.from_string("00:14:22:e9:54:5e"),
         message_id=0,
         code=Eap.RESPONSE,
         identity="John.McGuirk")
     packed_message = MessagePacker.ethernet_pack(
         message, MacAddress.from_string("00:14:22:e9:54:5e"),
         MacAddress.from_string("01:80:c2:00:00:03"))
     self.assertEqual(expected_packed_message, packed_message)
Ejemplo n.º 9
0
 def test_ttls_message_packs(self):
     expected_packed_message = bytes.fromhex("000000111101444444444444888e"
                                             "01000006016900061520")
     message = TtlsMessage(
         src_mac=MacAddress.from_string("44:44:44:44:44:44"),
         message_id=105,
         code=Eap.REQUEST,
         flags=0x20,
         extra_data=b'')
     packed_message = MessagePacker.ethernet_pack(
         message, MacAddress.from_string("44:44:44:44:44:44"),
         MacAddress.from_string("00:00:00:11:11:01"))
     self.assertEqual(expected_packed_message, packed_message)
Ejemplo n.º 10
0
 def test_md5_challenge_response_message_packs(self):  # pylint: disable=invalid-name
     expected_packed_message = bytes.fromhex(
         "0180c2000003001422e9545e888e010000220201002204103a535f0ee8c6b34fe714aa7dad9a0e154a6f686e2e4d63477569726b")  # pylint: disable=line-too-long
     message = Md5ChallengeMessage(
         src_mac=MacAddress.from_string("00:14:22:e9:54:5e"),
         message_id=1,
         code=Eap.RESPONSE,
         challenge=bytes.fromhex("3a535f0ee8c6b34fe714aa7dad9a0e15"),
         extra_data=b"John.McGuirk")
     packed_message = MessagePacker.ethernet_pack(
         message, MacAddress.from_string("00:14:22:e9:54:5e"),
         MacAddress.from_string("01:80:c2:00:00:03"))
     self.assertEqual(expected_packed_message, packed_message)
Ejemplo n.º 11
0
 def test_md5_challenge_request_message_packs(self):  # pylint: disable=invalid-name
     expected_packed_message = bytes.fromhex(
         "0180c2000003001906eab88c888e01000016010100160410824788d693e2adac6ce15641418228cf"
     )
     message = Md5ChallengeMessage(
         src_mac=MacAddress.from_string("00:19:06:ea:b8:8c"),
         message_id=1,
         code=Eap.REQUEST,
         challenge=bytes.fromhex("824788d693e2adac6ce15641418228cf"),
         extra_data=b"")
     packed_message = MessagePacker.ethernet_pack(
         message, MacAddress.from_string("00:19:06:ea:b8:8c"),
         MacAddress.from_string("01:80:c2:00:00:03"))
     self.assertEqual(expected_packed_message, packed_message)