#!/usr/bin/perl -w use strict; # Set variables my $today=`date +%d%b%y`; chomp($today); my $reportfile = "/exported/analysis/$today.logsum"; my $topten = 0; my $logfile = "/exported/$today.elog"; my @ips; my $from_addr="Root"; my $to_addr="IS Security){ chomp; $topten = 1 if m!^Users/Source Addresses!; next unless $topten; push @ips, [split /\s+/] if /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/; } close REPORT; # Pull out the first ip address and assign it to the variable $ip my $ip1 = qr/\b$ips[0][0]\b/o; my @fwlog1; # Open up the firewall log file and match the ip address and store the results into the array @fwlog1 open LOG, "$logfile" or die "Can't open $logfile: $!\n"; while (){ if ($_ =~ $ip1){ push (@fwlog1, $_); } #end if } #end while close LOG; # Splice the array @fwlog1 and take only the first 15 entries to be included in the email as "evidence" # Also substitute any firewall ip addresses for x's for add protection splice(@fwlog1, 15); foreach (@fwlog1){ s/192\.168\.13\.2/x.x.x.x/; s/192\.168\.2\.2/x.x.x.x/; s/192\.168\.214\.46/x.x.x.x/; s/192\.168\.148\.2/x.x.x.x/; } # Open sendmail and send Flagged Activity email to the Security Team for review. open(SENDMAIL, "|/usr/lib/sendmail -oi -t") or die "Can't fork for sendmail: $!\n"; print SENDMAIL <