LinuxQuestions.org
Review your favorite Linux distribution.
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


Reply
  Search this Thread
Old 07-12-2012, 02:46 PM   #1
crowl
LQ Newbie
 
Registered: Oct 2003
Posts: 25

Rep: Reputation: 0
Server hacked? My mailserver is on a spam-blocklist


spamhaus.org told me that my emails will be blocked because my server is listed on CBL. IP Address MYSERVERIP is listed in the CBL. It appears to be infected with a spam sending trojan or proxy.

I checked all logs but all things seems to be normal.

netstat -nap shows

Code:
Aktive Internetverbindungen (Server und stehende Verbindungen)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      11653/sshd      
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      11779/master    
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      11379/mysqld    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      10164/portmap   
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      5243/apache2    
tcp        0      0 127.0.0.1:949           0.0.0.0:*               LISTEN      11797/famd      
tcp        0      0 MYSERVERIP:50598      98.139.54.60:25         TIME_WAIT   -               
tcp        0      0 MYSERVERIP:22         85.17.30.50:59472       VERBUNDEN   -               
tcp        0      0 127.0.0.1:3306          127.0.0.1:53977         VERBUNDEN   -               
tcp        0      0 127.0.0.1:53977         127.0.0.1:3306          VERBUNDEN   -               
tcp        0      0 127.0.0.1:3306          127.0.0.1:42279         VERBUNDEN   -               
tcp        0      0 MYSERVERIP:22         MYREMOTEIP:52705   VERBUNDEN   -               
tcp        0     52 MYSERVERIP:22         MYREMOTEIP:52408   VERBUNDEN   -               
tcp        0      0 127.0.0.1:42279         127.0.0.1:3306          VERBUNDEN   -               
tcp6       0      0 :::22                   :::*                    LISTEN      11653/sshd      
tcp6       0      0 :::993                  :::*                    LISTEN      11451/couriertcpd
tcp6       0      0 :::995                  :::*                    LISTEN      11478/couriertcpd
tcp6       0      0 :::110                  :::*                    LISTEN      11459/couriertcpd
tcp6       0      0 :::143                  :::*                    LISTEN      11437/couriertcpd
udp        0      0 0.0.0.0:111             0.0.0.0:*                           10164/portmap   
Aktive Sockets in der UNIX-Domäne (Server und stehende Verbindungen)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name    Pfad
unix  14     [ ]         DGRAM                    2134107540 11289/syslogd       /dev/log
unix  2      [ ACC ]     STREAM     HÖRT         2134109444 11779/master        public/cleanup
unix  2      [ ACC ]     STREAM     HÖRT         2134108938 11672/nscd          /var/run/nscd/socket
unix  2      [ ACC ]     STREAM     HÖRT         2134109578 11779/master        public/flush
unix  2      [ ACC ]     STREAM     HÖRT         2134109594 11779/master        public/showq
unix  2      [ ACC ]     STREAM     HÖRT         2134109559 11779/master        private/bounce
unix  2      [ ACC ]     STREAM     HÖRT         2134109566 11779/master        private/defer
unix  2      [ ACC ]     STREAM     HÖRT         2134109570 11779/master        private/trace
unix  2      [ ACC ]     STREAM     HÖRT         2134109574 11779/master        private/verify
unix  2      [ ACC ]     STREAM     HÖRT         2134109582 11779/master        private/proxymap
unix  2      [ ACC ]     STREAM     HÖRT         2134109586 11779/master        private/smtp
unix  2      [ ACC ]     STREAM     HÖRT         2134109590 11779/master        private/relay
unix  2      [ ACC ]     STREAM     HÖRT         2134109598 11779/master        private/error
unix  2      [ ACC ]     STREAM     HÖRT         2134109602 11779/master        private/discard
unix  2      [ ACC ]     STREAM     HÖRT         2134109606 11779/master        private/local
unix  2      [ ACC ]     STREAM     HÖRT         2134109610 11779/master        private/virtual
unix  2      [ ACC ]     STREAM     HÖRT         2134109614 11779/master        private/lmtp
unix  2      [ ACC ]     STREAM     HÖRT         2134109618 11779/master        private/anvil
unix  2      [ ACC ]     STREAM     HÖRT         2134109627 11779/master        private/scache
unix  2      [ ACC ]     STREAM     HÖRT         2134109631 11779/master        private/maildrop
unix  2      [ ACC ]     STREAM     HÖRT         2134109635 11779/master        private/uucp
unix  2      [ ACC ]     STREAM     HÖRT         2134109639 11779/master        private/ifmail
unix  2      [ ACC ]     STREAM     HÖRT         2134109643 11779/master        private/bsmtp
unix  2      [ ACC ]     STREAM     HÖRT         2134109647 11779/master        private/scalemail-backend
unix  2      [ ACC ]     STREAM     HÖRT         2134109651 11779/master        private/mailman
unix  2      [ ACC ]     STREAM     HÖRT         2134109655 11779/master        private/retry
unix  2      [ ACC ]     STREAM     HÖRT         2134107792 11379/mysqld        /var/run/mysqld/mysqld.sock
unix  2      [ ACC ]     STREAM     HÖRT         2134109470 11779/master        private/tlsmgr
unix  2      [ ACC ]     STREAM     HÖRT         2134108042 11426/authdaemond   /var/run/courier/authdaemon/socket.tmp
unix  2      [ ACC ]     STREAM     HÖRT         2134109555 11779/master        private/rewrite
unix  2      [ ]         DGRAM                    3014309005 -                   
unix  2      [ ]         DGRAM                    3014300828 -                   
unix  2      [ ]         DGRAM                    3014203942 -                   
unix  2      [ ]         DGRAM                    2134109665 11810/qmgr          
unix  3      [ ]         STREAM     VERBUNDEN     2134109658 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109657 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109654 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109653 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109650 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109649 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109646 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109645 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109642 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109641 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109638 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109637 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109634 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109633 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109630 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109629 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109626 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109625 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109617 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109616 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109613 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109612 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109609 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109608 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109605 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109604 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109601 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109600 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109597 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109596 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109593 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109592 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109589 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109588 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109585 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109584 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109581 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109580 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109577 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109576 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109573 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109572 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109569 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109568 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109565 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109564 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109558 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109557 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109554 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109553 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109469 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109468 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109466 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109465 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109443 7527/pickup         
unix  3      [ ]         STREAM     VERBUNDEN     2134109442 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109429 11779/master        
unix  3      [ ]         STREAM     VERBUNDEN     2134109428 11779/master        
unix  2      [ ]         DGRAM                    2134109389 11779/master        
unix  2      [ ]         DGRAM                    2134108149 11477/courierlogger 
unix  2      [ ]         DGRAM                    2134108104 11458/courierlogger 
unix  2      [ ]         DGRAM                    2134108085 11450/courierlogger 
unix  2      [ ]         DGRAM                    2134108050 11436/courierlogger 
unix  2      [ ]         DGRAM                    2134108034 11425/courierlogger 
unix  2      [ ]         DGRAM                    2134107789 11380/logger        
unix  2      [ ]         DGRAM                    2134107560 11296/klogd
I am the only one who has access to this server (ssh / ftp), so I do not know who is
tcp 0 0 MYSERVERIP:22 85.17.30.50:59472

