简体   繁体   English

RasPi不会在ARP探测器上触发

[英]RasPi not triggering on ARP Probe

I'm trying to learn about programming and working in command line and all that and I'm still really new at it. 我正在尝试学习编程和在命令行中工作以及所有这些,我仍然是新手。 I got an Amazon Dash button to mess around with and I was able to get it to trigger a message in a Slack room when you press it. 我得到了一个亚马逊短跑按钮,当你按下它时,我能够让它在Slack房间触发一条消息。 Then I tried recreated the program on my raspi2, it worked ONCE and now when I run the program it just seems to not recognize the MAC address, ie nothing happens at all. 然后我尝试在我的raspi2上重新创建程序,它工作ONCE,现在当我运行程序时,它似乎无法识别MAC地址,即根本没有任何事情发生。

Here is the program that is running 这是正在运行的程序

import requests
import json

SLACK_INCOMING_WEB_HOOK = "https://hooks.slack.com/services/....." #Figure I should remove this for my question...
SLACK_INCOMING_USER = "SlackBit Bot" #Slack Bot display name
SLACK_INCOMING_CHANNEL = "#test" #Slack Channel

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 == 'a0:02:dc:42:32:e3': # Huggies
        print "Pushed Doritos"
        payload = {
            "text": "You Pressed The Button!",
            "username": SLACK_INCOMING_USER,
            "channel": SLACK_INCOMING_CHANNEL
        }
        r = requests.post(SLACK_INCOMING_WEB_HOOK, json.dumps(payload), headers={'content-type': 'application/json'})
        print r.status_code
        print r.content
      else:
        print "ARP Probe from unknown device: " + pkt[ARP].hwsrc

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

It worked the very first time I ran the program and pressed the button, but now it just runs and does nothing indefinitely. 它是我第一次运行程序并按下按钮,但现在它只是运行并无限期地执行任何操作。

Any help would be appreciated. 任何帮助,将不胜感激。 Sorry if my terminology is all wrong. 对不起,如果我的术语都错了。

Thanks! 谢谢!

尝试评论该行:

if pkt[ARP].psrc == '0.0.0.0': # ARP Probe

I have two brand new dash buttons, instead of doing an arp for 0.0.0.0, they are doing a bootp request to get a dhcp address, this causes the common scripts that are looking for an arp 0.0.0.0 to ignore them. 我有两个全新的破折号按钮,而不是为0.0.0.0执行arp,他们正在执行bootp请求以获取dhcp地址,这会导致寻找arp 0.0.0.0的常见脚本忽略它们。

you can modify the scripts to watch for bootp, instead of watching for arp 0.0.0.0, or just, as cyrus says, comment out the line testing for an arp probe. 您可以修改脚本以监视bootp,而不是观察arp 0.0.0.0,或者只是,正如cyrus所说,注释掉arp探测器的线路测试。

For those still struggling with this change (Detecting the Dash button with bootp vs. arp), here's what I'm using with a brand new Dash button: 对于那些仍在努力应对这种变化的人(使用bootp vs. arp检测Dash按钮),这是我使用全新的Dash按钮时所使用的:

from scapy.all import *
import requests
import time
def arp_display(pkt):
  if pkt.haslayer(DHCP):
   if pkt[Ether].src == 'x:x:x:x:x:x': # Dash Button MAC
    print "Pushed Dash Button" 
   else: 
    print "BOOTP Request from other device: " + pkt[Ether].src
print sniff(prn=arp_display, filter="(udp and (port 67 or 68))", store=0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM