#!/usr/bin/perl # Routines to make checking for email collection robots easy. # # Chris Seidel November 1998 # Configure variables $email = "you\@yourserver.net"; $notifyme = 1; $righteousness = 998; srand(time|$$); @candidate_list = ( 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789', 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', ); $listlength = 64; @top = ( '.com', '.net', '.edu', '.com', '.org'); # add or edit this email collector robot list at will. @collectors = ('EmailSiphon', 'CherryPicker', 'EmailCollector', 'EmailWolf', 'Extractor'); # not necessary, but makes things less uniform for an extraction robot. @strings = ("Please send me junk email. I love it!", "There are few things I like better than uce. I'm a sucker for spam.", "I'd love to hear from you. Here is my email address. ", "Send me email.", "To contact me: "); sub spamCheck { foreach (@collectors) { if ($ENV{'HTTP_USER_AGENT'} =~ /$_/i ) { ¬ify(); print "Content-type: text/html\n\n"; print "\n"; &spamChoker($righteousness); print ""; exit; } } return; } sub spamChoker { local($howmany) = @_; for( $k=0; $k<$howmany; ++$k ){ $address = &fake_address; print "
$strings[$topper] ";
print "$address";
print "\n";
}
}
sub fake_address {
local($address, $i);
$namel = int rand(7);
$doms = int rand(3);
$topper = int rand(5);
$name = &random_string($namel);
$namel = int rand(7);
$thorax = &random_string($namel);
for( $i=0; $i < $doms; ++$i ){
$namel = int rand(7);
$thorax = $thorax.".".&random_string($namel);
}
$address = $name."@".$thorax.$top[$topper];
return $address;
}
sub random_string {
local($length) = @_;
local($i, $name) = (0,0);
if( !defined($length) ){ $length = 0; }
$name = "";
for($i=0; $i < $length+2; ++$i){
$list = int rand(2);
$char = substr($candidate_list[$list], int rand(64), 1);
$name .= $char;
}
return $name;
}
sub notify {
unless( $notifyme ){
return;
}
$date = localtime;
$from = "Spam Choker";
$to = $email;
$subject = "Spam Choker";
$reply = $email;
$ip = $ENV{'REMOTE_ADDR'};
# who is the scumbag?
@numbers = split(/\./,$ip);
$ip_number = pack("C4", @numbers);
($name) = (gethostbyaddr($ip_number, 2))[0];
if($name) {
$hostname = $name;
} else {
$hostname = "No name available.\n";
}
&SendMail ($to, $from, $reply, $subject);
}
sub SendMail { my ($to, $from, $reply, $subject, $body) = @_;
###########################
#If active, really sends mail. Comment out to feed a phony mail to $debug_output.
$active = 1;
$debug_output = "spam.debug";
###########################
# Path to sendmail and its flags.
#
# sendmail options:
# -n no aliasing
# -t read message for "To:"
# -oi don't terminate message on line containing '.' alone
$sendmail = "/usr/lib/sendmail -t -n -oi";
# fork over the mail to sendmail and be done with it
if ($active == 1) {
open(MAIL,"| $sendmail");
}
else {
open(MAIL, ">>$debug_output");
}
print MAIL <