Testing Outbound SMTP Connections

Hello All,

We have a server with about 300 domains on it that handles web and mail services using Linux, APACHE, PHP and QMAIL with the PLESK Control Panel. Recently we have found out that one of the domains has a form on it that is being injected and used to send out SPAM. We don't know which on yet and while we are trying to figure that out we have turned off SMTP outbound connections via IPTABLES.

So the question is two fold:

One: Is there a way to make sure or check that all outbound PORT 25 connections are indeed NOT happening. I really want to make sure nothing is leaving the box.

Two: Is there a quick way to determine which domain on our system the spammer is using, or which form was used to inject the email into?


Any help in this matter would be greatly appreciated.
safepointmediaAsked:
Who is Participating?
 
ravenplConnect With a Mentor Commented:
1. iptables -I OUTPUT -p tcp --dport 25 -j REJECT
2. No. Hence there are two approcaches known to me
 - substitute/wrap php's mail() function so it adds server_name and script name to mail headers
 - patch php so it does by itself
0
 
nociConnect With a Mentor Software EngineerCommented:
Ad 1:
You can watch the outgoing line with:
a) snort
b) tcpdump -ni ethX dst port 25
    if this show output, it's stuff leaving the system (but iptables do work..., so it should show nothing.)
If you also forward traffic from another box also insert a forward rule: 'iptables -I FORWARD -p tcp --dport 25 -j REJECT'

Ad 2:
Have you thought about mod_security  http://www.modsecurity.org/,
http://www.securityfocus.com/infocus/1739

it even has an example about Formmail...
http://forums.rochen.com/showthread.php?t=7041

From the default setup:
    # Stop spamming through FormMail
    # note the exclamation mark at the beginning
    # of the filter - only requests that match this regex will
    # be allowed
    <Location /cgi-bin/FormMail>
        SecFilterSelective "ARG_recipient" "!@webkreator.com$"
    </Location>

0
 
safepointmediaAuthor Commented:
Noci,

I do accept inbound traffic to port 25 so tcpdump will show inbound right?

So it should read something like:

15:11:30.399900 IP thereserver.1916 > myserver.smtp: . ack 45 win 64196

Am I reading that right??

Thanks
0
 
nociSoftware EngineerCommented:
Yes, that would be shown too...,

tcpdump -ni ethX dst port 25 and not dst host myserver

would be better.. to exclude that.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.