# ***************************************************************************** #!/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; use strict; print ("\n"); #declare my variables my @loglines; my @testlines; my $logline; my $testline; #populate my arrays open (FILE, "blacklist.txt"); while () { chomp ($_); push(@testlines,$_); } close (FILE); open (FILE, "access.log"); while () { chomp ($_); push(@loglines,$_); } close (FILE); open (FILE, ">>output.txt"); #do my comparison foreach $logline (@loglines) { foreach $testline (@testlines) { if ($logline =~ $testline) { print FILE ("$logline\n"); } } }