【发布时间】:2019-10-17 02:57:38
【问题描述】:
您好,我是 Python 和 Scapy 的初学者。当我尝试在基本的第 2 层数据包上使用 sendp() 时,我收到了回溯错误。
使用 Python 3.8 和来自 https://scapy.readthedocs.io/en/latest/installation.html#platform-specific-instructions 的 Scapy 最新开发版本
这是我在 Python shell 中输入的内容:
import scapy
from scapy.all import *
a=Ether()/IP(dst="www.google.ca")/ICMP()/"Hello world"
sendp(a)
这是错误信息:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
sendp(a)
File "C:\Users\hoang\AppData\Local\Programs\Python\Python38-32\lib\site-packages\scapy-git_archive.dev304758016-py3.8.egg\scapy\sendrecv.py", line 336, in sendp
results = __gen_send(socket, x, inter=inter, loop=loop,
File "C:\Users\hoang\AppData\Local\Programs\Python\Python38-32\lib\site-packages\scapy-git_archive.dev304758016-py3.8.egg\scapy\sendrecv.py", line 296, in __gen_send
os.write(1, b".")
OSError: [Errno 9] Bad file descriptor
【问题讨论】:
-
在 Linux 上我必须以管理员权限运行它(使用命令
sudo)。也许在 Windows 上是同样的问题 - 只有管理员可以访问 scapy 使用的套接字。 -
@furas 感谢您的建议!如果我在 CMD shell 中工作,我可以发送带有 scapy 的数据包。但是将 scapy 导入 Python Shell (IDLE) 仍然不允许我发送数据包,即使我以管理员身份运行它也是如此。
-
所以问题是 IDLE,而不是代码。然后不要使用 IDLE,而是使用任何其他编辑器、IDE 或 python shell。