Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for more ISAKMP payloads #4600

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion scapy/layers/isakmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,16 @@ class ISAKMP_payload_SA(ISAKMP_payload):

class ISAKMP_payload_Nonce(ISAKMP_payload):
name = "ISAKMP Nonce"
fields_desc = ISAKMP_payload.fields_desc[:3] + [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Sorry for the delay.

This looks okay but will break existing code. You should add a deprecated_fields (grep elsewhere in the code) to redirect the old 'load' to those newer names.

Thanks

StrLenField("nonce", "", length_from=lambda x: x.length - 4)
]


class ISAKMP_payload_KE(ISAKMP_payload):
name = "ISAKMP Key Exchange"
fields_desc = ISAKMP_payload.fields_desc[:3] + [
StrLenField("ke", "", length_from=lambda x: x.length - 4)
]


class ISAKMP_payload_ID(ISAKMP_payload):
Expand All @@ -439,7 +445,15 @@ class ISAKMP_payload_ID(ISAKMP_payload):

class ISAKMP_payload_Hash(ISAKMP_payload):
name = "ISAKMP Hash"
fields_desc = ISAKMP_payload.fields_desc[:3] + [
StrLenField("hash", "", length_from=lambda x: x.length - 4)
]

class ISAKMP_payload_SIG(ISAKMP_payload):
name = "ISAKMP Signature"
fields_desc = ISAKMP_payload.fields_desc[:3] + [
StrLenField("sig", "", length_from=lambda x: x.length - 4)
]

NotifyMessageType = {
1: "INVALID-PAYLOAD-TYPE",
Expand Down Expand Up @@ -471,6 +485,8 @@ class ISAKMP_payload_Hash(ISAKMP_payload):
27: "NOTIFY-SA-LIFETIME",
28: "CERTIFICATE-UNAVAILABLE",
29: "UNSUPPORTED-EXCHANGE-TYPE",
30: "UNEQUAL-PAYLOAD-LENGTHS",
16384: "CONNECTED",
# RFC 3706
36136: "R-U-THERE",
36137: "R-U-THERE-ACK",
Expand Down Expand Up @@ -520,7 +536,7 @@ class ISAKMP_payload_Delete(ISAKMP_payload):
# bind_layers(_ISAKMP_class, ISAKMP_payload_CERT, next_payload=6)
# bind_layers(_ISAKMP_class, ISAKMP_payload_CR, next_payload=7)
bind_layers(_ISAKMP_class, ISAKMP_payload_Hash, next_payload=8)
# bind_layers(_ISAKMP_class, ISAKMP_payload_SIG, next_payload=9)
bind_layers(_ISAKMP_class, ISAKMP_payload_SIG, next_payload=9)
bind_layers(_ISAKMP_class, ISAKMP_payload_Nonce, next_payload=10)
bind_layers(_ISAKMP_class, ISAKMP_payload_Notify, next_payload=11)
bind_layers(_ISAKMP_class, ISAKMP_payload_Delete, next_payload=12)
Expand Down