You have been trying to be sneaky and not have any obvious virus scan running in the process list so as to not be detected, but that is tedious work and slow. Once you get a look at what is going on you can bring out the heavy duty security power tools to make your job easier. If the server load is not too high the next thing I like to do is update the locate database in the background. Many will use complicated find commands which is fine, but I want to know if the locate function is working properly or if it is being fooled into reporting false information. Let this run in the background as you do some other searches.
Update the Locate Database:
root:~#updatedb &
If this is a web server then the next thing to hunt for is signs of Apache exploits and SQL injection scripts. This nice little script was handed down to me from a co-worker and does a nice job of hunting through the log files rather than the long tedious work of searching manually.
Search for Apache Exploit
for i in `locate access_log` ; do echo $i ; egrep -i '(chr(|system()|(curl|wget|chmod|gcc|perl)%20' $i ; done
or
egrep -i '(chr(|system()|(curl|wget|chmod|gcc|perl)%20' /path/to/log/files/*
cPanel
egrep -i '(chr(|system()|(curl|wget|chmod|gcc|perl)%20' /usr/local/apache/logs/*
Ensim
egrep -i '(chr(|system()|(curl|wget|chmod|gcc|perl)%20'/home/virtual/site*/fst/var/log/httpd/*
Plesk
egrep -i '(chr(|system()|(curl|wget|chmod|gcc|perl)%20' /home/httpd/vhosts/*/statistics/logs/*
egrep -i '(chr(|system()|(curl|wget|chmod|gcc|perl)%20' /var/log/httpd/*
Of course not every thing that it locates is an exploit, it takes some interpreting. You are looking for obvious things such as a call to wget to download a file, or a call to perl that looks strangely out of place. However one thing this script does not search for is a call to shell code. Once you locate the access logs run a second search for long strings containing /x90/. I have yet to find a good interpreter of what these shell codes do but again google.com is your friend. Most often you can do a search for the code itself and come up with a technical explanation of what the code does.
Search for Shell Code:
cat /path/to/access/logs/* |grep "/x90/"
Finally now you can run your favorite virus scan and root kit hunter. Some favorites include rkhunter and chkrootkit.
ChkRootkit
http://www.chkrootkit.org
RKHunter
http://www.rootkit.nl
Hopefully by now the updatedb has finished, you can check the status of that by usingthe jobs command. Look for things that are out of place and dont belong, are there .bash_history or access_log files that seem to be in the wrong area. This is where you try to think like a hacker and try to find the strange things that just don’t seem right.
Think Like a Hacker in Your Search
root:~#locate .bash_history
root:~#locate access_log
root:~#locate "..."
root:~#locate ".. "
root:~#locate " .."
root:~#locate ". "
root:~#locate " ."
Again when you find some thing take the same care in cataloging every thing you can. If you have some strange TCP port listening try using telnet to access it and see what comes up. Only after you have cataloged as much as possible then you can start deleting every thing and start locking down the server.
By now you might have some user accounts and possibly some IP addresses and an idea of how they got into the server, what is the best way of handling this is a legal suitable manner. You could try contacting the owner of the server that the attack originated from, but that might open a whole new can of leagal worms. The best way is to instead contact the data center that operates the IP address and pass along the log files and other data you have gathered about the attack. You most likely wont hear back from them as they have their own policies but more often than not they are handling it. Untill they do some thing about it then firewall that IP address so they cannot access your server.
Who Ownes the IP Address
root:~#whois 12.34.56.78
Gather all Data About the IP Address
root:~#for i in `ls /var/log -la |grep -v drwx |grep -v lrwx | awk '{print $9}'`; do echo /var/log/$i; cat /var/log/$i |grep "12.34.56.78 ; done