From charlesreid1

Revision as of 21:35, 24 January 2016 by Admin (talk | contribs)

Creating a pcap file reader in Scapy.

The Summary

You will need a pcap file to begin with. (Use Tcpdump or some other utility.)

Once you've got your pcap file:

  • Read in the pcap file
  • Loop through each packet to gather some basic aggregate statistics

Read Pcap File

Start scapy:

$ scapy
Welcome to Scapy (2.3.1)
>>> 

To read a pcap file, use the rdpcap() method and pass the absolute path to the pcap file:

>>> a=rdpcap("/path/to/capture.pcap")

Now you should be able to see the number of packets:

>>> len(a)
2055