How to Fix

Thousands of sites are recently affected by lovegreenpencils malware, directing users to:
This contamination affects PHP files, JS files, wp_posts tables, wp_options site URLs.

Need help? Let us clean your site.

To fix a hacked website, follow these steps:

Step 0
Backup site
1. Backup database and site files. If you can’t do it, ask your web host.
2. Disable MySQL remote access, especially if you’re using Plesk.
3. Change MySQL user password.

Step 1
Rebuild site
1. Download a fresh WordPress copy:
2. Extract, add wp-config.php from your infected site inside wordpress folder ( make sure you check its content and clear malicious lines – if any ).
3. Add plugins and theme manually, one by one, inside /wp-content/plugins/ and /wp-content/themes/
4. Upload everything back to your server.

Step 2
Reset site URL
Restore site URL:
Easiest way would be to edit wp-config.php file via FTP or hosting dashboard ( replace with your own domain name ).

define( 'WP_HOME', '' );
define( 'WP_SITEURL', '' );
Step 3
Clean local files
If site rebuild still contains plugins or theme from a backup, all index.php and JS files may be corrupted as well.
Look for “String.fromCharCode”, “lovegreenpencils”, “secondaryinformtrand” and “list.insertBefore(s, list.childNodes[0])”.

Insert the following script with pack.php file and place it inside your root folder. This way you can pack all PHP and JS files, which can be cleaned locally.

Search and replace tools for malicious strings inside multiple files: dnGrep, grepwin, VisualGrep ( mac ), powergrep ( paid ).
Example of infected index.php file:

Example of infected JS file:

Step 4
Database check
1. As a precaution measure, look for “lovegreenpencils” and “secondaryinformtrand” then for “String.fromCharCode”.This way you will know if other tables are infected as well.
Attackers usually alter wp_posts and wp_options tables. Example:

The following SQL commands may be used to clear any malicious JS injections:

2. Check users with administrator privileges.

Step 5
Major update
Perform a major update, making sure core files, theme and plugins are up to date.
Disable any unmaintained abandoned plugins.

Step 6
Blacklist status & Google cache
Site should be verified with Google search console. To refresh indexed pages, ask for a re-index.
This way, any infected cached pages listed on Google will be updated.

Step 7
Cross-site contamination
If you’re using a single cPanel for multiple websites, all index.php and JS files may be infected.
So make sure other sites hosted on the server are secured. And better move each site with a separate cPanel, after cleanup will be completed.

Step 8
Find and remove backdoors
Attacker will often install a backdoor file, to regain access later on. In this particular case, PHP scripts can be found inside /uploads folder.
Here are some live samples from the server logs: – – [23/Nov/2020:05:28:36 +0800] “POST /wp-content/uploads/wp-stream.php HTTP/1.1” 200 – – [14/Nov/2020:05:05:53 +0100] “POST /wp-content/uploads/2020/11/wpc.php HTTP/1.1” 200 – – [22/Nov/2020:23:10:54 +0100] “POST /wp-content/uploads/2020/11/wpc.php HTTP/1.1” 200 – – [23/Nov/2020:03:49:54 +0800] “POST /wp-content/uploads/wp-beckup.php HTTP/1.1” 200

Try our Free site check.

If your Google Ads are currently suspended, we would recommend our Platinum plan, which will include malware cleanup and Ads support:

New “” wave of attacks, documented on Nov. 29:

Other malicious links:
Malicious domains used with this attack:,,,,,,,,,,,,,,,,,,,,
Malicious IPs:,,,


Try our Free site check.

6 thoughts on “How to Fix

  1. How should I prevent this kind of malware? I’m using standard wp plugins and update automatically. but it comes back!

    1. Make sure to follow the cleanup steps. Or subscribe with a Magefix plan, so we can sort it out for you.

Comments are closed.