Scapy has a built-in packet capture function called sniff(). By default, it will monitor all interfaces and capture all packets if you don't specify any filters or a certain interface:
from scapy.all import *from pprint import pprintprint("Begin capturing all packets from all interfaces. send ctrl+c to terminate and print summary")pkts = sniff()pprint(pkts.summary())
The script output is:
You can of course provide filters and specific interfaces to monitor whether the condition is matched. For example, in the preceding output we can see a mix of ICMP, TCP, SSH, and DHCP traffic hitting all interfaces. If we're interested only ...