使用Python和Scapy来嗅探Pi上的ARP

我正在尝试使用Raspberry Pi从我的网络上的特定无线设备查找ARP请求.这是亚马逊破折号按钮之一.当破折号连接到wifi时,有人使用此代码来收听.

from scapy.all import *
def arp_display(pkt):
  if pkt[ARP].op == 1: #who-has (request)
    if pkt[ARP].psrc == '0.0.0.0': # ARP Probe
      if pkt[ARP].hwsrc == '74:75:48:5f:99:30': # button 1
        print "Pushed Huggies"
      elif pkt[ARP].hwsrc == '10:ae:60:00:4d:f3': # button 2
        print "Pushed Elements"
      else:
        print "ARP Probe from unknown device: " + pkt[ARP].hwsrc

print sniff(prn=arp_display, filter="arp", store=0, count=10)

当我在Raspbian上运行它(安装了python和scapy)时,我收到一个错误

"IndexError: Layer [ARP] not found"

我完全不熟悉scapy,只是第一次潜水.谢谢你的任何想法.

解决方法:

我也在做同样的事情.我发现是没有安装tcpdump.

一个简单的sudo apt-get install tcpdump为我修复了这个错误.

上一篇:计算字符串中的数字,大小,写字母个数


下一篇:python – 如何找到scapy无线网络?