2016-07-18 79 views
1

我尝试从在线课程运行python代码以创建原始网络数据包并通过scapy在Debian 9上使用python 3.4.2发送到网络,但是我得到了错误信息,如下所示:获取“NameError:name'IP'未定义”错误消息

NameError: name 'IP' is not defined

当我看着代码

#!/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”方法的红线,然后它告诉那些2方法有Unresolved reference

我试图改变如何导入Scapy的库

from 

import scapy.all 

from scapy.all import * 

但问题没有得到解决。我有什么问题?

+0

当您使用scapy import *'时,这种行为是否会持续存在? – Clay

+0

@Clay yes和它给了我另一个错误,即“AttributeError:'builtin_function_or_method'对象没有属性'以太'” – thsecmaniac

+2

尝试从scapy.all导入*并在代码Ether(dst =“15:16:89:fa :dd:09“)/ IP(dst =”9.16.5.4“)/ TCP()/”这是我的有效载荷“ – galaxyan

回答

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"