scapy icon indicating copy to clipboard operation
scapy copied to clipboard

Incorrect Exception when linktype conflict with filter

Open m8k7j opened this issue 1 year ago • 2 comments

Brief description

when I using Asnysniffer with filter, sometime the program will blocked at compile_filter, then when I stop Asynsniffer, there is no attribute stop_cb.

Scapy version

2.6.0

Python version

3.11

Operating system

ubuntu 20.04

Additional environment information

No response

How to reproduce

  • enable Asynsniffer
  • send some packet with scapy
  • stop Asynsniffer

Actual result

have no attribute stop_cb

Expected result

have no error when finished sniffer capture

Related resources

No response

m8k7j avatar Nov 11 '24 02:11 m8k7j

reproduce step:

from scapy.sendrecv import AsyncSniffer
import time

count = 0
sniffer = AsyncSniffer(iface='eth0', filter='wlan type mgt subtype deauth')
sniffer.start()
time.sleep(1)
sniffer.stop()
print(f'success {count}')

expect result is raise Scapy_Exception(scapy.error.Scapy_Exception: Cannot set filter real result is raise Scapy_Exception(scapy.error.Scapy_Exception: Unsupported (offline or unsupported socket)

m8k7j avatar Nov 11 '24 03:11 m8k7j

This also hit me, when I had a typo in the filter:

sniffy = AsyncSniffer(iface="wlp0s20f3", filter="not arpand not port 22")

See: https://stackoverflow.com/q/79766638/21826195

Took some time to figure it out, because the same error also arises from timing issues: https://stackoverflow.com/q/70559382/21826195

Mo-way avatar Sep 16 '25 22:09 Mo-way