简体   繁体   中英

only accept certain ip/mac/ethtype packets in a socket

I;ma completely new in network programming and a starter in python.

I want so set a socket in Python to just accept certain packages. I have the following values at my disposal:

destination address and port source MAC address ethtype (own)

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 ?

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.

Thanx, Arthur

I would recommend you to use 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. You can also use scapy with your own python programm. More over you'll find ton of tutorials on the internet on how to use scapy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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