HostOnNet.com Forum Index HostOnNet.com
Private Label Reseller Plan
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Track Spam From PHP and Perl Scripts

 
Post new topic   Reply to topic    HostOnNet.com Forum Index -> Linux Server
View previous topic :: View next topic  
Author Message
admin
Site Admin


Joined: 23 Jan 2003
Posts: 256
Location: India

PostPosted: Fri Sep 09, 2005 6:48 am    Post subject: Track Spam From PHP and Perl Scripts Reply with quote

When you are running PHP and Perl Scripts as user nobody, it is impossible to track scripts that send spam emails. Here is a hack that allow you to track abusers.

Step 1

Login to server and create file for loging

Code:
touch /var/log/sendmail_log
chmod 0777 /var/log/sendmail_log


Step 2

Rename /usr/sbin/sendmail to /usr/sbin/sendmail.hidden

Code:

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


Step 3

create a file /usr/sbin/sendmail

Code:
vi /usr/sbin/sendmail


with Following content

Code:

#!/usr/local/bin/perl

# use strict;
 use Env;
 my $date = `date`;
 chomp $date;
 open (INFO, ">>/var/log/sendmail_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);


Step 4

Make /usr/sbin/sendmail executable by everyone

Code:
chmod +x /usr/sbin/sendmail


Step 5

Prevent overwriting the file /usr/sbin/sendmail

Code:
chattr +i /usr/sbin/sendmail


Step 6

Finished, now you can see the log file at /var/log/sendmail_log

Code:
tail -f /var/log/sendmail_log

_________________
HostOnNet.com - Reseller Hosting
Free Ads Forum, Promote your site
NetFreeHost.com - Free Web Hosting, phpBB Hosting
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    HostOnNet.com Forum Index -> Linux Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


For Support - http://forums.BizHat.com

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!