So I guess, my server is really hacked. Also the lots of sockets used by 11779/master are not a good sign, are they?

First of all I have add a rule via iptables to drop all port 22 connections and only allow port 22 connections from an ip owned by me.

But how to find the leak? I have checked all mail logs, webserver logs, syslog and can't find any hint for spam sending or irregular connections. Also ps -ef did not show suspicious things. Server updates are up to date.

Any help much appreciated. thx.
 
Old 07-12-2012, 03:00 PM   #2
NyteOwl
Member
 
Registered: Aug 2008
Location: Nova Scotia, Canada
Distribution: Slackware, OpenBSD, others periodically
Posts: 512

Rep: Reputation: 139Reputation: 139
Have you made sure you aren't configures as a public relay? Also note that spamhaus (like most RBL's) has a tendency to include entire IP blocks in their blacklists, if if only 1 ip intnhe block is an actual spammer.
 
Old 07-12-2012, 03:19 PM   #3
crowl
LQ Newbie
 
Registered: Oct 2003
Posts: 25

Original Poster
Rep: Reputation: 0
Thanks NyteOwl for your post. Yes, I have tested from another server via telnet and also run online test at http://www.mailradar.com/openrelay/ with result: All tested completed! No relays accepted by remote host!
 
Old 07-12-2012, 03:34 PM   #4
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
Crowl, you've been a member of LQ for almost a decade, but don't have a lot of post activity. I am not sure how familiar you are with incident investigation process as we perform it here. We use an evidence gathering, fact finding approach based upon the dated CERT intruder detection check list. Here is a link: http://www.scribd.com/doc/6398/Cert-...tion-Checklist While the checklist is dated, it still contains the fundamentals of what you need to look for.

The first step is to contain the system, which you have started to do by raising the firewall. I would suggest that you shut off all traffic except for SSH from your trusted connection. You should not try to operate this server while performing the investigation as it will only hamper your efforts and destroy potential evidence. It is also important to cut the intruder off in one swoop while still keeping processes active that could have important clues as to the nature of the intrusion. Once you have secured the system do not reboot or power down and do not try to 'clean' the system.

