2

There was a library pylibpcap for python2 that contained the functionality to create pcap objects like this:

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. So maybe someone knows how the pylibpcap library can be replaced in python3? I will be grateful for any advice.

Helen
  • 463
  • 2
  • 9
  • 23

2 Answers2

1

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)
Hedger
  • 112
  • 1
  • 6
1

You can store pcap files in python using scapy module. install it by -

pip install scapy

You can store the network traffic in pcap files using scapy. More info at this link - creating a pcap file using python

YadneshD
  • 396
  • 2
  • 12