python scapy中sniffer的用法以及过滤器

Sniff方法定义:

sniff(filter="",iface="any", prn=function, count=N)windows

一、filter的规则使用 Berkeley Packet Filter (BPF)语法,具体参考:http://blog.csdn.net/qwertyupoiuytr/article/details/54670477网络

二、iface用来指定要在哪一个网络接口上进行抓包【即网卡的名称】(一般不指定即全部网络接口);例如:tcp

dpkg = sniff(filter="host 192.168.191.5 and tcp",iface="Microsoft Wi-Fi Direct Virtual Adapter #2",count=2)

其中windows下要获取iface网卡名称能够使用: ipconfig /all  ,以下:函数

 

三、prn指定回调函数,每当一个符合filter的报文被探测到时,就会执行回调函数,一般使用lambda表达式来写回调函数spa

四、count指定最多嗅探多少个报文(是指符合filter条件的报文,而非全部报文).net

相关文章
相关标签/搜索