python scapy 网卡抓包

首先需要安装scapy包,点击下载

 

 1 from scapy.all import *
 2 
 3 def pack_callback(packet):
 4     print packet.show() 
 5     if packet['Ether'].payload:
 6         print packet['Ether'].src
 7         print packet['Ether'].dst
 8         print packet['Ether'].type
 9 
10     if packet['ARP'].payload:
11         print packet['ARP'].psrc
12         print packet['ARP'].pdst
13         print packet['ARP'].hwsrc
14         print packet['ARP'].hwdst
15 
16 filterstr="arp" 
17 
18 sniff(filter=filterstr,prn=pack_callback, iface='enp7s0f1', count=0) 

 

posted @ 2018-12-08 20:57  wangjq_china  阅读(2557)  评论(0编辑  收藏