我試圖使用scapy
,但我不知道爲什麼有些功能不起作用:的Python 2.7 + Scapy的2.3.1
Traceback (most recent call last):
File "/home/user/PycharmProjects/untitled/main.py", line 7, in <module>
a.show()
File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 819, in show
###[ Ethernet ]###
reprval = f.i2repr(self,fvalue)
File "/usr/lib/python2.7/dist-packages/scapy/fields.py", line 191, in i2repr
x = self.i2h(pkt, x)
File "/usr/lib/python2.7/dist-packages/scapy/layers/l2.py", line 88, in i2h
x = conf.neighbor.resolve(pkt,pkt.payload)
File "/usr/lib/python2.7/dist-packages/scapy/layers/l2.py", line 38, in resolve
return self.resolvers[k](l2inst,l3inst)
File "/usr/lib/python2.7/dist-packages/scapy/layers/inet.py", line 727, in <lambda>
conf.neighbor.register_l3(Ether, IP, lambda l2,l3: getmacbyip(l3.dst))
File "/usr/lib/python2.7/dist-packages/scapy/layers/l2.py", line 56, in getmacbyip
iff,a,gw = conf.route.route(ip)
AttributeError: 'NoneType' object has no attribute 'route'
沒有.show()
:在
from scapy.layers.inet import *
a = Ether()/IP(dst='192.168.1.1')/ICMP()
a.show()
結果它的作品和:
pck = Ether()
pck.show()
也可以。
我嘗試了一些其他功能,如.show
,但有時我得到這個錯誤。爲什麼?
它使回溯(最近通話最後一個): 文件 「/home/inck/PycharmProjects/untitled/main.py」,7號線,在 S,R = SR1(一)#發送&接收一個數據包 文件「/usr/lib/python2.7/dist-packages/scapy/sendrecv.py」,行334,sr1 s = conf.L3socket(filter = filter,nofilter = nofilter,iface = iface) 文件「/usr/lib/python2.7/dist-packages/scapy/arch/linux.py」,行307,在__init__中 self.ins = socket.socket(socket.AF_PACKET,socket.SOCK_RAW, socket.htons(type)) [...] socket.error:[Errno 1]不允許操作 –
Chris
您需要超級用戶(root)權限,因爲它會創建套接字。只要sudo,你就要走了。 – Misko