Hello perl gurus,
I'm fairly new to Perl, but have chosen it for something I'm working on now as it seems to be the right tool for the job: I have some pcap files which I want to perform some analysis on. I want to:
i) Reconstruct TCP flows
ii) Have access to all headers + payloads of packets within each flow
So far I've found Net::TcpDumpLog which has allowed me to extract individual packets (headers + payload) from pcap files fine. But I don't want to manually rebuild sessions (as I'm sure there's a better way). The code for that is here -> http://perl.pastebin.com/m79529a69
Now I'm hoping someone much smarter than me can shove me in the right direction about how to reconstruct flows. My overall goal is to have a file output which has something like the following, one per line:
flow_num IP_src IP_dest TCP_srcPort TCP_dstPort num_of_packets_in_flow avg_packet_payload_size avg_packet_interarrival_time
I found a Linux tool called tcpflow[1], but it reconstructs flows with minimal packet information. Next I found a package called Net::Analysis[2] which I think may be the solution, but I'm struggling to understand how to actually use it, as I'm not sure how modules, interfaces, classes etc work in Perl. I see that there is a class called TCPMonologue which I *think* is what I need to use, along with the Listener::TCP module (already I'm confused between classes and modules).
To pseudo code what I want to do:
There seems to be some sort of command line interface from reading the documentation: narcos@host:~/$perl -MNet::Analysis -e main TCP,v=2 foo.dump@monologues = new monologues("capture.dump"); foreach $monologue (@monologues){ foreach $packet ($monologue){ //print and create stats on header information and payload etc } }
...gives me almost what I want, but I can't figure out how to write a script as opposed to using this command line thing. Sorry if I'm asking silly questions, I'm feeling a bit confused by all of this. I would *greatly* appreciate any help you could give me.
[1] http://www.circlemud.org/~jelson/software/tcpflow/ [2] http://search.cpan.org/~worrall/Net-Analysis/
In reply to TCP session recreation from pcap files by narcos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |