secdev / scapy

Scapy: the Python-based interactive packet manipulation program & library.
https://scapy.net
GNU General Public License v2.0
10.67k stars 2.02k forks source link

haslayer(Dot11) Python2 vs Python3 #2590

Closed ratwix closed 4 years ago

ratwix commented 4 years ago

Things to consider Test on Rpi3

Brief description When testing "if packet.haslayer(Dot11)", it return nothing (always false) with Python3 but work with Python2.

How to reproduce

from scapy.all import *

ap_list = []

def PacketHandler(packet):
    if packet.haslayer(Dot11):
        if packet.type == 0 and packet.subtype == 4 :
            if packet.addr2 not in ap_list:
                ap_list.append(packet.addr2)
                print ("AP MAC: " + packet.addr2 + " with SSID:" + packet.info.decode() + " type " + packet.__class__.__name__)

print("Start sniffing")
sniff(iface="wlan0mon", prn=PacketHandler, store=0)
print("Stop sniffing")

Actual result $ sudo python3 test2.py Start sniffing

Expected result $ sudo python test2.py Start sniffing AP MAC: 24:0a:64:ca:02:0c with SSID: AP MAC: 7a:67:05:de:f9:3c with SSID: AP MAC: 54:60:09:f9:97:26 with SSID:unrudal AP MAC: ac:b5:7d:b6:b3:e7 with SSID: AP MAC: e4:b2:fb:46:aa:66 with SSID:

Related resources Version: 2.4.3 Python: 3.7

guedou commented 4 years ago

Please use the template to report an issue if you want us to provide an answer.

ratwix commented 4 years ago

Please use the template to report an issue if you want us to provide an answer.

Fixed

guedou commented 4 years ago

Could you try with the development version of Scapy?

ratwix commented 4 years ago

Sorry, I have stop this development.

Le mer. 29 avr. 2020 à 15:29, Guillaume Valadon notifications@github.com a écrit :

Could you try with the development version of Scapy?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/secdev/scapy/issues/2590#issuecomment-621206863, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA42GC6HQ6DA3JYWVVN6QJTRPATUTANCNFSM4MIVTO5Q .

alex-kowalczyk commented 4 years ago

This issue is valid, I confirm it on Python3.7 (vs working Python2 code). What could be done to resolve it?

guedou commented 4 years ago

@alex-kowalczyk You can open a new issue an provide a simple example that exhibits the issue without needing to sniff Wi-Fi frames.