import socket import os host = "192.168.148.128" if os.name == "nt": socket_protocol = socket.IPPROTO_IP else: socket_protocol = socket.IPPROTO_ICMP sniffer = socket.socket(socket.AF_INET,socket.SOCK_RAW,socket_protocol) sniffer.bind((host,0)) sniffer.setsockopt(socket.IPPROTO_IP,socket.IP_HDRINCL,1) if os.name=="nt": sniffer.ioctl(socket.SIO_RCVALL,socket.RCVALL_ON) print sniffer.recvfrom(65565) if os.name == "nt": sniffer.ioctl(socket.SIO_RCVALL,socket.RCVALL_OFF)
本文出自 “专注php” 博客,请务必保留此出处http://jingshanls.blog.51cto.com/3357095/1828225
原文地址:http://jingshanls.blog.51cto.com/3357095/1828225