I manage many clients' firewalls, and regularly generate pcap packet trace files of traffic passing through these firewalls. I do a lot of searching, matching, and extracting of data from these files, and often use Net::TcpDumpLog to automate the process.
I find myself stymied, however, by HTML that has been optimized for download speed through the use of chunked Transfer-Encoding and gzip Content-Encoding. Since the text HTML has been turned into binary data, I can't automate the parsing process and systematically extract interesting information.
Is there a relatively simple way to decompress and decode this data so that it can be manipulated automatically in my program?
Here is what I have so far:
#!/usr/bin/perl use strict; use Net::TcpDumpLog; my $log = Net::TcpDumpLog->new(); $log->read( "/my/tracefile.pcap" ); my $maxindex = $log->maxindex(); my $gzip = 0; foreach my $index ( 0..$maxindex ) { my ( $length_orig, $length_incl, $drops, $seconds, $milliseconds ) + = $log->header( $index ); my $data = $log->data( $index ); if (( $data =~ /Transfer-Encoding: chunked/g ) && ( $data =~ /Co +ntent-Encoding: gzip/g )) { $gzip++; print $index + 1 . "\t$length_orig\t$length_incl\t$seconds\t$m +illiseconds\n"; print "\t$data\n\n"; } } print "$gzip chunked-gzip packets.";
In reply to Extract chunked/gzip data from pcap file by oakb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |