Skip to content
Advertisement

How to read pcapng (wireshark) files in Python?

I have a capture of some TCP packets in pcapng format and I’d like to open it in python to inspect the TCP payloads with address 192.168.1.198. I’ve only found this library: https://python-pcapng.readthedocs.io/en/latest/api/blocks.html but it does not support inspecting TCP payloads.

Is there an easy way?

Advertisement

Answer

You can use python-pcapng package. First install python-pcapng package by following command.

JavaScript

Then use following sample code.

JavaScript

Above code worked for me.

Reference: https://pypi.org/project/python-pcapng/

Advertisement