簡介:
前段時間裝的pypcap做嗅探。打包受阻。因為我都是在windows做的。也要打包到exe給别人用。
是以嘗試了一下scapy,也可以嗅探,貌似功能更強大。先用sniff吧。
這個也不是在venv中點滑鼠就能裝上的。
看下官方提示:
You need the following software packages in order to install Scapy on Windows:
Python: Python 2.7.X or 3.3+. After installation, add the Python installation directory and its Scripts subdirectory to your PATH. Depending on your Python version, the defaults would be C:\Python27 and C:\Python27\Scripts respectively.
Npcap: the latest version. Default values are recommanded. Scapy will also work with Winpcap.
Scapy: latest development version from the Git repository. Unzip the archive, open a command prompt in that directory and run “python setup.py install”.
把python加入系統PATH
安裝Npcap,沒說Npcap SDN。不過我電腦上裝的有。也不知道不裝可以不可以。
git 源碼, 運作python setup.py install
再講一下怎麼圖形安裝它。
pycharm打開源碼包。
打開setup.py,随便運作一下。不管報什麼錯。

點setup旁邊的小箭頭,打開 Edit Configurations
Script path : 這是setup.py的路徑,剛才忽視錯誤運作一下,就是為了讓它自動生成。
Parameters: 擴充指令 參數 填 install
Python interpreter :所用的環境,也就是要選venv。選你準備運作scapy的環境。安裝到這個環境裡面。
scapy示例代碼:沒有解包。亂碼一樣。
from scapy.all importsniff
pkts= sniff(prn=lambda x:x.sprintf("{IP:%IP.src% -> %IP.dst%\n}{Raw:%Raw.load%\n}"))print(pkts)