Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when calling sniff for multiple interfaces #3191

Closed
hobobandy opened this issue Apr 24, 2021 · 2 comments · Fixed by #3240
Closed

Exception when calling sniff for multiple interfaces #3191

hobobandy opened this issue Apr 24, 2021 · 2 comments · Fixed by #3240
Labels

Comments

@hobobandy
Copy link

Brief description

Basic sniff capture using multiple interfaces.
When passing a list (or dict) of interfaces, Scapy raises an exception (see below).

See 'Related resources' for probable cause/fix.

Environment

Scapy version: 2.4.5
Python version: 3.8.5
Operation System: Ubuntu 20.04.2.0 Desktop

How to reproduce

packets = sniff(iface=["wlan0", "wlan1", "wlan2", "wlan3"], prn=callback, store=0)

Actual result

File "scapy_file.py", line 197, in run
packets = sniff(iface=["wlan0","wlan1","wlan2","wlan3"], prn=callback, store=0)
File "/root/.local/share/virtualenvs/myenv/lib/python3.8/site-packages/scapy/sendrecv.py", line 1264, in sniff
sniffer._run(*args, **kwargs)
File "/root/.local/share/virtualenvs/myenv/lib/python3.8/site-packages/scapy/sendrecv.py", line 1128, in _run
sniff_sockets[L2socket(type=ETH_P_ALL, iface=iface,
File "/root/.local/share/virtualenvs/myenv/lib/python3.8/site-packages/scapy/arch/linux.py", line 501, in init
set_promisc(self.ins, self.iface)
File "/root/.local/share/virtualenvs/myenv/lib/python3.8/site-packages/scapy/arch/linux.py", line 181, in set_promisc
mreq = struct.pack("IHH8s", get_if_index(iff), PACKET_MR_PROMISC, 0, b"")
File "/root/.local/share/virtualenvs/myenv/lib/python3.8/site-packages/scapy/arch/linux.py", line 401, in get_if_index
return int(struct.unpack("I", get_if(iff, SIOCGIFINDEX)[16:20])[0])
File "/root/.local/share/virtualenvs/myenv/lib/python3.8/site-packages/scapy/arch/common.py", line 65, in get_if
return ioctl(sck, cmd, struct.pack("16s16x", iff.encode("utf8")))
AttributeError: 'list' object has no attribute 'encode'

Expected result

Expecting sniff to begin.

Related resources

Source probably related to this issue:
sendrecv.py - line 1111 to line 1128

Since I don't use a custom L2 socket, I simply commented out line 1111 to 1113 and used the default L2 socket:
L2socket = conf.L2listen

Proper fix probably involves looping through list items to instance an L2socket.

@guedou
Copy link
Member

guedou commented Apr 25, 2021

Thanks for reporting the issue. That is indeed a regression!

@guedou
Copy link
Member

guedou commented May 10, 2021

This regression was introduced in 4521d8a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants