PermissionError: [Errno 1] 不允许操作

Kas*_*mad 4 scapy python-3.4

我对 python、linux RPI 和 scapy 完全陌生。我正在尝试使用 scapy 发送一些数据包。
在命令行上(仅当授予 scapy 超级用户权限时)

send(IP(dst="1.2.3.4")/ICMP())
Run Code Online (Sandbox Code Playgroud)

这在 python 脚本上运行时非常有效。

from scapy.all import *
p=send(IP(dst="1.2.3.4")/ICMP())
Run Code Online (Sandbox Code Playgroud)

抛出错误

Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    send(IP(dst="1.2.3.4")/ICMP())
  File "/usr/local/lib/python3.4/dist-packages/scapy/sendrecv.py",line   255, in send
    __gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime)
  File "/usr/local/lib/python3.4/dist-packages/scapy/arch/linux.py", line 326, in __init__
    self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))
  File "/usr/lib/python3.4/socket.py", line 123, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
PermissionError: [Errno 1] Operation not permitted<br>
Run Code Online (Sandbox Code Playgroud)

我正在尝试解决它,但不能,我对环境不熟悉,因此了解不多。就我的搜索而言,这个问题与套接字有关。但我仍然需要一些简单的解释才能理解。

Cuk*_*c0d 5

这意味着您需要使用 sudo/admin 权限启动脚本。

  • 这取决于您的操作系统:如果您使用的是 *nix,请在 Windows 上使用 `sudo python script.py`,您可以以管理员(资源管理器)身份启动 cmd,然后启动您的文件 (2认同)