I created this plugin because I am tired of having my Wordpress sites being hacked. It is used to completely lock the filesystem with the help of a bash script. The said script is external from the website and ran via cron so you need cron access to make this work. Otherwise, this plugin is useless to you.
This plugin has a known bug. See FAQs.
- Upload the plugin files to the
/wp-content/plugins/filesystem-unlocker
directory, or install the plugin through the WordPress plugins screen directly.
- Activate the plugin through the 'Plugins' screen in WordPress
- Use the left menu Filesystem Unlocker to configure the plugin (this has to be done before configuring and cron'ing scripts)
- You need to put the folowing script somewhere on your filesystem, elsewhere then in the webserver's directory. It needs to be run with the webserver's privileges or a higher privilege that can chmod files in the webserver's directory.
- Edit the script to match your users, passwords, database prefixes, paths and the like.
- Minimaly, cron a job that runs this script every minute of everyday
- Ideally, cron this job to run only when you are EFFECTIVELY playing in your ftp. You are sleeping from 10pm to 6am ? Then don't run the script. It won't unlock your filesystem if it's not ran. But then, you need an additionnal script to be ran the minute after you go to sleep to ensure the ftp is locked in the scenario where there was "time left in the parking meter" when your cron stop to execute.
The script in step 4 goes as follows:
#!/bin/bash
####################################################################################################
# You NEED to edit the folowing strings #
####################################################################################################
# #
# -uuser : -uYourMySQLUser... ex.: -umarc #
# -ppassword : -pYourUserSPassword... ex.: -pabracadabra #
# MySQLDatabaseName : Your MySQL database name... ex.: datab1f32 #
# wpTablePrefix__ : Your wordpress installation table prefixes... ex.: wp_prefix123__ #
# /path/to/public_html : the path to your webserver's root document... ex.: /home/user/public_html #
# #
####################################################################################################
####################################################################################################
# Note on the choice of the path to be locked... #
####################################################################################################
# #
# The above mention of /path/to/public_html may or may not be accurate in the case your Wordpress #
# installation is not at the root of your webserver's tree. But take into account I suggest you #
# lock your WHOLE filesystem because if you choose to lock only your Wordpress's files, any hacker #
# being "ethical" as they are, will write outside of your "locked zone" and exploit your webserver.#
# Thus, I STRONGLY suggest you lock your WHOLE filesystem. #
# #
# Should you choose otherwise, you could adapt the above #
# /path/to/public_html #
# with #
# /path/to/public_html/wordpress/install/path #
# #
####################################################################################################
timetolock=$(mysql -uuser -ppassword -se "select option_value from MySQLDatabaseName.wpTablePrefix__options where option_name='filesystem_unlocker_plugin_options'");
isitlockedalready=$(mysql -uuser -ppassword -se "select option_value from MySQLDatabaseName.wpTablePrefix__options where option_name='filesystem_unlocker_plugin_lock_state'");
if [ $timetolock -gt 0 ] && [ $isitlockedalready -eq 1 ]
then
find /path/to/public_html -type d -exec chmod 755 {} \; && find /path/to/public_html -type f -exec chmod 644 {} \;
mysql -uuser -ppassword -se "update MySQLDatabaseName.wpTablePrefix__options set option_value = 0 where option_name='filesystem_unlocker_plugin_lock_state'";
fi
if [ $timetolock -eq 0 ] && [ $isitlockedalready -eq 0 ]
then
find /path/to/public_html -type d -exec chmod 555 {} \; && find /path/to/public_html -type f -exec chmod 444 {} \;
mysql -uuser -ppassword -se "update MySQLDatabaseName.wpTablePrefix__options set option_value = 1 where option_name='filesystem_unlocker_plugin_lock_state'";
fi
if [ $timetolock -gt 0 ] && [ $isitlockedalready -eq 0 ]
then
mysql -uuser -ppassword -se "update MySQLDatabaseName.wpTablePrefix__options set option_value = option_value-1 where option_name='filesystem_unlocker_plugin_options'";
fi
The optional script in step 7 goes as follows:
#!/bin/bash
####################################################################################################
# You NEED to edit the folowing strings #
####################################################################################################
# #
# -uuser : -uYourMySQLUser... ex.: -umarc #
# -ppassword : -pYourUserSPassword... ex.: -pabracadabra #
# MySQLDatabaseName : Your MySQL database name... ex.: datab1f32 #
# wpTablePrefix__ : Your wordpress installation table prefixes... ex.: wp_prefix123__ #
# /path/to/public_html : the path to your webserver's root document... ex.: /home/user/public_html #
# #
####################################################################################################
####################################################################################################
# Note on the choice of the path to be locked... #
####################################################################################################
# #
# The above mention of /path/to/public_html may or may not be accurate in the case your Wordpress #
# installation is not at the root of your webserver's tree. But take into account I suggest you #
# lock your WHOLE filesystem because if you choose to lock only your Wordpress's files, any hacker #
# being "ethical" as they are, will write outside of your "locked zone" and exploit your webserver.#
# Thus, I STRONGLY suggest you lock your WHOLE filesystem. #
# #
# Should you choose otherwise, you could adapt the above #
# /path/to/public_html #
# with #
# /path/to/public_html/wordpress/install/path #
# #
####################################################################################################
find /path/to/public_html -type d -exec chmod 555 {} \; && find /path/to/public_html -type f -exec chmod 444 {} \;
mysql -uuser -ppassword -se "update MySQLDatabaseName.wpTablePrefix__options set option_value = 1 where option_name='filesystem_unlocker_plugin_lock_state'";