What is the best way to sniff network packets using Python?
I\'ve heard from several places that the best module for this is a module called Scapy, unfortunately, it
you can use raw sockets, with your interface ip address (in admin mode),
import socket
s = socket.socket(socket.AF_INET,socket.SOCK_RAW,socket.IPPROTO_IP)
s.bind(("YOUR_INTERFACE_IP",0))
s.setsockopt(socket.IPPROTO_IP,socket.IP_HDRINCL,1)
s.ioctl(socket.SIO_RCVALL,socket.RCVALL_ON)
while True:
data = s.recvfrom(10000)
print data