PHP code in functions.php of all wordpress websites on my shared hosting

I know this answer is very late but I'll share my experience to help any one who has this problem. cause of this issue can be a plugin that you downloaded from outside of wordpress.org or some body has access to your wordpress admin account and you doesn't already close editor.php in appearance tab or hacker has your ftp user and password or ... to solve this create a full backup first and save it in your computer in case of doing any mistake and then:

  1. go to theme directory of your wordpress site and delete all of the unused theme because they are infected already.
  2. in active theme edit your functions.php file and delete all extra code inserted by malware. you can search for wp_vcd or wp-tmp words to find the code.
  3. download latest wordpress installation. then delete wp-include and wp-admin folder and all files in public_html except wp-content folder and .htaccess file and wp-config.php file. after that replace deleted files and folder with downloaded wordpress.
  4. remove all plugins that you downloaded from known source.
  5. finally change all of your passwords like ftp, admin panel, cpanel or direct admin and ... in case if hacker saved your info somewhere.

hope this little guide can help someone.


Apparently your site has been compromised (hacked). You can contact your hosting provider, they probably (surely) will not help you. You can contact a web site security company, I use sucuri.net. If you want to clean it yourself, there are 2 options

  • delete EVERYTHING and reinstall all the sites, including the database!
  • if you cannot reinstall everything, you'll have to check script per script to find "weird" code and clean it. If you find a few keywords that repeat (for example the code9 that shows your code, you can look for this, but probably sometimes it's code9 and sometimes is a different name.
  • update as much as you can, as plugins, template and of course your wordpress version.

No need to do ton of such changes, simply do these two steps >>

1 > Dashboard > Updates > "Re-install Now"
This will re-install latest version of WordPress, overwriting infected wp core files.

2 > Now open theme functions.php file in editor and remove malicious code snippet and hit save.

All done! this time it will accept the file changes to remove infected code from functions.php file.

Tags:

Php

Wordpress