Faced this problem in few sites of my client. Fixed it by removing the script code from the site.
The malicious string is the same for every compromised file, so mostly downloading whole project from FTP, and then CTRL+SHIFT+F all files in project for the phrase you pasted should make your day. – You can also look for it in the Database using various combination of searches using for example https://pl.ww.wp.xz.cn/plugins/search-and-replace/
I have found the malicious code also in my own custom post type body( the_content() )
After that I’d recommend to:
clean up your PC and browsers’ extensions as they could be the main security-hole
define( 'DISALLOW_FILE_EDIT', true ); in wp-config
Change your database password
Check if all WP User accounts and their e-mails are known to you. If not, just suspend or delete them.
Install some basic security for WP
Ask your hosting company to help you by installing anti-virus on the server(or just launching you the option – this may be extra – billed for you).
There’s probably better way, but my solution led up to get free of viruses in short time(hope they don’t come back soon).
-
This reply was modified 6 years, 2 months ago by
sellmark.
-
This reply was modified 6 years, 2 months ago by
sellmark.
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
Moved to Fixing WordPress, this is not an Everything else WordPress topic.
Don’t post malware on this site, that’s not allowed and removed when found.
Please remain calm and give this a good read.
https://ww.wp.xz.cn/support/article/faq-my-site-was-hacked/
When you have successfully deloused your site then consider giving this a read too.
https://ww.wp.xz.cn/support/article/hardening-wordpress/