#!/usr/local/bin/perl -- -*-fundamental-*- ## Dynapage.pl ## Written by Greg Mullane ## Please see http://www.turnstep.com/Spambot/ ## ## This program changes a web page ever so slightly for ## spambot detection by using dynamic email addresses ## Use at your own risk ## This should be run as a cron job every hour on the hour ## Every day at midnight the name changes ## Otherwise, only the hourly identifier $root = "/home/website"; $log = "$root/spam.log"; ## List of all the pages to be changed: @pages = ( "test.html", "search.html", "welcome.html", ); ## Load all the already used names open(WORDS, "$log") || die "Could not open $log!\n"; while() { /(\d*) ([^ ]*) .*/; push(@allnames, $2); $num=$1; $oldname=$2; } close(WORDS); $num++; ## Do we need to generate a new name? @time = localtime(time); ($sec, $minute, $hour, $date, $month, $year) = @time; if ($hour) { ## i.e. not midnight, so no new name $thisname="$oldname" . $hour; } else { ## Generate random words until we get a match: srand ( time() ^ ($$ + ($$<<15)) ); $letters = int(rand 2) ? 3 : int(rand 2) ? 4 : 2; $found=0; while(!$found) { $newname=""; for $x (1..$letters) { $newname[$x-1] = pack "C", int(rand 26)+97; } $nn = join(/1/, @newname); $found=1; for $a (@allnames) { if($a eq $nn) { $found =0; } } } $thisname = $nn; ## Write it to the log file: ## Write the log file open(LOG, ">>$log") || die "No open $log!\n"; print LOG "$num $thisname $month/$date/$year\n"; close(LOG); } ## end of else ## Now rewrite the files, using $thisname: for $x (@pages) { $a = "$root/$x"; open(OLD, $a) || die; @all=; close(OLD); open(NEW, ">$a") || die; for $a (@all) { $a =~ s/A HREF="mailto:.*\@(.*)/A HREF="mailto:$thisname\@$1/; print NEW $a; } close(NEW); } exit;