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

Custom 802.11 Vendor Specific packet #4659

Closed
Hoolean opened this issue Feb 6, 2025 · 2 comments
Closed

Custom 802.11 Vendor Specific packet #4659

Hoolean opened this issue Feb 6, 2025 · 2 comments

Comments

@Hoolean
Copy link

Hoolean commented Feb 6, 2025

Hello! Thank you for the excellent library :)

Scapy has specialised subclasses of Dot11EltVendorSpecific that interpret and parse the generic info field of the parent class:

scapy/scapy/layers/dot11.py

Lines 1428 to 1456 in c15a670

class Dot11EltVendorSpecific(Dot11Elt):
name = "802.11 Vendor Specific"
match_subclass = True
fields_desc = [
ByteEnumField("ID", 221, _dot11_id_enum),
ByteField("len", None),
OUIField("oui", 0x000000),
StrLenField("info", "", length_from=lambda x: x.len - 3)
]
@classmethod
def dispatch_hook(cls, _pkt=None, *args, **kargs):
if _pkt:
oui = struct.unpack("!I", b"\x00" + _pkt[2:5])[0]
if oui == 0x0050f2: # Microsoft
type_ = orb(_pkt[5])
if type_ == 0x01:
# MS WPA IE
return Dot11EltMicrosoftWPA
elif type_ == 0x02:
# MS WME IE TODO
# return Dot11EltMicrosoftWME
pass
elif type_ == 0x04:
# MS WPS IE TODO
# return Dot11EltWPS
pass
return Dot11EltVendorSpecific
return cls

For a project using Scapy as a library, how easiest can this be extended to cover an additional custom subclass? Is this possible with the current implementation and, if not, is another workaround accessible?

@gpotter2
Copy link
Member

gpotter2 commented Feb 7, 2025

Currently you're right, this isn't super extensible.
You need to update the file directly (feel free to contribute !).

@gpotter2 gpotter2 closed this as completed Feb 7, 2025
Hoolean added a commit to Hoolean/scapy that referenced this issue Feb 7, 2025
See secdev#4659

This commit allows the Dot11EltVendorSpecific packet to dispatch to its
subclasses based on their OUI, with the same idiom that the parent
Dot11Elt uses to select subclasses based on their ID already:

https://github.com/secdev/scapy/blob/c15a670926185f6ddb9b3330ed1f947ff6f14b92/scapy/layers/dot11.py#L1057-L1074

This is just a rough sketch, so feedback very welcome to make sure it is
heading in the right direction :)
Hoolean added a commit to Hoolean/scapy that referenced this issue Feb 7, 2025
See secdev#4659

This commit allows the Dot11EltVendorSpecific packet to dispatch to its
subclasses based on their OUI, with the same idiom that the parent
Dot11Elt uses to select subclasses based on their ID already:

https://github.com/secdev/scapy/blob/c15a670926185f6ddb9b3330ed1f947ff6f14b92/scapy/layers/dot11.py#L1057-L1074

This is just a rough sketch, so feedback very welcome to make sure it is
heading in the right direction :)
@Hoolean
Copy link
Author

Hoolean commented Feb 7, 2025

@gpotter2 Cheers for the speedy reply :) I've put up a PR at #4660

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants