I want to tell you this is not a guide for linux protection, is just my experience with linux .
Few tips that let you prevent of hacking system :
Never send server access information (IP, Login, Password) via Email, Skype or other instant message clients. If you need to send the information, divide it into a few parts. For instance, send IP and user name via email and password Ė via Skype.
As far as possible, keep SSH service open for a limited number of IPs.
Never use simple passwords for the server access (like 123123, birth date, words from dictionary). It is very easy to hack such passwords.
Never use a similar password for all servers and services. If one of your servers will be hacked, then hackers will find other servers with the same password.
Never use the same password when registering on different sites. Inexperienced users often use email at Gmail, Yahoo, Hotmail and other services to get register on different sites. They specify password for the email. If the site is hacked, or this site is fraud site, you will lose your password. Remember that hackers will use every password for scanning servers and services.
How to determinate if your server is already hacked :
w or who command doesnít work.
4:25:31 up 121 days, 13:49, 1 user, load average: 0.59, 0.85, 0.63
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
Hackers often removes /var/log/wtmp file so you canít see who works on the PC.
Logs donít work:
/etc/syslog.conf file was replaced.
/etc/passwd and /etc/shadow file are changed Ė check the dates. Check shady accounts. Hackers can open shell access to a bin user and set their own password.
My action when server being hacked :
Close SSH for all IPs except yours one ASAP. Donít change the password, this is useless. New password will immediately be sent to the hackers.
Check crontab. Check change date for cron files
The following process was created on your server in /etc/cron.daily/dnsquery file:
* * * /usr/games/.bash/update >/dev/null 2>&1
Check the following folders:
I found services launched by the hackers in these folders.
Analyze these files. Find out what the hacker launched. On our server, the unclear demon was started:
ps ax|grep slogd
and bash Ė the process found in /usr/games/.bash/bash
Kill all shady processes.
Check the update date of ssh, sshd, sftp-server utilities and /etc/passwd, /etc/shadow files. These dates will help you to specify time of the attack.
Check mail.log. Try to understand if the server sends some emails when you log on using ssh.
Try to update sshd. You can do this with the following command on CentOS:
yum update openssh.
If you canít update, try to download and re-install openssh packages.
yum reinstall openssh-XXXXXX.rpm
Check /etc/passwd and /etc/shadow
On our server, the password was set and the bash was open for bin user:
Change this line to:
um reinstall utils-linux-XXXXX.rpm
Keep in mind that 100% guarantee way to get rid the effects of the hackers attack is reinstall the system. But the above actions will help you to save time and create backups of your files, databases etc.
Most of the hackers sniff the server that is hacked .
If you want you can find the( in and out )logs he took .
Most of the sniffers saving log location is : /usr/share/sshd.sync , /usr/include/gpm2.h , /etc/ssh/.sshd_auth , /usr/include/syslog2.h , /usr/include/ptty.h , /usr/include/netda.h , /usr/include/pwd2.h etc.
If you believe your server is hacked and you don't really get how to fix it i can guide you to do it .
Did you meet the similar problems? Iím waiting for your comments.