/usr/share/perl5/Lire/Firewall/IpchainsDlfConverter.pm is in lire 2:2.1.1-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | package Lire::Firewall::IpchainsDlfConverter;
use strict;
use Lire::DlfConverter;
use Lire::Firewall qw/firewall_number2names/;
use Lire::Syslog;
use Carp;
use base qw/Lire::DlfConverter/;
my %action2cisco = (
'DENY' => 'denied',
'REJECT' => 'denied',
'ACCEPT' => 'permitted'
);
my @chain_fields = qw/rule action rcv_intf protocol from_ip from_port
to_ip to_port length tos seq_no fragment ttl/;
sub new {
my $proto = shift;
bless {}, (ref $proto || $proto);
}
sub name { 'ipchains' }
sub title { 'IPchains firewall log' }
sub description { '<para>IPchains firewall log</para>' }
sub schemas { qw/firewall/ }
sub handle_log_lines { 1 }
sub init_dlf_converter {
my ($self, $process) = @_;
$self->{'parser'} = new Lire::Syslog;
}
sub process_log_line {
my ($self, $process, $line) = @_;
#
# skip invalid log entries before parsing
#
return $process->ignore_log_line($line)
unless $line =~ /Packet log: /;
eval {
my $log = $self->{'parser'}->parse($line);
local $_ = $log->{'content'};
#
# skip invalid log entries
#
return $process->ignore_log_line($line)
unless /^Packet log: /;
my @chain_infos =
$log->{'content'} =~ /^Packet\slog:\s
([-\w]+)\s # chain
(\w+)\s # action
(\w+)\s # interface
PROTO=(\d+)\s # protocol
(\d+\.\d+\.\d+\.\d+):(\d+)\s # from
(\d+\.\d+\.\d+\.\d+):(\d+)\s # to
L=(\d+)\s # length
S=(0x[0-9A-Fa-z]+)\s # TOS
I=(\d+)\s # Sequence number
F=(0x[0-9A-Fa-z]+)\s # Fragment offset
T=(\d+)\s # TTL
(.*)$/x # Other stuff
or die "ipchains lexer failed\n";
#
# assign log values to hash
#
my %dlf = (
'time' => $log->{'timestamp'},
'count' => 1,
);
my $i = 0;
foreach my $f (@chain_fields) {
$dlf{$f} = $chain_infos[$i++];
}
if(exists $action2cisco{$dlf{'action'}}) {
$dlf{'action'} = $action2cisco{$dlf{'action'}};
}
#
# convert numbers to names and create dlf-record
#
firewall_number2names(\%dlf);
$process->write_dlf('firewall', \%dlf);
};
if($@) {
$process->error($line, $@);
}
}
sub finish_conversion {
delete $_[0]->{'parser'};
}
1; # nag nag.
__END__
=pod
=head1 NAME
Lire::Firewall::IpchainsDlfConverter - convert Ipchains logs to firewall DLF
=head1 DESCRIPTION
B<Lire::Firewall::IpchainsDlfConverter> converts Ipchains logs into
firewall DLF format.
Input for this converter is the standard IPchains syslog log file.
=head1 AUTHOR
Francis J. Lacoste <flacoste@logreport.org>,
Wessel Dankers <wsl@logreport.org>
=head1 VERSION
$Id: IpchainsDlfConverter.pm,v 1.10 2006/07/23 13:16:35 vanbaal Exp $
=head1 COPYRIGHT
Copyright (C) 2001-2003 Stichting LogReport Foundation LogReport@LogReport.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html.
=cut
# Local Variables:
# mode: cperl
# End:
|