Saturday, January 18, 2025
HomeEveryday WordPressRemove Suspicious Code with Defender

Remove Suspicious Code with Defender


If you’re not careful, suspicious code within your sites can easily go unnoticed and wreak havoc. Whether you’ve been hacked and need a resolution ASAP, or you simply want to check your sites for suspicious activity, Defender can help you quickly detect and eliminate malware for good. See how it’s done in this tutorial.

Looking for a convenient and hassle-free way to locate and delete suspicious code from your sites?

In this tutorial we’re showing you, step-by-step, how Defender‘s vast suite of security features can help banish and keep suspicious code at bay.

You’ll also learn how to keep your sites protected from these kinds of issues going forward.

First order of business… Detecting and removing suspicious files and code can only be done with the Pro version of Defender.

You can get Defender Pro, along with our suite of Pro WordPress plugins and site management tools for a low $3/month. Which is incredible value, especially if you own or manage critical sites that are particularly susceptible to malware or attacks.

The first step is to enable the Suspicious Code setting via Malware Scanning > Settings.

You also need to ensure that File Change Detection is enabled for both ‘Scan Core Files’ and ‘Scan Plugin Files.’ This will help reduce the occurrence of false positives in your scans.

Once you’ve enabled these settings, you’re ready to scan your site for malware.

To do this, go to Malware Scanning via the WordPress admin sidebar or from the main Defender dashboard.

Start a new malware scan with a click and identify threats in seconds.

Once here, you can initiate a new scan with a click.

Then sit back and let Defender work its magic. The scan should only take a few minutes, depending on the size of your site.

A screen showing a Defender malware scan in progress.

Once the scan is completed, you will be alerted to any issues found relating to file change detection, known vulnerabilities, and suspicious code.

A screen showing that vulnerabilities have been detected.
The Issues tab details all of the vulnerabilities or suspicious behavior detected.

Next, simply click on the Issues tab. Here you will find a list of all the potentially harmful files that have been compromised or changed in some way.

A screen showing the issues the Defender scan has detected.
Defender quickly identifies issues for you to address.

Click on any of the detected files to get more details about the issue and its exact location.

In the example below, the suspicious code has been detected inside of a WordPress plugin. Defender specifically points out the error and the file in which it was found.

A screen showing details of an issue that was detected during the malware scan.
Quickly see where the detected issue was found.

Along with seeing important details like the plugin URL, location of the issue, date added, and developer, you have three options when it comes to addressing suspicious files or code.

You can either ignore, delete, or Safe Repair the file.

Caution: It’s strongly recommended to ensure that something is harmless before choosing to delete and/or ignore it. If you’re unsure or need advice, you can consult our 24/7 WordPress experts.

It’s important to note there is a chance that reported issues or vulnerabilities could be false positives, meaning that legitimate code being flagged as suspicious due to its resemblance to malicious code.

This can happen for various reasons, such as a function being modified by a plugin or theme, or if something is directly modified in the file or theme editor.

Fortunately, Defender is designed to minimize the occurrence of false positives. However, malicious code often mimics legitimate code, making it almost impossible to avoid completely.

To help verify suspicious code, you can take a couple of steps:

  • Verify custom edits: Check with the plugin developer to confirm the questionable code.
  • Contact our support: If you didn’t add the code, and you’re certain no one you know did, feel free to contact WPMU DEV support for feedback and to share what you deem to be malicious code.

We highly recommend you reach out to either the plugin developer or our expert support team for advice before deleting any files. You’ll also need to deactivate the plugin before you can delete the associated file.

Another great and risk-free option is to use Defender’s Safe Repair feature.

A screen showing where the user can enable the Safe Repair feature
Using Defender’s Safe Repair feature is a great way to repair your site without worrying if deleting a file will do even more damage.

Click Safe Repair to automatically quarantine the file for a defined amount of time that you specify (30 days – one year).