Hi Guys
I have several wordpress sites hosted on an Ubuntu server driven by Nginx. Ive had to clean out many bogus php files and clean up my sites following an obvious hack
I have fail2ban installed and ssl Hardening, I have disabled root login and password access so only access should be via ssh.
I’m guessing this is a Cross Site Scripting attack so I’m wondering what else I can do to prevent a repeat of this in the future?
Any advice would be greatly appreciated
Thanks in advance
Matt
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hello, @thinknew
I will recommend you to check the folder’s structure and make sure that the permissions are not set too high. This should prevent people from accessing certain directories and also prevent them from uploading files.
Another thing is to disable
shell_exec
. The shell_exec() function is an inbuilt function in PHP which is used to execute the commands via shell and return the complete output as a string. When it’s usually enabled people can use it to execute malicious scripts. In order to disable it open the PHP.ini file and add the shell_exec to the disable_functions row/line:You’ve mentioned that the sites are based on WordPress so there are several things you need to do:
Always make sure that your WordPress installations are up to date. When there is a new update you can take a backup (in case something goes wrong) for the site and then update the WordPress version.
Keep you plugins updated. When there is a new version of a plugin that you use, update it. You can again first take backup for the site in question.
Remove any plugin which is not active. If you have any plugins which are currently inactive and you’re not using it will be better to have this removed.
Install a security plugin like Wordfence, iThemes Security or Sucuri Security to keep everything protected.
Occasionally checking through the site files for the sites, making sure nothing is out of place
You can also check the status of your sites site checking them through hack scanners such as http://sitecheck.sucuri.net/ http://isithacked.com/ http://www.unmaskparasites.com/
Hope this helps!
Regards, Alex