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

Missing warning when creating a layer 3 socket with iface #4596

Closed
adoebber opened this issue Nov 21, 2024 · 5 comments
Closed

Missing warning when creating a layer 3 socket with iface #4596

adoebber opened this issue Nov 21, 2024 · 5 comments

Comments

@adoebber
Copy link

Brief description

When I do this

scapy.all.send(my_packet, iface = "My Adapter")

I get the warning SyntaxWarning: 'iface' has no effect on L3 I/O send(). For multicast/link-local see https://scapy.readthedocs.io/en/latest/usage.html#multicast.

Shouldn't I get this warning for this code as well?

l3_socket = scapy.all.conf.L3socket6(iface="My Adapter")
l3_socket.send(my_packet)

I noticed that the behavior changed in scapy 2.6.0. In 2.5.0 I could send the packet this way. In 2.6.0 there is no warning and also no packet in Wireshark. I am not quite sure if this is a Windows 10 vs Windows 11 problem (on PCs with Windows 10 it works). However, it works if I use a l2 socket and prepend the packet with an Ether(). A warning in the second case would have saved me some time debugging the problem.

Scapy version

2.6.1

Python version

3.9

Operating system

Windows 11

Additional environment information

No response

How to reproduce

see code in description

Actual result

No response

Expected result

No response

Related resources

No response

@gpotter2
Copy link
Member

It's normal that there's no warning when using the socket directly. A socket is specific to a single interface.

What's the IP destination you're trying to reach? send is supposed to use the routing table, you can look at it using conf.route. Does conf.route.route("THE IP") returns the expected interface?

@adoebber
Copy link
Author

Thanks for your answer. I am sending packets to the IPv6 broadcast address.

>>> scapy.all.conf.route6.route("ff02::1")
('\\Device\\NPF_{4D63740E-6EE1-4423-86D3-BFA9DC83D786}', 'fe80::24ad:26fd:1f0b:28cd', '::')

This is not the expected interface. On the other PC it works and there it shows the correct interface. So I assume that this approach is not reliable for sending messages with broadcast or multicast destinations on particular interfaces? Do I need to use an L2 socket for this use case?

@gpotter2
Copy link
Member

You are using a multicast address. There usually are multiple routes for the same IP for those addresses. In that case, the behaviour is expected: Scapy can't know which interface to use.

Did you read the link you mentioned in your first post ? Scope identifiers are explained there, which are the new 2.6.0 way of doing that.

@adoebber
Copy link
Author

Ok, thank you very much. It would have been nice if I got a warning. But if this is intended behavior, I am fine with closing this PR.

@gpotter2
Copy link
Member

Yeah, sorry for the breaking change. It's documented in the 2.6.0 release notes and on the link you got in the warning https://scapy.readthedocs.io/en/latest/usage.html#multicast

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

No branches or pull requests

2 participants