Next, please capture a process and network connection output. You can use the following command set as root/sudo:
Code:
(ps acxfwwwe 2>&1; lsof -Pwln 2>&1; netstat -anpe 2>&1; lastlog 2>&1; last 2>&1; who -a 2>&1 ) > /tmp/log.txt
This will create a text file called log.txt in your /tmp directory. Running as root is important because it provides key pieces of process information that helps tie things together.

Second, you will need to continue the examination of your log files. As a start, download a copy of the logwatch tool and run it.
Code:
"logwatch --detail High --service All --range All --archives --numeric --save /path/to/logwatch.log"
Note, that I have seen some variation in this command/utility and depending on your distribution it may not behave quite right in regards to producing the log output. The variation as provided I believe will work on Debian/Ubuntu systems, but on others you will get a listing to stdout that you can redirect to a file with > Again, this should be run as root as some log files are protected.

Third, you will need to make a verification of your binary files. In fact, this really should be done in part before you try to run the command set I listed above. In the interests of saving time, please download known good copies of the binaries, lsof, netstat, and ps, from you distribution repository mirrors and upload these files to the server and use the know copies in the commands.

Please post back as soon as you are able and with any questions.

Followup: you mentioned not knowing the IP address. It is from a hosting company in the Netherlands called lease web (AS number 16265).

Last edited by Noway2; 07-12-2012 at 03:36 PM. Reason: Follow up
 
1 members found this post helpful.
Old 07-13-2012, 02:12 AM   #5
crowl
LQ Newbie
 
Registered: Oct 2003
Posts: 25

Original Poster
Rep: Reputation: 0
@Noway2, thanks for your awesome helpful post. I will do the steps suggested.

Quote:
Crowl, you've been a member of LQ for almost a decade, but don't have a lot of post activity. I am not sure how familiar you are with incident investigation process as we perform it here.
Yeah, I know I am an old man ;-) I am not very familiar with incident investigation since I am more a software engineer than a system admin. I have run several debian server for years - for goods sake - without be compromised (or I did not noticed it).
 
Old 07-13-2012, 04:10 AM   #6
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
Quote:
Originally Posted by crowl View Post
@Noway2, thanks for your awesome helpful post. I will do the steps suggested.
Happy to assist. That is what we are here for.

Quote:
Yeah, I know I am an old man ;-) I am not very familiar with incident investigation since I am more a software engineer than a system admin. I have run several debian server for years - for goods sake - without be compromised (or I did not noticed it).
I too am getting up there, or at least it seems that way sometimes as my parents have even started telling me that I'm getting older instead of telling me I'm young. Compromises can happen to anyone at any time. Here at LQ we've even help catch a few previously unknown exploits. The important thing is to figure out how it happened so you can take steps to prevent it from recurring.

With respect to your situation, a machine sending spam is a fairly common symptom and one that does not require root privilege to execute. Often times you will find a hidden script or process that is responsible, but the bigger question is how did they get it there. In your particular case, the SSH connection is a red warning flag. I am particularly curious about the process tree and connection output which may show a linkeage between the active connection and your symptoms. All of that is a just a guess, so it is extremely important to gather the evidence.

Once you have gathered that information, the next things I would look at are:
1 - what distribution and server processes are you running and what is the revision/patch level of these
2 - look for any hidden files and files with setuid or group id.
3 - look for file modifications, especially if there is evidence or indication of an intrusion date/time
4 - do you run any content management systems, e.g. Drupal, MyAdmin, Plesk, Nagios?

Also do you run any HIDS applications, such as Aide, Ossec, Samhain, etc or monitor your network traffic with Snort?
Given that your SSH may be implicated, what steps had you taken to secure it prior to the intrusion? For example, did you have passwords enabled and/or allow direct root login. Do you use script-avoidance tool like fail2ban?

Again, post if you have any questions or would like help with the analysis.
 
  


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
Help! Mailserver sending out spam highrise Linux - Networking 8 12-04-2011 03:51 PM
mailserver- my outgoing mail is spam ? kitek Linux - Newbie 5 04-28-2009 06:53 AM
qmail - mail server hacked,sending spam - help.. > skate Linux - Server 8 07-29-2008 02:25 AM
MailServer with Mysql and spam Bberglund Linux - Software 3 10-04-2004 06:16 PM
Red Hat 6.22 Mailserver hacked : Help. markng Linux - Security 7 05-06-2002 12:52 AM

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

All times are GMT -5. The time now is 03:35 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