Get "NameError: name 'IP' is not defined" error message

python python-3.x network-programming scapy

4411 просмотра

2 ответа

28 Репутация автора

I try to run a python code from online course to create a raw network packet and send to a network by scapy with python 3.4.2 on Debian 9 but I got the error message as show below:

NameError: name 'IP' is not defined

when I look into the code:

#!/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"

there is a red line under "IP" and "TCP" method and then It tell that those 2 methods are Unresolved reference

I try to change how to import scapy library

from

import scapy.all

to

from scapy.all import *

but the problem is not resolved. What do I something wrong?

Автор: thsecmaniac Источник Размещён: 18.07.2016 04:36

Ответы (2)


0 плюса

2150 Репутация автора

#!/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"
Автор: StephenG Размещён: 24.07.2016 10:11

2 плюса

21 Репутация автора

from scapy.layers.inet import IP
Автор: Ivan Adamov Размещён: 11.04.2019 07:15
Вопросы из категории :
32x32