#!/usr/bin/perl -w #-*-perl-*- # use Date::Manip; use LWP::UserAgent; use Net::DNS; use Net::SMTP; my $file = ""; if ($ARGV[0]) { $file = $ARGV[0]; } else { print "You must provide a data file\n"; exit(1); } open (FILE, $file) || die "Can't open file $file"; open (LOG, ">>./orb.log") || die "Can't open file ./orb.log"; while() { chomp; mailNotice($_, "root", LOG); mailNotice($_, "postmaster", LOG); mailNotice($_, "webmaster", LOG); mailNotice($_, "abuse", LOG); mailNotice($_, "admin", LOG); mailNotice($_, "administrator", LOG); } close(LOG); close(FILE); sub mailNotice { my($ServerName, $ToPrefix) = @_; my $MailFrom = ""; my $MailTo = ""; print STDERR "$ServerName\n"; # Connect to the server $smtp = Net::SMTP->new($ServerName, Timeout => 5); return unless $smtp; $MailFrom = "$ToPrefix\@$ServerName"; $MailTo = $MailFrom; print STDERR " trying $ToPrefix\@$ServerName\n"; $smtp->mail( $MailFrom ); $smtp->to( $MailTo ); # Start the mail $smtp->data(); # Send the header. $smtp->datasend("To: $MailTo\n"); $smtp->datasend("From: $MailFrom\n"); $smtp->datasend("Subject: Abuse: Your email server is an open relay\n"); $smtp->datasend("\n"); # Send the message $smtp->datasend("Currently, your email server is configured as an \n"); $smtp->datasend("open relay and is being used to send Unsolicited \n"); $smtp->datasend("Commercial Email (UCE, aka spam). Please take the \n"); $smtp->datasend("appropriate action to correct this problem.\n"); $smtp->datasend("\n"); $smtp->datasend("For more information:\n"); $smtp->datasend("http://www.cauce.org/\n"); $smtp->datasend("\n\n"); # Send the termination string $smtp->dataend(); $smtp->quit(); my $timestamp = UnixDate("today","%b %d %T"); print LOG "$timestamp $ServerName $ToPrefix\@$ServerName\n"; }