问题
I just want to do -
from scapy import *
target = "42.42.42.42"
packet = IP()/UDP()
packet.dst = target
del pak[IP].chksum
del pak[TCP].chksum
pak.show2()
But "IP()" and "UDP()" are not defined.
If I use scapy.all it hands me this;
Traceback (most recent call last):
File "C:\Python27\scapy_stuff.py", line 1, in <module>
import scapy.all
File "C:\Python25\Lib\site-packages\scapy\all.py", line 13, in <module>
from arch import *
File "C:\Python25\lib\site-packages\scapy\arch\__init__.py", line 75, in <module>
from windows import *
File "C:\Python25\Lib\site-packages\scapy\arch\windows\__init__.py", line 19, in <module>
from scapy.arch import pcapdnet
File "C:\Python25\lib\site-packages\scapy\arch\pcapdnet.py", line 157, in <module>
import dnet
ImportError: No module named dnet
Everywhere I look people are just using interactive mode, I am starting to believe this is the only way.
回答1:
You will need to do a from scapy.all import *.
All detailed on the SecDev documentation, Using Scapy to build your own tools.
You can either import the entire scapy.all namespace, or import specifically what you need.
For the dnet issue, try this configuration where is is appropriate for your Scapy installation.
Change "scapy.config.conf.use_dnet = 1" to equal = 0
Depending on your system, it is either in scapy/arch/unix.py or scapy/arch/pcapdnet.py
来源:https://stackoverflow.com/questions/14638271/can-only-use-scapy-in-interactive-mode