2016-07-23 3 views
0

Amazonダッシュボタンから送信されたARP要求を見つけるための作業コードを見つけるのに問題があります。私はTed Benson's code、またthis code hereを試しましたが、どちらもうまくいかないようです。ダッシュボタンのARP要求を検出する

テッドのコード:

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 
     print("ARP Probe from: " + pkt[ARP].hwsrc) 
print(sniff(prn=arp_display, filter="arp", store=0, count=10)) 

私が午前問題はラインscapy.all import *です。私は説明の長いリストを取得しますが、エラーの最後の行は import dnet ImportError: No module named dnetです。 'AttributeError: 'module' object has no attribute 'AF_PACKET''

私が試した第二のコードは

import socket 
import struct 
import binascii 

# Written by Bob Steinbeiser (https://medium.com/@xtalker) 

rawSocket = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, 
         socket.htons(0x0003)) 
MAC = '74c24671971c' 

while True: 
    packet = rawSocket.recvfrom(2048) 

    ethernet_header = packet[0][0:14] 
    ethernet_detailed = struct.unpack('!6s6s2s', ethernet_header) 

    arp_header = packet[0][14:42] 
    arp_detailed = struct.unpack('2s2s1s1s2s6s4s6s4s', arp_header) 

    # skip non-ARP packets 
    ethertype = ethernet_detailed[2] 
    if ethertype != '\x08\x06': 
     continue 

    source_mac = binascii.hexlify(arp_detailed[5]) 
    dest_ip = socket.inet_ntoa(arp_detailed[8]) 

    if source_mac == MAC: 
     print "Dash button pressed!, IP = " + dest_ip 

これは私が取得していますエラーです。

私はPython 2.7と3.4の両方のコードを試しましたが、どちらも動作しません。私が何かできることがあれば、私に連絡してください。

+1

ようこそ。おそらく、この質問に答えるのに十分な情報がありません。 [How to ask](http://stackoverflow.com/help/how-to-ask)を参照して、[Minimal、Complete、and Verifiable example](http://stackoverflow.com/help/mcve)を作成してください。 – tmthydvnprt

答えて

0

this SO answerで説明されているように、最初の例では、おそらくlibdnetの依存関係がありません。

また、新しいモデルダッシュボタン(ARP要求ではなくDHCP要求を待ち受ける)を検出するには、別の方法が必要です。私はthis answerに解決策を記述する。

関連する問題