Comments on: Parsing pcap files with Perl https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html Just another WordPress site Sat, 27 Oct 2012 18:02:51 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: whall https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html#comment-22 Sat, 27 Oct 2012 18:02:51 +0000 https://grey-panther.net/?p=118#comment-22 Nice example – thanx.

I had to add "use Exporter;" to the top in order for it to work. Otherwise you get this error:

$ perl -wc netpacket.pl
Can't locate package Exporter for @NetPacket::Ethernet::ISA at netpacket.pl line 5.
Can't locate package Exporter for @NetPacket::ISA at /usr/lib/perl5/site_perl/5.10/NetPacket/IP.pm line 17.
Can't locate package Exporter for @NetPacket::IP::ISA at netpacket.pl line 6.
Can't locate package Exporter for @NetPacket::TCP::ISA at netpacket.pl line 7.
netpacket.pl syntax OK

Also, I changed the "foo.pcap" to be $ARGV[0] so I could just pass it an argument.

my $log = Net::TcpDumpLog->new();
$log->read($ARGV[0]);

Now you can do "netpacket.pl ", put netpacket.pl in your path and use it anywhere.

I was wondering if anyone knew of any scripts that already existed that used these modules and exported useful information about the pcap, such as

– total number of flows
– total number of unique IP's seen (src vs dst)
– total number of unique ports seen (src vs dst)
– breakdown of traffic types (percentages based on dst port)
– top n flows, IP's, dst ports, packet sizes, etc

Basically I'm looking to get via text / perl the same stuff I might get from Wireshark's analysis. I just want it in text instead of graphical format or to have to launch wireshark.

]]>
By: Cd-MaN https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html#comment-39 Tue, 06 Sep 2011 14:09:10 +0000 https://grey-panther.net/?p=118#comment-39 @Anonymous – thank you, I updated the link in the article.

]]>
By: Anonymous https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html#comment-56 Fri, 15 Apr 2011 17:36:54 +0000 https://grey-panther.net/?p=118#comment-56 only FYI: NetPack link has changed:
http://search.cpan.org/~yanick/NetPacket-1.1.1/lib/NetPacket.pm

]]>
By: Cd-MaN https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html#comment-78 Mon, 03 Jan 2011 14:50:34 +0000 https://grey-panther.net/?p=118#comment-78 @Anonymous: the test.pcap file should be in the same directory where you start your script from. You can change where the file is read from by using a different path on the '$log->read("foo.pcap");' line (for example: $log->read("/home/cdman/test/bar.pcap");)

]]>
By: Anonymous https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html#comment-87 Sat, 01 Jan 2011 15:24:08 +0000 https://grey-panther.net/?p=118#comment-87 heloo guyz..i get an error that canot read "test.pcap" file..what could be the issue.. no such file or dirctory..could you plese tell where the Pcap file should be placed to run this program..

]]>
By: Cd-MaN https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html#comment-104 Thu, 23 Sep 2010 13:33:50 +0000 https://grey-panther.net/?p=118#comment-104 @Anonymous: this is not a module, rather a perl script (snippet). You should run it directly (ie. perl pcap.pl).

]]>
By: Anonymous https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html#comment-122 Wed, 07 Jul 2010 22:50:11 +0000 https://grey-panther.net/?p=118#comment-122 Thanks for this snippet. I am not able to run this module. I am getting pcap.pm not found error. Can you please let me know why this error?

]]>
By: Cd-MaN https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html#comment-131 Mon, 07 Jun 2010 07:05:59 +0000 https://grey-panther.net/?p=118#comment-131 @Anonymous: thanks good catch. Sorry for the late reply. I've updated the post. The actual formula is (as far as I can tell) "$secs + $msecs/1000".

]]>
By: Anonymous https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html#comment-135 Sun, 30 May 2010 12:25:15 +0000 https://grey-panther.net/?p=118#comment-135 Thanks, this saved me some slogging and experimenting 🙂

Do you mean to use localtime($secs) instead of localtime(time)?

]]>
By: Anonymous https://grey-panther.net/2010/03/parsing-pcap-files-with-perl.html#comment-162 Fri, 02 Apr 2010 06:08:05 +0000 https://grey-panther.net/?p=118#comment-162 Hmm, a PERL binding for the REST API that xtractr provides sounds like an interesting project…

]]>