简体   繁体   English

使用Python 2.7在Windows上运行Scapy

[英]Running Scapy on Windows with Python 2.7

I like to use Scapy with Python v2.7 under Windows 7. 我喜欢在Windows 7下使用Scapy和Python v2.7。

  • How can I install the required module pypcap for Python 2.7? 如何为Python 2.7安装所需的模块pypcap?
  • Will it be possible to make Python scripts depending on Scapy into standalone Windows applications using a distribution tool such as py2exe? 是否可以使用py2exe等分发工具将Scapy的Python脚本变为独立的Windows应用程序?

The particular Python distribution I am using is Enthought Python distribution 7.02. 我使用的特定Python发行版是Enthought Python发行版7.02。

Intrusive update: please note that this answer is outdated , with recent versions (>=2.4.0) scapy will ONLY require Npcap (or Winpcap) to work, and IPython for the console. 侵入性更新:请注意,这个答案已经过时 ,最近的版本(> = 2.4.0)scapy只需要Npcap(或Winpcap)工作,IPython用于控制台。 Have a look at the official windows page 看一下官方的windows页面

In case someone needs Scapy for 64-bit + Python 2.7 , I've uploaded the binaries here: 如果有人需要Scapy for 64-bit + Python 2.7 ,我在这里上传了二进制文件:

https://github.com/Kondziowy/scapy_win64 https://github.com/Kondziowy/scapy_win64

In addition , you probably need to install WinPcap from the official site 此外 ,您可能需要从官方网站安装WinPcap


Compiling it yourself required a few fixes - I'll commit them upstream soon. 自己编译需要一些修复 - 我会尽快上传它们。

Q: how can i install required module pypcap 问:我如何安装所需的模块pypcap

Using Scapy with Windows 7 is possible, but it does not exactly work out of the box. 可以在Windows 7中使用Scapy,但它并不是完全可以开箱即用的。 An install guide can be found here: 可在此处找到安装指南:

http://www.secdev.org/projects/scapy/doc/installation.html#windows http://www.secdev.org/projects/scapy/doc/installation.html#windows

I strongly recommend to switch to python 2.6, as this will make your live much easier. 我强烈建议切换到python 2.6,因为这会让你的生活更轻松。

When you insist on 2.7 you will have to compile some of the require modules yourself. 当你坚持使用2.7时,你必须自己编译一些需要的模块。 Also, some key modules like pypcap have to be patched before they can be compiled with python 2.7 (see pycap patch ). 此外,像pypcap这样的关键模块必须先修补,然后才能用python 2.7编译(参见pycap补丁 )。

Here you will find some guidance on how to build the modules. 在这里,您将找到有关如何构建模块的一些指导。


Q: will it be possible to make python scripts depending on scapy into standalone windows applications 问:是否可以根据scapy将python脚本制作成独立的Windows应用程序

Yes and no. 是的,不是。 While you can use py2exe to build a an EXE from your python code. 虽然您可以使用py2exe从您的python代码构建一个EXE。 Scapy uses WinPcap which you have to install in addition to your application. Scapy使用WinPcap ,除了您的应用程序之外,您还必须安装它。

Dirk Loss provides an Windows installer for the dnet package for Python 2.7 . Dirk Loss 为Python 2.7的dnet包提供了Windows安装程序 Together with the Windows installer for the pypcap package for Python 2.7 I was able to run Scapy successfully on Python 2.7 on Windows. 用于Python 2.7的pypcap包Windows安装程序一起,我能够在Windows上的Python 2.7上成功运行Scapy。

A LOT OF ANSWERS ARE OUTDATED ! 很多答案都已经过时了!

Latest scapy version, that you can download on the official GitHub page: https://github.com/secdev/scapy Works without the old hand-compiled dependencies! 最新的scapy版本,您可以在官方GitHub页面上下载: https//github.com/secdev/scapy没有旧的手工编译依赖项工作!

They are two easy requirements: IPython (for the console) and npcap (or winpcap) 它们有两个简单的要求:IPython(用于控制台)和npcap(或winpcap)

You may follow the official tutorial here: http://scapy.readthedocs.io/en/latest/installation.html#windows 您可以按照官方教程: http//scapy.readthedocs.io/en/latest/installation.html#windows

Using the link posted by circus , I created binary installations for Scapy for python 2.7.x 32bit. 使用马戏团发布的链接,我为Scapy for python 2.7.x 32bit创建了二进制安装。 Link for the setups (with dependencies) https://github.com/Kondziowy/scapy_win64 设置链接(带依赖关系) https://github.com/Kondziowy/scapy_win64

If you don't have limitations forcing you to work with python2, you can try scapy3k from http://github.com/phaethon/scapy or pip install scapy-python3 . 如果您没有强制使用python2的限制,可以从http://github.com/phaethon/scapypip install scapy-python3尝试scapy3k。

It does not require dnet nor pypcap, no C compilation required. 它不需要dnet或pypcap,也不需要C编译。 I work with following config Windows 10/Anaconda 3.5/latest WinPcap. 我使用以下配置Windows 10 / Anaconda 3.5 /最新的WinPcap。

Minimum requirement to get Scapy running on Windows with Python 2.7 seems to be: pyreadline, pcapy, and dnet. 使用Python 2.7在Windows上运行Scapy的最低要求似乎是:pyreadline,pcapy和dnet。 The last two are the trickiest to compile and/or find pre-compiled binaries. 最后两个是编译和/或查找预编译二进制文件最棘手的。 One option for these is listed in the above answer. 上面的答案中列出了这些选项的一个选项。 Another download, together with with detailed steps on how getting Scapy to run on Windows is at: https://github.com/zlorb/scapy . 另一个下载,以及如何让Scapy在Windows上运行的详细步骤https//github.com/zlorb/scapy These steps describe also how to get the optional dependencies, such as Gnuplot and Tex. 这些步骤还描述了如何获取可选的依赖项,例如Gnuplot和Tex。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM