Rev 5 |
|
Rev 6 |
Line 12... |
|
Line 12... |
my %args=@_; |
|
my %args=@_; |
|
|
|
my $IPTABLES=$args{IPTABLES}; |
|
my $IPTABLES=$args{IPTABLES}; |
|
|
|
if ( (! -e "acct_int.dat") || (! -e "acct_ext.dat")) { |
|
if ( (! -e "acct_int.dat") || (! -e "acct_ext.dat")) { |
system("$IPTABLES -L acct_int_tcp -xvn > acct_int.dat"); |
|
system("$IPTABLES -L acct_int_other -xvn > acct_int.dat"); |
system("$IPTABLES -L acct_ext_tcp -xvn > acct_ext.dat"); |
|
system("$IPTABLES -L acct_ext_other -xvn > acct_ext.dat"); |
foreach $prt ("udp","icmp","all") { |
|
foreach $prt ("tcp","udp") { |
|
|
system("$IPTABLES -L acct_int_$prt -xvn | sed 's/all/$prt/g' >> acct_int.dat"); |
|
|
system("$IPTABLES -L acct_ext_$prt -xvn | sed 's/all/$prt/g' >> acct_ext.dat"); |
system("$IPTABLES -L acct_int_$prt -xvn >> acct_int.dat"); |
|
system("$IPTABLES -L acct_int_$prt -xvn >> acct_int.dat"); |
system("$IPTABLES -L acct_ext_$prt -xvn >> acct_ext.dat"); |
|
system("$IPTABLES -L acct_ext_$prt -xvn >> acct_ext.dat"); |
} |
|
} |
} |
|
} |
|
|
|
my %acct_int_old=readfile("acct_int.dat",$IPTABLES); |
|
my %acct_int_old=readfile("acct_int.dat",$IPTABLES); |
my %acct_ext_old=readfile("acct_ext.dat",$IPTABLES); |
|
my %acct_ext_old=readfile("acct_ext.dat",$IPTABLES); |
system("$IPTABLES -L acct_int_all -xvn > acct_int.dat"); |
|
system("$IPTABLES -L acct_int_other -xvn > acct_int.dat"); |
system("$IPTABLES -L acct_ext_all -xvn > acct_ext.dat"); |
|
system("$IPTABLES -L acct_ext_other -xvn > acct_ext.dat"); |
foreach $prt ("udp","icmp","tcp") { |
|
foreach $prt ("tcp","udp") { |
system("$IPTABLES -L acct_int_$prt -xvn | sed 's/all/$prt/g' >> acct_int.dat"); |
|
system("$IPTABLES -L acct_int_$prt -xvn | sed 's/all/$prt/g' >> acct_int.dat"); |
system("$IPTABLES -L acct_ext_$prt -xvn | sed 's/all/$prt/g' >> acct_ext.dat"); |
|
system("$IPTABLES -L acct_ext_$prt -xvn | sed 's/all/$prt/g' >> acct_ext.dat"); |
} |
|
} |
my %acct_int=readfile("acct_int.dat",$IPTABLES); |
|
my %acct_int=readfile("acct_int.dat",$IPTABLES); |
my %acct_ext=readfile("acct_ext.dat",$IPTABLES); |
|
my %acct_ext=readfile("acct_ext.dat",$IPTABLES); |
|
|
|
my $time=time; |
|
my $time=time; |
|
|
|
foreach my $nn (sort(keys(%acct_int))) { |
|
foreach my $nn (sort(keys(%acct_int))) { |
$allin=$acct_int{$nn}[1]-$acct_int_old{$nn}[1]; |
|
$otherin=$acct_int{$nn}[1]-$acct_int_old{$nn}[1]; |
$tcpin=$acct_int{$nn}[3]-$acct_int_old{$nn}[3]; |
|
$tcpin=$acct_int{$nn}[3]-$acct_int_old{$nn}[3]; |
$udpin=$acct_int{$nn}[5]-$acct_int_old{$nn}[5]; |
|
$udpin=$acct_int{$nn}[5]-$acct_int_old{$nn}[5]; |
$icmpin=$acct_int{$nn}[7]-$acct_int_old{$nn}[7]; |
|
$icmpin=$acct_int{$nn}[7]-$acct_int_old{$nn}[7]; |
$allout=$acct_int{$nn}[2]-$acct_int_old{$nn}[2]; |
|
$otherout=$acct_int{$nn}[2]-$acct_int_old{$nn}[2]; |
$tcpout=$acct_int{$nn}[4]-$acct_int_old{$nn}[4]; |
|
$tcpout=$acct_int{$nn}[4]-$acct_int_old{$nn}[4]; |
$udpout=$acct_int{$nn}[6]-$acct_int_old{$nn}[6]; |
|
$udpout=$acct_int{$nn}[6]-$acct_int_old{$nn}[6]; |
$icmpout=$acct_int{$nn}[8]-$acct_int_old{$nn}[8]; |
|
$icmpout=$acct_int{$nn}[8]-$acct_int_old{$nn}[8]; |
updatedb($args{MODNAME},$time,"int$nn",$tcpin,$udpin,$icmpin,$tcpout,$udpout,$icmpout); |
|
updatedb($args{MODNAME},$time,"int$nn",$tcpin,$udpin,$otherin,$tcpout,$udpout,$otherout); |
} |
|
} |
|
|
|
foreach my $nn (sort(keys(%acct_ext))) { |
|
foreach my $nn (sort(keys(%acct_ext))) { |
$allin=$acct_ext{$nn}[1]-$acct_ext_old{$nn}[1]; |
|
$otherin=$acct_ext{$nn}[1]-$acct_ext_old{$nn}[1]; |
$tcpin=$acct_ext{$nn}[3]-$acct_ext_old{$nn}[3]; |
|
$tcpin=$acct_ext{$nn}[3]-$acct_ext_old{$nn}[3]; |
$udpin=$acct_ext{$nn}[5]-$acct_ext_old{$nn}[5]; |
|
$udpin=$acct_ext{$nn}[5]-$acct_ext_old{$nn}[5]; |
$icmpin=$acct_ext{$nn}[7]-$acct_ext_old{$nn}[7]; |
|
$icmpin=$acct_ext{$nn}[7]-$acct_ext_old{$nn}[7]; |
$allout=$acct_ext{$nn}[2]-$acct_ext_old{$nn}[2]; |
|
$otherout=$acct_ext{$nn}[2]-$acct_ext_old{$nn}[2]; |
$tcpout=$acct_ext{$nn}[4]-$acct_ext_old{$nn}[4]; |
|
$tcpout=$acct_ext{$nn}[4]-$acct_ext_old{$nn}[4]; |
$udpout=$acct_ext{$nn}[6]-$acct_ext_old{$nn}[6]; |
|
$udpout=$acct_ext{$nn}[6]-$acct_ext_old{$nn}[6]; |
$icmpout=$acct_ext{$nn}[8]-$acct_ext_old{$nn}[8]; |
|
$icmpout=$acct_ext{$nn}[8]-$acct_ext_old{$nn}[8]; |
updatedb($args{MODNAME},$time,"ext$nn",$tcpin,$udpin,$icmpin,$tcpout,$udpout,$icmpout); |
|
updatedb($args{MODNAME},$time,"ext$nn",$tcpin,$udpin,$otherin,$tcpout,$udpout,$otherout); |
} |
|
} |
} |
|
} |
|
|
|
sub readfile { |
|
sub readfile { |
my ($file,$IPTABLES)=@_; |
|
my ($file,$IPTABLES)=@_; |