从scapy模块中找不到Ether类

时间:2015-12-28 00:06:52

标签: python scapy

我一直收到错误消息,说我的脚本中没有定义Ether()方法。我使用python 2.7并且arprequest和arpresponse变量位于类内部的函数内。我跟随tutourial,它是完全相同的代码。还有一个项目中包含相同的代码https://github.com/OsandaMalith/ARP-Spoofer/blob/master/arp.py(第171行)

from scapy import *
            arprequest = Ether(dst='ff:ff:ff:ff:ff:ff')/ARP(pdst=ip+str(i), hwdst='ff:ff:ff:ff:ff:ff')
            arpresponse = srp1(arprequest, timeout=2, verbose=0)

 Traceback (most recent call last):
   File "skivy.py", line 96, in <module>
     MITMtool().run()
   File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 824, in run
     runTouchApp()
   File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 487, in runTouchApp
     EventLoop.window.mainloop()
   File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_sdl2.py", line 539, in mainloop
     self._mainloop()
   File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_sdl2.py", line 300, in _mainloop
     EventLoop.idle()
   File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 330, in idle
     self.dispatch_input()
   File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 315, in dispatch_input
     post_dispatch_input(*pop(0))
   File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 281, in post_dispatch_input
     wid.dispatch('on_touch_up', me)
   File "_event.pyx", line 699, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:6856)
   File "/usr/lib/python2.7/dist-packages/kivy/uix/behaviors.py", line 163, in on_touch_up
     self.dispatch('on_release')
   File "_event.pyx", line 695, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:6815)
   File "_event.pyx", line 1168, in kivy._event.EventObservers.dispatch (kivy/_event.c:11690)
   File "_event.pyx", line 1052, in kivy._event.EventObservers._dispatch (kivy/_event.c:10730)
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1465, in custom_callback
     exec(__kvlang__.co_value, idmap)
   File "<string>", line 28, in <module>
   File "skivy.py", line 77, in ARPscan
     arprequest = Ether(dst='ff:ff:ff:ff:ff:ff')/ARP(pdst=ip+str(i), hwdst='ff:ff:ff:ff:ff:ff')
 NameError: global name 'Ether' is not defined

1 个答案:

答案 0 :(得分:0)

导入不正确,应该来自all模块。

from scapy.all import *

如果您希望直接导入Ether位于scapy.layers.l2