- 論壇徽章:
- 0
|
因?yàn)楣ぷ餍枰,需要解析pcap包, 我已經(jīng)寫了一部分代碼- #!/usr/bin/perl
- use strict;
- use warnings;
- use Net::Pcap;
- use Net::PcapUtils;
- use NetPacket::Ethernet qw(:strip);
- use NetPacket::IP;
- use NetPacket::TCP;
- my $file = "packet-c.pcap";
- my $err = '';
- my $pcap = Net::Pcap::open_offline($file, \$err) or die "Can't open file...$err\n";
- Net::Pcap::loop($pcap, -1, \&process_pkt, '');
- Net::Pcap::close($pcap);
- sub process_pkt {
- my ($user_data, $header, $packet) = @_;
- # Strip ethernet encapsulation of captured packet
- my $ether_data = NetPacket::Ethernet::strip($packet);
- # Decode contents of TCP/IP packet contained within
- # captured ethernet packet
- my $ip = NetPacket::IP->decode($ether_data);
- my $tcp = NetPacket::TCP->decode($ip->{'data'});
- # Print all out where its coming from and where its
- # going to!
- print
- $ip->{'src_ip'}, ":", $tcp->{'src_port'}, " -> ",
- $ip->{'dest_ip'}, ":", $tcp->{'dest_port'}, "\n",
- "#############################################\n",
- $tcp->{'data'}, "\n",
- "#############################################\n";
- }
復(fù)制代碼 但這個(gè)只能分析出ip,端口之類的。我想得到
$tcp->{'data'}的值,但現(xiàn)在得到的只是加密后的值,有什么辦法可以解析嗎, 謝謝 |
|