/usr/share/logwatch/scripts/services/pix is in logwatch 7.4.1-2.
This file is owned by root:root, with mode 0o755.
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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | #!/usr/bin/perl
##########################################################################
# $Id: pix 150 2013-06-18 22:19:38Z mtremaine $
##########################################################################
# $Log: pix,v $
# Revision 1.4 2008/06/30 23:07:51 kirk
# fixed copyright holders for files where I know who they should be
#
# Revision 1.3 2008/03/24 23:31:26 kirk
# added copyright/license notice to each script
#
# Revision 1.2 2007/02/16 03:30:55 bjorn
# Change to Unix text, without CR/LF, by Ivana Varekova.
#
# Revision 1.1 2006/12/20 04:24:07 bjorn
# New script for cisco pix files, written by Bob Hendry.
#
##########################################################################
#######################################################
## Copyright (c) 2008 Bob Hendry
## Covered under the included MIT/X-Consortium License:
## http://www.opensource.org/licenses/mit-license.php
## All modifications and contributions by other persons to
## this script are assumed to have been donated to the
## Logwatch project and thus assume the above copyright
## and licensing terms. If you want to make contributions
## under your own copyright or a different license this
## must be explicitly stated in the contribution an the
## Logwatch project reserves the right to not accept such
## contributions. If you have made significant
## contributions to this script and want to claim
## copyright please contact logwatch-devel@lists.sourceforge.net.
#########################################################
use Logwatch ':all';
##########################################################################
# Apply date for Cisco PIX
##########################################################################
use POSIX qw(strftime);
use Logwatch ':dates';
$SearchDate = TimeFilter('%b %e %H:%M:%S');
$Debug = $ENV{'LOGWATCH_DEBUG'} || 0;
$Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
if ( $Debug >= 5 ) {
print STDERR "\n\nDEBUG: Inside PIX Filter \n\n";
$DebugCounter = 1;
}
my ($month,$day,$time,$host,$process,$conn,$msg);
while (defined($ThisLine = <STDIN>)) {
if ($ThisLine =~ m/^$SearchDate/o) { # added
if ( $Debug >= 30 ) {
print STDERR "DEBUG($DebugCounter): $ThisLine";
$DebugCounter++;
}
($month,$day,$time,$host,$process,$conn,$msg)=split(/ +/,$ThisLine,7);
if ( ($ThisLine =~ /(ISDN-6-.+)/ ) or
($ThisLine =~ /Copyright/ ) or
($ThisLine =~ /Cisco Internetwork Operating System Software/ ) or
($ThisLine =~ /IOS \(tm\)/ ) or
($ThisLine =~ /TAC:Home:SW:IOS:Specials/ )
) {
# don't care about this, will code this later
}
elsif ( $ThisLine =~ /%PIX-4-106023:/) {
$testline = $ThisLine;
chomp $testline;
$testline =~ s/^.*PIX-4-106023: Deny //;
$testline =~ s/\[0x0, 0x0\]//;
$testline =~ s/"/ /g;
$testline =~ s/by access-group//;
$testline =~ s/[:,]/ /g;
$testline =~ s/\// /g;
@testfields = split(' ',$testline);
$accesslist = @testfields[$#testfields];
$action = "Deny";
$protocol = @testfields[0];
if ($protocol =~ /(tcp|udp)/) {
$source = @testfields[3];
$destination = @testfields[7];
$icmp_type = "";
$count = 1;
$source_ip = @testfields[3];
$source_port = @testfields[4];
$destination_ip = @testfields[7];
$destination_port = @dfields[8];
} elsif ($protocol =~ /icmp/) {
$source = @testfields[3];
$destination = @testfields[7];
$icmp_type = @testfields[8];
$count = 1;
$source_ip = @testfields[3];
$destination_ip = @testfields[7];
} elsif ($protocol =~ /41/) { #IPv6
$source = @testfields[3];
$destination = @testfields[7];
$icmp_type = "";
$count = 1;
$source_ip = @testfields[3];
$source_port = @testfields[4];
$destination_ip = @testfields[7];
$destination_port = @dfields[8];
} else {
$count = 0;
}
$ACL{$accesslist} += $count;
$ACTION{$action} += $count;
$packets += $count;
if ( ($destination_port == 22) and ($protocol =~ /TCP|tcp/) ) {
$SSH{$source_ip} += $count;
$SSH_packets += $count;
}
if ( ($destination_port == 23) and ($protocol =~ /TCP|tcp/) ) {
$TELNET{$source_ip} += $count;
$TELNET_packets += $count;
}
}
elsif ($ThisLine =~ /%PIX-6-106100:/) {
$testline = $ThisLine;
chomp $testline;
$testline =~ s/^.*%PIX-6-106100://;
$testline =~ s/ ->//;
$testline =~ s/[:,]/ /g;
$testline =~ s/\// /g;
$testline =~ s/[()]/ /g;
@testfields = split(' ',$testline);
$accesslist = @testfields[1];
$action = @testfields[2];
$protocol = @testfields[3];
if ($protocol =~ /(TCP|UDP|tcp|udp)/) {
$count = 1;
$source_ip = @testfields[5];
$source_port = @testfields[6];
$destination_ip = @testfields[8];
$destination_port = @testfields[9];
} elsif ($protocol =~ /icmpv6/) {
# not implemented
} else {
$count = 0;
}
$ACL{$accesslist} += $count;
$ACTION{$action} += $count;
$packets += $count;
if ( ($destination_port == 22) and ($protocol =~ /TCP|tcp/) ) {
$SSH{$source_ip} += $count;
$SSH_packets += $count;
}
if ( ($destination_port == 23) and ($protocol =~ /TCP|tcp/) ) {
$TELNET{$source_ip} += $count;
$TELNET_packets += $count;
}
if ( ($destination_port == 21) and ($protocol =~ /TCP|tcp/) ) {
$FTP{$source_ip} += $count;
$FTP_packets += $count;
}
}
#Error Message %PIX|ASA-6-302013
elsif ($ThisLine =~ /%PIX-6-302013: Built/) {
$testline = $ThisLine;
chomp $testline;
$testline =~ s/^.*%PIX-6-302013: Built//;
$testline =~ s/[:,]/ /g;
$testline =~ s/\// /g;
$testline =~ s/[()]/ /g;
@testfields = split(' ',$testline);
$connection_id = @testfields[3];
$CONNECTION_ID{$connection_id} = $connection_id;
}
#Error Message %PIX|ASA-6-302015
elsif ($ThisLine =~ /%PIX-6-302015: Built/) {
$testline = $ThisLine;
chomp $testline;
$testline =~ s/^.*%PIX-6-302015: Built//;
$testline =~ s/[:,]/ /g;
$testline =~ s/\// /g;
$testline =~ s/[()]/ /g;
@testfields = split(' ',$testline);
$connection_id = @testfields[3];
$CONNECTION_ID{$connection_id} = $connection_id;
}
#Error Message %PIX|ASA-6-302014
elsif ($ThisLine =~ /%PIX-6-302014: Teardown/) {
$testline = $ThisLine;
chomp $testline;
$testline =~ s/^.*%PIX-6-302014: Teardown//;
$testline =~ s/[:,]/ /g;
$testline =~ s/\// /g;
$testline =~ s/[()]/ /g;
@testfields = split(' ',$testline);
$protocol = @testfields[0];
$connection_id = @testfields[2];
$count = 1;
$source_ip = @testfields[5];
$source_port = @testfields[6];
$destination_ip = @testfields[11];
$destination_port = @testfields[12];
if ($connection_id == $CONNECTION_ID{$connection_id}) {
if ( ($destination_port == 21) and ($protocol =~ /TCP|tcp/) ) {
$FTP{$source_ip} += $count;
$FTP_packets += $count;
}
if ( ($destination_port == 22) and ($protocol =~ /TCP|tcp/) ) {
$SSH{$source_ip} += $count;
$SSH_packets += $count;
}
if ( ($destination_port == 23) and ($protocol =~ /TCP|tcp/) ) {
$TELNET{$source_ip} += $count;
$TELNET_packets += $count;
}
}
}
#Error Message %PIX|ASA-6-302016
elsif ($ThisLine =~ /%PIX-6-302016: Teardown/) {
$testline = $ThisLine;
chomp $testline;
$testline =~ s/^.*%PIX-6-302016: Teardown//;
$testline =~ s/[:,]/ /g;
$testline =~ s/\// /g;
$testline =~ s/[()]/ /g;
@testfields = split(' ',$testline);
$protocol = @testfields[0];
$connection_id = @testfields[2];
$count = 1;
$source_ip = @testfields[5];
$source_port = @testfields[6];
$destination_ip = @testfields[11];
$destination_port = @testfields[12];
if ($connection_id == $CONNECTION_ID{$connection_id}) {
if ( ($source_port == 53) and ($protocol =~ /UDP|udp/) ) {
$DNS{$source_ip} += $count;
$DNS_packets += $count;
}
if ( ($source_port == 123) and ($protocol =~ /UDP|udp/) ) {
$NTP{$source_ip} += $count;
$NTP_packets += $count;
}
if ( ($source_port == 514) and ($protocol =~ /UDP|udp/) ) {
$SYSLOG{$source_ip} += $count;
$SYSLOG_packets += $count;
}
}
}
elsif ( $ThisLine =~ /%PIX-3-710003:/) {
$testline = $ThisLine;
chomp $testline;
$testline =~ s/^.*%PIX-3-710003://;
$testline =~ s/[:,]/ /g;
$testline =~ s/\// /g;
@testfields = split(' ',$testline);
$accesslist = @testfields[4];
$action = "denied";
$protocol = @testfields[0];
if ($protocol =~ /(TCP|UDP|tcp|udp)/) {
$icmp_type = "";
$count = 1;
$source_ip = @testfields[6];
$source_port = @testfields[7];
$destination_ip = @testfields[10];
$destination_port = @testfields[11];
} elsif ($protocol =~ /icmpv6/) {
$source_ip = @testfields[3];
$source_port = 0;
$destination_ip = @testfields[4];
$destination_port = 0;
$icmp_type = @testfields[5];
$count = @testfields[6];
} else {
$count = 0;
}
$ACL{$accesslist} += $count;
$ACTION{$action} += $count;
$packets += $count;
if ( ($destination_port == 22) and ($protocol =~ /TCP|tcp/) ) {
$SSH{$source_ip} += $count;
$SSH_packets += $count;
}
}#Error Message %PIX|ASA-6-302020
elsif ($ThisLine =~ /%PIX-6-302020: Built ICMP connection for faddr/) {
$testline = $ThisLine;
chomp $testline;
$testline =~ s/^.*%PIX-6-302020: Built ICMP connection for faddr//;
$testline =~ s/[:,]/ /g;
$testline =~ s/\// /g;
$testline =~ s/[()]/ /g;
@testfields = split(' ',$testline);
$connection_id = @testfields[0];
$CONNECTION_ID{$connection_id} = $connection_id;
}
#Error Message %PIX|ASA-6-302021
elsif ($ThisLine =~ /%PIX-6-302021: Teardown ICMP connection for faddr/) {
$testline = $ThisLine;
chomp $testline;
$testline =~ s/^.*%PIX-6-302021: Teardown ICMP connection for faddr//;
$testline =~ s/[:,]/ /g;
$testline =~ s/\// /g;
$testline =~ s/[()]/ /g;
@testfields = split(' ',$testline);
$connection_id = @testfields[0];
$count = 1;
$source_ip = $connection_id;
if ($connection_id == $CONNECTION_ID{$connection_id}) {
$ICMP{$source_ip} += $count;
$ICMP_packets += $count;
}
}
else {
# Report any unmatched entries...
chomp $ThisLine;
$OtherList{$ThisLine}++;
}
}
}
if (keys %ACL) {
print "\nAccess Control Lists:\n";
foreach $ThisOne (sort keys %ACL) {
print " " . $ThisOne . " : " . $ACL{$ThisOne} . " Hit(s)\n";
}
print " Total : " . $packets . " Hit(s)\n";
if ($IPV6_packets >0) {print " IPv6 Total : " . $IPV6_packets . " Hit(s)\n"}
}
if (keys %ACTION) {
print "\nActions:\n";
foreach $ThisOne (sort keys %ACTION) {
print " " . $ThisOne . " : " . $ACTION{$ThisOne} . " Hit(s)\n";
}
print " Total : " . $packets . " Hit(s)\n";
if ($IPV6_packets >0) {print " IPv6 Total : " . $IPV6_packets . " Hit(s)\n"}
}
if (keys %ICMP) {
print "\nICMP Requests:\n";
foreach $ThisOne (sort keys %ICMP) {
print " " . $ThisOne . " : " . $ICMP{$ThisOne} . " Hit(s)\n";
}
print " Total : " . $ICMP_packets . " Hit(s)\n";
}
if (keys %SSH) {
print "\nSSH access:\n";
foreach $ThisOne (sort keys %SSH) {
print " " . $ThisOne . " : " . $SSH{$ThisOne} . " Hit(s)\n";
}
print " Total : " . $SSH_packets . " Hit(s)\n";
}
if (keys %TELNET) {
print "\nTELNET access:\n";
foreach $ThisOne (sort keys %TELNET) {
print " " . $ThisOne . " : " . $TELNET{$ThisOne} . " Hit(s)\n";
}
print " Total : " . $TELNET_packets . " Hit(s)\n";
}
if (keys %FTP) {
print "\nFTP access:\n";
foreach $ThisOne (sort keys %FTP) {
print " " . $ThisOne . " : " . $FTP{$ThisOne} . " Hit(s)\n";
}
print " Total : " . $FTP_packets . " Hit(s)\n";
}
if (keys %DNS) {
print "\nDNS access:\n";
foreach $ThisOne (sort keys %DNS) {
print " " . $ThisOne . " : " . $DNS{$ThisOne} . " Hit(s)\n";
}
print " Total : " . $DNS_packets . " Hit(s)\n";
}
if (keys %NTP) {
print "\nNTP access:\n";
foreach $ThisOne (sort keys %NTP) {
print " " . $ThisOne . " : " . $NTP{$ThisOne} . " Hit(s)\n";
}
print " Total : " . $NTP_packets . " Hit(s)\n";
}
if (keys %SYSLOG) {
print "\nSYSLOG access:\n";
foreach $ThisOne (sort keys %SYSLOG) {
print " " . $ThisOne . " : " . $SYSLOG{$ThisOne} . " Hit(s)\n";
}
print " Total : " . $SYSLOG_packets. " Hit(s)\n";
}
#if (keys %OtherList) {
# print "\n**Unmatched Entries**\n";
# foreach $line (sort {$OtherList{$b}<=>$OtherList{$a} } keys %OtherList) {
# print " $line: $OtherList{$line} Time(s)\n";
# }
#}
exit(0);
# vi: shiftwidth=3 tabstop=3 syntax=perl et
# Local Variables:
# mode: perl
# perl-indent-level: 3
# indent-tabs-mode: nil
# End:
|