The idea is to read and write capture files like it is really a serialized data. The API is ment to be close as possible to json and pickle APIs.
install the package by:
pip install cap
or from the source:
python setup.py install
import cap
captured_packets = cap.load(open("C:\\test.cap", "rb"))
ip_v4_captured_packet = []
for captured_packet in captured_packets:
if captured_packet.data[12:14] == '\x08\x00':
ip_v4_captured_packet.append(p)
cap.dump(ip_v4_captured_packet, open('C:\\new_test.cap', "wb"))
Have a nice use and please report about problems and issues. Thank you.