Reading PCAP FIles - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Reading PCAP FIles (/thread-17850.html) |
Help reading pcap files - Variables - Apr-26-2019 Hi peeps!! i need someone expertise to help me I am trying to read a pcap file with a program im making but im having problems If anyone has an idea how can i start, i already have the file i need the program to read, im just having problems trying to read it RE: Help reading pcap files - buran - Apr-26-2019 (Apr-26-2019, 03:41 AM)Variables Wrote: I am trying to read a pcap file with a program im making but im having problemspost your code in python tags, full traceback you get in error tags and ask specific questions. We are glad to help, but we don't write code for you Reading PCAP FIles - Variables - Apr-26-2019 Okay Guys! Im new here so im a bit lost, i dont know much about python, im learning Im doing this program which im trying to make it read a PCAP file(test1.pcap). When i try to print the output, nothing appears. Can someone help Thanks import dpkt f = open('test1.pcap') pcap = dpkt.pcap.Reader(f) f.close() RE: Reading PCAP FIles - buran - Apr-26-2019 well, there is no print in your code... did you read the tutorial from the docs: https://jon.oberheide.org/blog/2008/10/15/dpkt-tutorial-2-parsing-a-pcap-file/ it looks pretty outdated, but should help you start and improve from there RE: Reading PCAP FIles - Variables - Apr-26-2019 When i insert print, <dpkt.pcap.Reader object at 0x0000000003870EF0> this happens The idea of this program is to see how many packets i have, I just want to print the whole file RE: Reading PCAP FIles - buran - Apr-26-2019 it's a Reader object you can iterate over it and print each packet as shown in the tutorial or you can use Reader.readpkts() method to get a list and print it. If you just want the number of packets I guess you can print just the lenNot tested but import dpkt with open('test1.pcap', 'rb') as f: pcap = dpkt.pcap.Reader(f) packets = pcap.readpkts() print(len(packets)) print(packets)note that you will need to process packets further in order to extract info - see how they use Ethernet class in the tutorial |