You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AsyncSniffer will call resolve_iface to get linktype, but resolve_iface only take effect at init python program start, so if change link type in code, resolve_iface cannot recognize the linktype realtime, suggest add conf.ifaces.reload() at the beginning of resolve_iface function:
defresolve_iface(dev, retry=True):
# type: (_GlobInterfaceType, bool) -> NetworkInterface""" Resolve an interface name into the interface """conf.ifaces.reload()
ifisinstance(dev, NetworkInterface):
returndevtry:
returnconf.ifaces.dev_from_name(dev)
exceptValueError:
try:
returnconf.ifaces.dev_from_networkname(dev)
exceptValueError:
passifnotretry:
raiseValueError("Interface '%s' not found !"%dev)
# Nothing found yet. Reload to detect if it was added recentlyconf.ifaces.reload()
returnresolve_iface(dev, retry=False)
Scapy version
2.6.0
Python version
3.11
Operating system
ubuntu 20.04
Additional environment information
No response
How to reproduce
from scapy.sendrecv import AsyncSniffer
import time
import subprocess
set_link_type('monitor')
print('link type match filter')
capture()
set_link_type('managed')
print('link type not match filter')
capture()
execute the script twice will tirgger issue
Actual result
Traceback (most recent call last):
File "/home/dinghuan/.pyenv/pyenv-1.2.19/versions/3.11.1/lib/python3.11/site-packages/scapy/sendrecv.py", line 1400, in stop
self.stop_cb()
^^^^^^^^^^^^
AttributeError: 'AsyncSniffer' object has no attribute 'stop_cb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dinghuan/myscript/scapy/debug_stop_cb.py", line 32, in
capture()
File "/home/dinghuan/myscript/scapy/debug_stop_cb.py", line 27, in capture
sniffer.stop()
File "/home/dinghuan/.pyenv/pyenv-1.2.19/versions/3.11.1/lib/python3.11/site-packages/scapy/sendrecv.py", line 1402, in stop
raise Scapy_Exception(
scapy.error.Scapy_Exception: Unsupported (offline or unsupported socket)
Expected result
can get right linktype after code change the linktype
Related resources
No response
The text was updated successfully, but these errors were encountered:
Brief description
AsyncSniffer will call
resolve_iface
to get linktype, butresolve_iface
only take effect at init python program start, so if change link type in code,resolve_iface
cannot recognize the linktype realtime, suggest addconf.ifaces.reload()
at the beginning ofresolve_iface
function:Scapy version
2.6.0
Python version
3.11
Operating system
ubuntu 20.04
Additional environment information
No response
How to reproduce
from scapy.sendrecv import AsyncSniffer
import time
import subprocess
def set_link_type(mode_type):
subprocess.Popen(['sudo', 'ifconfig', 'wlan0', 'down'])
print('sudo ifconfig wlan0 down')
time.sleep(1)
if mode_type == 'managed':
subprocess.Popen(['sudo', 'iwconfig', 'wlan0', 'mode', 'managed'])
print('sudo iwconfig wlan0 mode managed')
time.sleep(1)
elif mode_type == 'monitor':
subprocess.Popen(['sudo', 'iwconfig', 'wlan0', 'mode', 'monitor'])
print('sudo iwconfig wlan0 mode monitor')
time.sleep(1)
subprocess.Popen(['sudo', 'ifconfig', 'wlan0', 'up'])
print('sudo ifconfig wlan0 up')
time.sleep(2)
def capture():
sniffer = AsyncSniffer(iface='wlan0', filter='wlan type mgt subtype deauth')
sniffer.start()
time.sleep(1)
sniffer.stop()
set_link_type('monitor')
print('link type match filter')
capture()
set_link_type('managed')
print('link type not match filter')
capture()
execute the script twice will tirgger issue
Actual result
Traceback (most recent call last):
File "/home/dinghuan/.pyenv/pyenv-1.2.19/versions/3.11.1/lib/python3.11/site-packages/scapy/sendrecv.py", line 1400, in stop
self.stop_cb()
^^^^^^^^^^^^
AttributeError: 'AsyncSniffer' object has no attribute 'stop_cb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dinghuan/myscript/scapy/debug_stop_cb.py", line 32, in
capture()
File "/home/dinghuan/myscript/scapy/debug_stop_cb.py", line 27, in capture
sniffer.stop()
File "/home/dinghuan/.pyenv/pyenv-1.2.19/versions/3.11.1/lib/python3.11/site-packages/scapy/sendrecv.py", line 1402, in stop
raise Scapy_Exception(
scapy.error.Scapy_Exception: Unsupported (offline or unsupported socket)
Expected result
can get right linktype after code change the linktype
Related resources
No response
The text was updated successfully, but these errors were encountered: