开发者

How do I reassemble HTTP packets from Net::Pcap?

开发者 https://www.devze.com 2023-02-05 11:55 出处:网络
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:

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:

开发者_Python百科
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

0

精彩评论

暂无评论...
验证码 换一张
取 消