LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-11-2007, 06:06 PM   #1
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Rep: Reputation: 30
Sendmail wrapper to detected spammer (which domain is using PHP's mail function?


Hi,

I have the following two scripts but neither of them work. What I am trying to find out is which domain is having vulnerable php code exploited to send spam.
But ideally I would like to find out whatever domain is sending out mail, the maillog itself shows where mail is going to and coming from but not which script on which domain sent it.

Sometimes I can trace the process and find out an X-mailer in the mail header but not all the time. Just says send by the Apache UID so certainly a website that's doing it.

Here are the scripts for your reference.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~BEGIN~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/perl

# use strict;
use Env;
my $date = `date`;
chomp $date;
open(INFO, ">>/var/log/formmail.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 - @info\n";
}
my $mailprog='/var/qmail/bin/sendmail.real';
foreach (@ARGV){
$arg="$arg" . "$_" . " " ;
}

print("sendmail arguments:\n");
print("$arg\n");


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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~END~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


And another one.


#!/bin/sh
(echo X-Additional-Header: $(basename $(dirname $PWD));cat)|tee -a
/var/tmp/mail.send|/var/qmail/bin/sendmail-qmail "$@"



Any help with this would be appreciated, please note that I am not a coder.

Thanks.
 
Old 02-12-2007, 12:13 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
You might want to look at the httpd access logs (I think the default location is /var/log/httpd/). For each virtual that I have web site you can create a separate log file, Apache directive (CustomLog logs/dummy-host.example.com-access_log common in the VirtualHost directive). It might then be a case of looking which one has excessive access and from there locate the script in question.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problems with From : header when sending emails with function mail() from my domain mavgh1 Linux - Software 0 03-24-2006 07:51 PM
md5, SHA and php's mcrypt function rjcrews General 1 12-05-2005 12:54 AM
ruby equivalent of PHP's print_r(); function?? opioid Programming 1 04-08-2005 01:23 PM
sendmail and PHP's mail() issues Magsol Linux - General 5 03-26-2005 03:15 PM
PHP's imagecreatefromPNG function Tomasfuego Linux - Software 0 06-20-2003 12:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration