Can only use Scapy in interactive mode?

主宰稳场 提交于 2019-12-11 10:33:02

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!