# *****************************************************************************
#!/bin/perl -w
# Duzan, Tyler Created 10/18/05 Modified 10/18/05
#
# Licensed under the GPL v2 or later, see license.txt or http://gnu.org/ for
# more information.
#
# Simple log analyzer that will compare an array of regex against an Apache log
# file to find any referral spammers that you haven't banned yet, and report
# their IP addresses to you.
#
# Thanks to Kaos Havoc for explaining how to do most of this.
# *****************************************************************************
use warnings;
print ("\n");
#declare my variables
@loglines;
@testlines;
#populate my arrays
open (FILE, "blacklist.txt");
while (<FILE>) {
chomp ($_);
push(@testlines,$_);
}
close (FILE);
open (FILE, "access.log");
while (<FILE>) {
chomp ($_);
push(@loglines,$_);
}
close (FILE);
open (FILE, "output.txt");
#do my comparison
foreach ($loglines (@loglines)) {
foreach ($testlines (@testlines)) {
if ($loglines =~ $testlines) {
print FILE ("$loglines\n");
}
}
}