How do I reassemble HTTP packets from Net::Pcap?
I am using the Net::Pcap
module to capture packets with this filter:
dst $my_host and dst port 80
Inside the Net::Pcap event loop I use a callback function:
Net::Pcap::pcap_loop($pcap_t, -1, \my_callback, '')
where my_callback
look like this:
my_callback {
my ($user_data, $header, $packet) = @_;
# Strip ethernet IP and TCP
my $ether_data = NetPacket::Ethernet::strip($packet);
my $ip = NetPacket::IP->decode($ether_data);
my $tcp = NetPacket::TCP->decode($ip->{'data'});
}
How can I assemble the HTTP packets into one packet and extract its header?
try to use Sniffer::HTTP from CPAN
精彩评论