获取“NameError:name'IP'未定义”错误消息

问题描述 投票:1回答:2

我尝试从在线课程运行一个python代码来创建一个原始网络数据包并通过scapy在Debian 9上使用python 3.4.2发送到网络但是我收到了如下所示的错误消息:

NameError:未定义名称“IP”

当我查看代码时:

#!/usr/bin/python

#for python 3 , must install scapy for python3 first by type command "pip3 install scapy-python3"
import scapy.all

frame = scapy.all.Ether(dst="15:16:89:fa:dd:09") / IP(dst="9.16.5.4") / TCP() / "This is my payload"

在“IP”和“TCP”方法下有一条红线然后它告诉那两个方法是Unresolved reference

我尝试更改如何导入scapy库

from

import scapy.all

from scapy.all import *

但问题没有解决。我有什么不对的?

python python-3.x network-programming scapy
2个回答
1
投票
from scapy.layers.inet import IP

0
投票
#!/usr/bin/python

#for python 3 , must install scapy for python3 first by type command "pip3 install scapy-python3"
import scapy.all.Ether
import scapy.all.IP
import scapy.all.TCP

frame = Ether(dst="15:16:89:fa:dd:09") / IP(dst="9.16.5.4") / TCP() / "This is my payload"
© www.soinside.com 2019 - 2024. All rights reserved.