Skip to content
Snippets Groups Projects
Commit 310e468d authored by Pierre Lorinquer's avatar Pierre Lorinquer Committed by Guillaume Valadon
Browse files

EAP_TTLS class added in eap.py. Regression tests have also been added to the regression.uts file.

Add a mysummary() method to the EAP class.
parent 679dc6e4
No related branches found
No related tags found
No related merge requests found
......@@ -268,6 +268,16 @@ class EAP(Packet):
return 1
return 0
def mysummary(self):
summary_str = "EAP %{eap_class}.code% %{eap_class}.type%".format(
eap_class = self.__class__.__name__
)
if self.type == 1 and self.code == EAP.RESPONSE:
summary_str += " %{eap_class}.identity%".format(
eap_class = self.__class__.__name__
)
return self.sprintf(summary_str)
def post_build(self, p, pay):
if self.len is None:
l = len(p) + len(pay)
......@@ -310,11 +320,33 @@ class EAP_TLS(EAP):
BitField('S', 0, 1),
BitField('reserved', 0, 5),
ConditionalField(IntField('tls_message_len', 0), lambda pkt: pkt.L == 1),
#PacketField("tls_data", None, TLS)
XStrLenField('tls_data', '', length_from=lambda pkt: 0 if pkt.len is None else pkt.len - (6 + 4 * pkt.L))
]
class EAP_TTLS(EAP):
"""
RFC 5281 - "Extensible Authentication Protocol Tunneled Transport Layer
Security Authenticated Protocol Version 0 (EAP-TTLSv0)"
"""
name = "EAP-TTLS"
fields_desc = [
ByteEnumField("code", 1, eap_codes),
ByteField("id", 0),
FieldLenField("len", None, fmt="H", length_of="data",
adjust=lambda p, x: x + 10 if p.L == 1 else x + 6),
ByteEnumField("type", 21, eap_types),
BitField("L", 0, 1),
BitField("M", 0, 1),
BitField("S", 0, 1),
BitField("reserved", 0, 2),
BitField("version", 0, 3),
ConditionalField(IntField("message_len", 0), lambda pkt: pkt.L == 1),
XStrLenField("data", "", length_from=lambda pkt: 0 if pkt.len is None else pkt.len - (6 + 4 * pkt.L))
]
class EAP_FAST(EAP):
"""
RFC 4851 - "The Flexible Authentication via Secure Tunneling
......
......@@ -6241,12 +6241,28 @@ assert(eap.type == 3)
assert(hasattr(eap, 'desired_auth_type'))
assert(eap.desired_auth_type == 43)
= EAP - Dissection (8)
s = b"\x02\x03\x01\x15\x15\x00\x16\x03\x01\x01\n\x01\x00\x01\x06\x03\x03\xd5\xd9\xd5rT\x9e\xb8\xbe,>\xcf!\xcf\xc7\x02\x8c\xb1\x1e^F\xf7\xc84\x8c\x01t4\x91[\x02\xc8/\x00\x00\x8c\xc00\xc0,\xc0(\xc0$\xc0\x14\xc0\n\x00\xa5\x00\xa3\x00\xa1\x00\x9f\x00k\x00j\x00i\x00h\x009\x008\x007\x006\x00\x88\x00\x87\x00\x86\x00\x85\xc02\xc0.\xc0*\xc0&\xc0\x0f\xc0\x05\x00\x9d\x00=\x005\x00\x84\xc0/\xc0+\xc0'\xc0#\xc0\x13\xc0\t\x00\xa4\x00\xa2\x00\xa0\x00\x9e\x00g\x00@\x00?\x00>\x003\x002\x001\x000\x00\x9a\x00\x99\x00\x98\x00\x97\x00E\x00D\x00C\x00B\xc01\xc0-\xc0)\xc0%\xc0\x0e\xc0\x04\x00\x9c\x00<\x00/\x00\x96\x00A\x00\xff\x01\x00\x00Q\x00\x0b\x00\x04\x03\x00\x01\x02\x00\n\x00\x1c\x00\x1a\x00\x17\x00\x19\x00\x1c\x00\x1b\x00\x18\x00\x1a\x00\x16\x00\x0e\x00\r\x00\x0b\x00\x0c\x00\t\x00\n\x00\r\x00 \x00\x1e\x06\x01\x06\x02\x06\x03\x05\x01\x05\x02\x05\x03\x04\x01\x04\x02\x04\x03\x03\x01\x03\x02\x03\x03\x02\x01\x02\x02\x02\x03\x00\x0f\x00\x01\x01"
eap = EAP(s)
assert(eap.code == 2)
assert(eap.id == 3)
assert(eap.len == 277)
assert(eap.type == 21)
assert(eap.haslayer(EAP_TTLS))
assert(eap[EAP_TTLS].L == 0)
assert(eap[EAP_TTLS].M == 0)
assert(eap[EAP_TTLS].S == 0)
assert(eap[EAP_TTLS].version == 0)
= EAP - EAP_TLS - Basic Instantiation
str(EAP_TLS()) == b'\x01\x00\x00\x06\r\x00'
= EAP - EAP_FAST - Basic Instantiation
str(EAP_FAST()) == b'\x01\x00\x00\x06+\x00'
= EAP - EAP_TTLS - Basic Instantiation
str(EAP_TTLS()) == b'\x01\x00\x00\x06\x15\x00'
= EAP - EAP_MD5 - Basic Instantiation
str(EAP_MD5()) == b'\x01\x00\x00\x06\x04\x00'
......@@ -6322,6 +6338,13 @@ assert(not EAP_MD5 in eap)
assert(not EAP_TLS in eap)
assert(not LEAP in eap)
assert(EAP in eap)
eap = EAP_TTLS()
assert(EAP_TTLS in eap)
assert(not EAP_MD5 in eap)
assert(not EAP_TLS in eap)
assert(not EAP_FAST in eap)
assert(not LEAP in eap)
assert(EAP in eap)
eap = LEAP()
assert(not EAP_MD5 in eap)
assert(not EAP_TLS in eap)
......@@ -6336,6 +6359,8 @@ eap = EAP_TLS()
assert(type(eap[EAP]) == EAP_TLS)
eap = EAP_FAST()
assert(type(eap[EAP]) == EAP_FAST)
eap = EAP_TTLS()
assert(type(eap[EAP]) == EAP_TTLS)
eap = LEAP()
assert(type(eap[EAP]) == LEAP)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment