Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to catch nobody spammers?  (Read 4203 times)

0 Members and 1 Guest are viewing this topic.

nirmal

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
How to catch nobody spammers?
« on: November 17, 2013, 12:46:26 pm »
Hi all,

How to catch nobody spammers?

Step 1) Turn off exim before proceeding
/etc/init.d/exim stop

Step 2) Backup your original /usr/sbin/sendmail file

mv /usr/sbin/sendmail /usr/sbin/sendmail.hidden

Step 3) Create the spam monitoring script for the new sendmail
vi /usr/sbin/sendmail

Paste in the following:

#!/usr/local/bin/perl

# use strict;
 use Env;
 my $date = `date`;
 chomp $date;
 open (INFO, ">>/var/log/spam_log") || die "Failed to open file ::$!";
 my $uid = $>;
 my @info = getpwuid($uid);
 if($REMOTE_ADDR) {
         print INFO "$date - $REMOTE_ADDR ran $SCRIPT_NAME at $SERVER_NAME n";
 }
 else {

        print INFO "$date - $PWD -  @infon";

 }
 my $mailprog = '/usr/sbin/sendmail.hidden';
 foreach  (@ARGV) {
         $arg="$arg" . " $_";
 }

 open (MAIL,"|$mailprog $arg") || die "cannot open $mailprog: $!n";
 while (<STDIN> ) {
         print MAIL;
 }
 close (INFO);
 close (MAIL);

Change the new sendmail permissions
chmod +x /usr/sbin/sendmail


Create a new log file to keep a history of all mail going out of the server using web scripts
touch /var/log/spam_log
chmod 0777 /var/log/spam_log

Start Exim
/etc/init.d/exim start

Monitor your spam_log file for spam
tail -f /var/log/spam_log
Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!