Mac OS上的Scapy ARP设置为en0不起作用

时间:2018-03-23 22:47:55

标签: python macos networking

Iam尝试在https://null-byte.wonderhowto.com/how-to/build-arp-scanner-using-scapy-and-python-0162731/

之后在Mac OS上执行ARP

继承我的代码(或他的)

import sys
from datetime import datetime
from scapy.all import srp,Ether,ARP,conf
conf.verb = 0
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst = '192.168.1.0/24'), timeout = 2, iface = 'en0', inter = 0.1)


for snd, rcv in ans:
    print rcv.sprintf(r"%Ether.src% - %ARP.psrc%")

我在Mac OS上运行,它给了我错误:

Traceback (most recent call last):
  File "arp.py", line 5, in <module>
    ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst = '192.168.1.1/24'), timeout = 2, iface = 'en0', inter = 0.1)
  File "/Library/Python/2.7/site-packages/scapy/sendrecv.py", line 378, in srp
    a,b=sndrcv(s ,x,*args,**kargs)
  File "/Library/Python/2.7/site-packages/scapy/sendrecv.py", line 133, in sndrcv
    r = pks.nonblock_recv()
  File "/Library/Python/2.7/site-packages/scapy/arch/pcapdnet.py", line 672, in nonblock_recv
    p = self.recv(MTU)
  File "/Library/Python/2.7/site-packages/scapy/arch/pcapdnet.py", line 653, in recv
    pkt = self.ins.next()
  File "/Library/Python/2.7/site-packages/scapy/arch/pcapdnet.py", line 390, in next
    s,us = h.getts()
AttributeError: 'NoneType' object has no attribute 'getts'

我的ifconfig输出是:

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
XHC20: flags=0<> mtu 0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 7c:04:d0:d2:77:34 
    inet6 fe80::46d:deb2:47a5:584a%en0 prefixlen 64 secured scopeid 0x5 
    inet 10.40.2.169 netmask 0xfffff800 broadcast 10.40.7.255
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
    ether 0e:04:d0:d2:77:34 
    media: autoselect
    status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
    ether b6:4c:39:61:6e:4d 
    inet6 fe80::b44c:39ff:fe61:6e4d%awdl0 prefixlen 64 scopeid 0x7 
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: active
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    options=60<TSO4,TSO6>
    ether 9a:00:10:01:97:a0 
    media: autoselect <full-duplex>
    status: inactive
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=63<RXCSUM,TXCSUM,TSO4,TSO6>
    ether 9a:00:10:01:97:a0 
    Configuration:
        id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
        maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
        root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
        ipfilter disabled flags 0x2
    member: en1 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 8 priority 0 path cost 0
    nd6 options=201<PERFORMNUD,DAD>
    media: <unknown type>
    status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
    options=6403<RXCSUM,TXCSUM,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
    inet6 fe80::606c:eaa0:59d7:84b0%utun0 prefixlen 64 scopeid 0xa 
    nd6 options=201<PERFORMNUD,DAD>

我很确定在同一网络中连接的设备的IP为192.168.1.141,但为什么它找不到它?任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

尝试运行命令sudo pip install pypcap以使错误消失。有关详细信息,请参阅this GitHub Issue