简体   繁体   English

仅在套接字中接受某些ip / mac / ethtype数据包

[英]only accept certain ip/mac/ethtype packets in a socket

I;ma completely new in network programming and a starter in python. 我是网络编程方面的全新专家,也是python的入门者。

I want so set a socket in Python to just accept certain packages. 我想在Python中设置一个套接字以仅接受某些程序包。 I have the following values at my disposal: 我可以使用以下值:

destination address and port source MAC address ethtype (own) 目标地址和端口源MAC地址ethtype(自己)

how can I set a filter to my socket class to only accept packets for me (at dest address,port) and/or the right ethtype, and/or send by the device with the known mac address ? 我如何为我的套接字类设置一个过滤器,使其仅接受我的数据包(在目标地址,端口)和/或正确的ethtype,和/或由具有已知mac地址的设备发送?

Any help would be greatly appreciated, I tried to look via Google, but the amount of hits is incredible, and I haven't been able to find an answer that solves my question so far. 任何帮助将不胜感激,我尝试通过Google查找,但点击量令人难以置信,到目前为止,我一直找不到能够解决我问题的答案。

Thanx, Arthur 坦克斯,亚瑟

I would recommend you to use scapy . 我建议您使用scapy It is a great tool for crafting custom packets and to do lot of other stuff. 这是制作自定义数据包和执行许多其他操作的好工具。

You can add filters in the scapy's sniff() to capture the packets you desire. 您可以在Scapy的sniff()中添加过滤器 ,以捕获所需的数据包。 You can also use scapy with your own python programm. 您也可以将scapy与您自己的python程序一起使用。 More over you'll find ton of tutorials on the internet on how to use scapy. 在更多的内容中,您会在Internet上找到大量有关如何使用Scapy的教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM