LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Closed Thread
  Search this Thread
Old 01-19-2007, 10:44 AM   #1
Jefficus
Member
 
Registered: May 2003
Location: Saskatoon
Distribution: Ubuntu 5.04
Posts: 31

Rep: Reputation: 15
Detect outgoing spam


Hi folks. A server I manage recently got hacked. Sadly, they converted my machine into a spam broadcaster. I'm in the process of rebuilding that machine, and researching various security strategies to help me defend against such rape in the future, but that's not what I want help with, yet.

What I want to know is if anybody has a suggestion for some kind of monitoring I can run that will inform me when outbound email exceeds some threshold level. This server sends out a few (maybe 10) notifications of various types to a few addresses each day, so I don't want to shut down email or anything that excessive. But I DEFINITELY want to know when it's suddenly sending out 10000 messages per day. And I want to know FAST. (The fact that my hacked box was spamming for almost a week before I got wind of it is more than a little embarrassing.)

I'm still learning the ropes for tools like tiger and tripwire and I'm sure there are other tools I'll discover as I begin to build my "fortress on the prairie." But I'd really like to have some piece of mind that, if/when the new system fails, I won't commit spamicide for week again before I shut it down.

Any suggestions?

Jefficus
 
Old 01-19-2007, 11:52 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
While I realise you do have a legitimate question, and with all due respect, but IMHO you got your priorities reversed. You should deal with resolving your compromise before doing anything else. Especially finding the *cause* your box got turned into a spam fountain. Spammers by default don't go for root account compromises but go the way of least effort, often this indicates you running stale or deprectated software, or misconfigurations like overly broad permissions or even a crackable ssh. Hardening a box from the ground up takes away much of the chances for abuse giving you plenty of time to get a grip on the relatively lesser important measures to take.
 
Old 01-19-2007, 01:32 PM   #3
Jefficus
Member
 
Registered: May 2003
Location: Saskatoon
Distribution: Ubuntu 5.04
Posts: 31

Original Poster
Rep: Reputation: 15
I agree that hardening the box is the first concern. As I said in my original posting, I am working on that and feel reasonably confident that I can find what I need to make some major improvements.

BUT

I am also not naive enough to think that I will do a perfect job of this, nor that any job, however perfect at one time, will remain perfectly secure.

Consequently, I want a system in place that might give me a hint if/when those failures re-occur.

As I said above, I'm confident I can build a much more secure system this time. The tips and "how tos" for such stuff is a yard deep and a mile wide on the net. What I am NOT finding is a tool that will monitor my success for me in this particular way. I didn't see the point of asking this community to help me with stuff I can already find solutions for.

So my question still stands. Does anybody have any suggestions for how to monitor the mail output of my machine and send a warning if/when that output exceeds a particular threshold?

Jefficus
 
Old 01-19-2007, 06:04 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
0. You can search Freshmeat.net or Sourceforge for a complete system monitoring solution with all bells and whistles and install that.

1. I can generate a script for per hour and daily stats which can be picked up by a Nagios plugin or Monit as say HTTPS as CGI, accessed tru SNMP, output to syslog to have something else pick it up or cronjobbed and made to alert all by itself.
Code:
#!/bin/sh --
hrmax=100; log="/var/log/maillog"; grep=`date '+%b %d'`
cut() { wc -l|awk '{print $1}'; }; hrchk() { [ ${#hr} -eq 1 ] && hr="0${hr}"; }
hrlog() { [ $hrsent -ge $hrmax ] && echo "${grep} ${hr}: ${hrsent}"; }
queue() { echo -n "Mailqueue: "; mailq 2>/dev/null|grep req|awk '{print $3}'; }
case "$1" in --today) for hr in $(seq 00 20); do hrchk; hrsent=`grep "^${grep}.\
${hr}.*stat=Sent$" $log 2>/dev/null|cut`; hrlog; done; queue;; *) hr=`date '+%H'`; 
hrchk; hrsent=`grep "^${grep}.${hr}.*stat=Sent$" $log 2>/dev/null|cut`; hrlog; 
queue;; esac; exit 0
2. I can also take output from an intermediary like SMA, the "SendMail Analyser", grep for "Messages/hour" and script an alert alert for when it exceeds thresh:
Code:
i=`links -dump proto://site/sma.html 2>/dev/null|grep "Messages/h"|awk -F' ' '\
{print $4}'`; [ ${i//.*/} -gt 100 ] && echo 'Alert!'
3. You can pick up outgoing SYN's to remote MTA's with Iptables and choke it with temp rules and alert.

And then I prolly forgot some. Oh well.
 
Old 04-28-2009, 05:39 AM   #5
r.bhange
LQ Newbie
 
Registered: Mar 2009
Posts: 18

Rep: Reputation: 0
Unhappy

Quote:
Originally Posted by unSpawn View Post
0. You can search Freshmeat.net or Sourceforge for a complete system monitoring solution with all bells and whistles and install that.

1. I can generate a script for per hour and daily stats which can be picked up by a Nagios plugin or Monit as say HTTPS as CGI, accessed tru SNMP, output to syslog to have something else pick it up or cronjobbed and made to alert all by itself.
Code:
#!/bin/sh --
hrmax=100; log="/var/log/maillog"; grep=`date '+%b %d'`
cut() { wc -l|awk '{print $1}'; }; hrchk() { [ ${#hr} -eq 1 ] && hr="0${hr}"; }
hrlog() { [ $hrsent -ge $hrmax ] && echo "${grep} ${hr}: ${hrsent}"; }
queue() { echo -n "Mailqueue: "; mailq 2>/dev/null|grep req|awk '{print $3}'; }
case "$1" in --today) for hr in $(seq 00 20); do hrchk; hrsent=`grep "^${grep}.\
${hr}.*stat=Sent$" $log 2>/dev/null|cut`; hrlog; done; queue;; *) hr=`date '+%H'`; 
hrchk; hrsent=`grep "^${grep}.${hr}.*stat=Sent$" $log 2>/dev/null|cut`; hrlog; 
queue;; esac; exit 0
2. I can also take output from an intermediary like SMA, the "SendMail Analyser", grep for "Messages/hour" and script an alert alert for when it exceeds thresh:
Code:
i=`links -dump proto://site/sma.html 2>/dev/null|grep "Messages/h"|awk -F' ' '\
{print $4}'`; [ ${i//.*/} -gt 100 ] && echo 'Alert!'
3. You can pick up outgoing SYN's to remote MTA's with Iptables and choke it with temp rules and alert.

And then I prolly forgot some. Oh well.

Dear Sir,


I am facing same kind of problem, my firewall IP are blacklisted each day i donts cause is outgoing emails are spred spam. I search a lot but yet not got perfect solution over this problem.

If you or any one got solution kindly reply me.

At least give me hint.

thanks

byeeeee
 
Old 04-28-2009, 06:57 AM   #6
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
r.bhange, please start your own thread instead of resurrecting someone else's.

You can always provide a reference to another thread if you need to.
 
  


Closed Thread



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
stop outgoing spam zovres Linux - General 5 04-28-2009 07:16 AM
mailserver- my outgoing mail is spam ? kitek Linux - Newbie 5 04-28-2009 06:53 AM
All my outgoing emails suddenly bounce as spam! ivj Linux - Software 5 05-18-2006 01:22 PM
why is my outgoing mail considered spam to others kitek Linux - Networking 4 04-17-2005 05:31 PM
Stopping outgoing spam dtugg Linux - Software 1 04-04-2005 04:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:50 PM.

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