Hello again Michael,
it was your suggestions in the thread called "multifunction
production servers" that encouraged me to get on and sort
this spam thing out.
>> I'd like to know if there is any wrapper for the mail
>> command which simply logs the calling script's name
>
> How would you know it is using the mail command? There are
> several ways to inject mail. One could even use telnet.
I don't, but since our servers are making it so easy for
spammers to use scripts we host, they don't need to bother
with anything clever. Also, if I were to set aside just one
working day to look at only one server, I could find 20+
scripts easily which are actively being exploited by
spammers. So I thought I'd tackle those first.
> I'd start with the obvious:
>
> - which scripts send mail at all?
> - how often is each invoked?
> - how often is local mail generated send from the user apache
> runs as?
I think our hard drives are mounted noatime (since they are
in PIO mode remember) So that is one tool gone for
invokation frequency.
Also some scripts are used once, but with 100-200 cc:/Bcc:
and others are called hundreds of times with one mail
address each time.
If we average and say 50 servers each with 1000 websites,
(some have fewer some have many more) each site COULD
contain .cgi/.pl/.php files which use the mail function.
Nobody knows how many, but a
grep -ri 'mail(' /home/*/public_html/* would give a huge list.
I know -c would count,or |sort|uniq would list them for me,
but we are talking hundreds (on each server).
Currently the drill is something like this:
1) Woah look at the mail queues on server31 !
2) Ah, they're outgoing. List them
3) pick out the hundred or so which were invoked by 99
(nobody/apache)
4) which ones were injected since the last time access_log
was processed and wiped? Oh only 3.. view them for spam like
content..pick one and look at the time it got injected.
5) e.g. grep '13:27:06' access_log
6) buggar! a couple of pages-full, scroll through
7) Ah only 8 are .cgi/.pl/.php the rest are jpeg/gif/html
8) grep these 8 for any mention of the mail function
9) whew! down to 3. View the email and look for clues about
the script itself like:
"Thank you for your interest in our armpit-hair-comb-overs
weekly website.
(E-Mail Removed)".
10) If we find a spam-email-to-script match, we chmod out
the script and try to contact the webmaster. If we can't
find a match, we just have to give up and move onto the
other emails.
My idea of a sendmail wrapper just to log the scripts which
call the mail function would speed up steps 3-8 above.
> I'd hurry up
> before your system is getting blacklisted for being abused as
> spambot.
Too late. many of the outgoing messages stuck in the queue
are perfectly good, genuine emails to real people from real
people, but our IPs have been blacklisted by many agencies
and ISPs and so the next server will not take our mail.
The boss is pushing for an IP migration as soon as we start
in earnest in the new year. I'd like to do what I can to
make sure that the new IP's don't immediately get blacklisted.
> In general I wouldn't recommend to run a public
> webserver on some MTA.
Unfortunately I don't have that kind of freedom.
I've only been a sys-admin for 3 months and my practical
experience with email amounted to configuring Thunderbird.
So far,
i)I have introduced the notion that HELOHOST really ought to
match the servername - That unclogged a lot of the outgoing
queues
ii)introduced magic-smtpd and written the valid user
checking program. So now each server I've implemented it on
deals with much less than 5% of the incoming mail that it
used to.
iii) stopping scripts on our servers being abused by
spammers is just my next project.
None of this is on my official list of priorities so this is
all done at home/evenings/weekends. I just love all this
stuff and am glad to get out of teaching school-kids.
--
Andy Richardson
Never criticize a man 'til you've walked a mile in his shoes.
After that, you can say what you like..
'cos you're a mile away and you've got his shoes.