1

Is there an efficient way to get the offset of some field in a packet captured with pyshark? For example, I need to get the offset of the source IP within the whole packet or within some layer header in the packet. Is it possible?

Ahmed Hussein
  • 715
  • 1
  • 15
  • 38

1 Answers1

0

I was able to solve my issue. Here is a sample code:

import pyshark

packets = pyshark.FileCapture(input_file=pcap_file_dir)
print(int(packets[0].ip.src.pos)) # Prints the offset of source IP
Ahmed Hussein
  • 715
  • 1
  • 15
  • 38