Search code examples
pythonwiresharkpcaplibpcappcap-ng

How to print PCAPNG metadata in Python?


I'm attempting my first Python program and could use a little help. My script on github

I need a way to print the metadata in a PCAPNG file. I want to print the application and version, OS, and interface for starters. The Section Header Block and the Interface Description Block contain the data I need.

My problem is the blocks/fields are not at a fixed size because of the Options field in each block:
PCAPNG format, See section 3.1 and 3.2

Questions:

1.) Are there any Python libraries that print that information?
2.) If not, are there any ways through Python that information could be easily grabbed

Thanks in advance.


Solution

  • There are no such libraries, you will have to write your own parser for the PCAPNG Section Header Blocks.

    Another option is to implement code to do a HTTP POST of the PCAPNG file to pcapng.com and parse the extracted metadata from the HTML result.