Skip to content

Commit

Permalink
Fix 802.11 control frames type 1 addr
Browse files Browse the repository at this point in the history
  • Loading branch information
gpotter2 committed Dec 8, 2022
1 parent 6a4f0db commit b6b4fa2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scapy/layers/dot11.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,11 +713,12 @@ class Dot11(Packet):
ConditionalField(
_Dot11MacField("addr2", ETHER_ANY, 2),
lambda pkt: (pkt.type != 1 or
pkt.subtype in [0x8, 0x9, 0xa, 0xb, 0xe, 0xf]),
pkt.subtype in [0x4, 0x5, 0x6, 0x8, 0x9, 0xa, 0xb, 0xe, 0xf]),
),
ConditionalField(
_Dot11MacField("addr3", ETHER_ANY, 3),
lambda pkt: pkt.type in [0, 2],
lambda pkt: (pkt.type in [0, 2] or
((pkt.type, pkt.subtype) == (1, 6) and pkt.cfe == 6)),
),
ConditionalField(LEShortField("SC", 0), lambda pkt: pkt.type != 1),
ConditionalField(
Expand Down Expand Up @@ -770,6 +771,8 @@ def address_meaning(self, index):
if self.type == 0: # Management
return _dot11_addr_meaning[0][index]
elif self.type == 1: # Control
if (self.type, self.subtype) == (1, 6) and self.cfe == 6:
return ["RA", "NAV-SA", "NAV-DA"][index]
return _dot11_addr_meaning[1][index]
elif self.type == 2: # Data
meaning = _dot11_addr_meaning[2][index][
Expand Down
12 changes: 12 additions & 0 deletions test/scapy/layers/dot11.uts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ assert Dot11Elt(info="scapy").summary() == "SSID='scapy'"
assert Dot11Elt(ID=1).mysummary() == ""
assert Dot11(b'\x84\x00\x00\x00\x00\x11\x22\x33\x44\x55\x00\x11\x22\x33\x44\x55').addr2 == '00:11:22:33:44:55'

= Dot11 - type 1 subtype 4, 5, 6

assert raw(Dot11(type=1, subtype=4, addr2="ff:ff:ff:ff:ff:ff")) == b'D\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff'
assert raw(Dot11(type=1, subtype=5, addr2="ff:ff:ff:ff:ff:ff")) == b'T\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff'
assert raw(Dot11(type=1, subtype=6, addr2="ff:ff:ff:ff:ff:ff", cfe=3)) == b'd0\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff'
assert raw(Dot11(type=1, subtype=6, addr2="ff:ff:ff:ff:ff:ff", cfe=6, addr3="aa:aa:aa:aa:aa:aa")) == b'd`\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xaa\xaa\xaa\xaa\xaa\xaa'

assert Dot11(type=1, subtype=5).address_meaning(1) == 'RA'
assert Dot11(type=1, subtype=6, cfe=5).address_meaning(2) == 'TA'
assert Dot11(type=1, subtype=6, cfe=6).address_meaning(2) == 'NAV-SA'
assert Dot11(type=1, subtype=6, cfe=6).address_meaning(3) == 'NAV-DA'

= Multiple Dot11Elt layers
pkt = Dot11() / Dot11Beacon() / Dot11Elt(ID="Supported Rates") / Dot11Elt(ID="SSID", info="Scapy")
assert pkt[Dot11Elt::{"ID": 0}].info == b"Scapy"
Expand Down

0 comments on commit b6b4fa2

Please sign in to comment.