2016-07-18 125 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"