Disable mod_security2 for a single domain in cPanel

Mod_security is an open source Apache module. This can be considered as firewall for web applications. It secures the system from the attackers. We use mod_security1 for Apache1.x and Apache 2.x uses mod_security2. In case of mod_security1, we can disable it for a domain using the .htaccess file.
If you want to disable mod_sec for one domain then add the following Line in .htaccess
—————–
SecFilterEngine Off
——————
However, we can’t block mod_security2 via .htaccess on domain basis.
The following steps can be used to disable mod_security2 rule for one domain in cPanel servers.
1. Make the directory “/usr/local/apache/conf/userdata/std/2/username/domain.com”
2. Create a file “vhost.conf” in the above location
3. Add the following lines :
———-
<IfModule mod_security2.c>
SecRuleEngine Off
</IfModule>
———-
To disable mod_secuirty for a particular location :
———
<LocationMatch specify_the_path_here>
<IfModule mod_security2.c>
SecRuleEngine Off
</IfModule>
</LocationMatch>
———
To disable a particular mod_secuirty rule :
———
<IfModule mod_security2.c>
SecRuleRemoveById give_ruleID_here
</IfModule>
———
Please make sure run the following script after making the changes.
———
/scripts/ensure_vhost_includes –user=username
———
This script will uncomment the following line in apache configuration. It will customise the virtual host to use the particular include file and will restart apache.
———–
Include “/usr/local/apache/conf/userdata/std/2/username/domain.com/*.conf”
———–

Command to kill tcp connections to FTP port 21

kill -9 $( lsof -i:21 -t)

Update root password of mysql server

service mysqld stop
mysqld_safe --skip-grant-tables &
use mysql
UPDATE mysql.user SET password=PASSWORD('newpass') WHERE user='root';
FLUSH PRIVILEGES;
quit
/sbin/service mysqld start
mysql -uroot -p

Script to list files not owned by a specific cPanel user

find /home/prasanth \! -user prasanth -exec echo "{}" \;

Here prasanth is the cPanel username

PTR record online lookup tool

http://www.simpledns.com/lookup-dg.aspx

Steps to rename wordpress wp-login.php file

1. Find and replace the text “wp-login.php” on /wp-login.php file with “hidden-login.php”
2. Find and replace the text “wp-login.php” on /wp-includes/general-template.php file with “hidden-login.php” except this line on wp_login_url function, like :
    $login_url = site_url('wp-login.php', 'login'); for new version, or
    return site_url("wp-login.php$redirect",'login'); for old version
    just let it be the way it is, otherwise when you go to wp-admin, it will redirect to “hidden-login.php”
3. Rename /wp-login.php file into hidden-login.php

Reference: http://crazydavinci.net/2010/11/secure-wordpress-login/

How to find a spamming script?

You can use the below scripts to find out the php script used for spamming

find /home/xyz/ -name '*.php'|xargs grep -w "mail("

This will search for any PHP files containing the mail() function. From there, you can get an idea of which scripts are sending emails out.

If there is on going spamming via a php script issue below command to find the running scripts at the moment

watch 'ps -ef| grep php'