[英]Pylibpcap for python-3.x
There was a library pylibpcap
for python2 that contained the functionality to create pcap objects like this:有一个用于 python2 的库
pylibpcap
,其中包含创建 pcap 对象的功能,如下所示:
import pcap
pc = pcap.pcapObject()
Now I'm looking for an analogue for python3, but from what I found ( pypcap
, pcap-ct
), these libraries don't contain similar functionality and look completely different.现在我正在寻找 python3 的类似物,但根据我的发现(
pypcap
, pcap-ct
),这些库不包含类似的功能并且看起来完全不同。 So maybe someone knows how the pylibpcap
library can be replaced in python3?那么也许有人知道如何在 python3 中替换
pylibpcap
库? I will be grateful for any advice.我将不胜感激任何建议。
You can use this package similar to your requirement, installation steps mentioned below:您可以根据您的要求使用此软件包,安装步骤如下:
$ sudo apt-get install libpcap-dev
$ pip3 install Cython python-libpcap
And usage as below:用法如下:
from pylibpcap import OpenPcap
p = OpenPcap("pcap.pcap", "a")
p.write(buf)
You can store pcap files in python using scapy module.您可以使用 scapy 模块将 pcap 文件存储在 python 中。 install it by -
安装它 -
pip install scapy
You can store the network traffic in pcap files using scapy.您可以使用 scapy 将网络流量存储在 pcap 文件中。 More info at this link - creating a pcap file using python
此链接上的更多信息 - 使用 python 创建 pcap 文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.