scapy icon indicating copy to clipboard operation
scapy copied to clipboard

Wrong FCS checkum in Dot11FCS

Open ash09 opened this issue 6 years ago • 1 comments

Brief description

Checksum is not calculated properly in Dot11FCS. The payload given to compute_fcs() contains the 4-bytes FCS field initialized with zeros.

Environment

  • Scapy version: v2.4.3
  • Python version: 3.5
  • Operating System: Debian 9

How to reproduce

In [19]: pkt = RadioTap() / Dot11FCS() / Dot11Beacon()                                                                  

In [20]: pkt.show()                                                                                                     
###[ RadioTap dummy ]### 
  version   = 0
  pad       = 0
  len       = None
  present   = Flags
  Flags     = FCS
  notdecoded= ''
###[ 802.11-FCS ]### 
     subtype   = 8
     type      = Management
     proto     = 0
     FCfield   = 
     ID        = 0
     addr1     = 00:00:00:00:00:00
     addr2     = 00:00:00:00:00:00
     addr3     = 00:00:00:00:00:00
     SC        = 0
     fcs       = None
###[ 802.11 Beacon ]### 
        timestamp = 0
        beacon_interval= 100
        cap       = 


In [21]: wireshark(Raw(pkt), linktype=DLT_IEEE802_11_RADIO)

Actual result

capture

Fix

scapy/layers/dot11.py

     def post_build(self, p, pay):
         p += pay
         if self.fcs is None:
-            p = p[:-4] + self.compute_fcs(p)
+            p = p[:-4] + self.compute_fcs(p[:-4])
         return p

ash09 avatar Apr 09 '20 09:04 ash09

Thanks for the note. Would you mind making a PR to fix that? Thanks

gpotter2 avatar Apr 10 '20 15:04 gpotter2