cPanel Plesk

How to remove malware from WordPress

Applies to cPanel Plesk
By Jamie D Published 14 December 2023 Updated 19 October 2026 12 min read
Quick answer

If your WordPress site is hacked, back it up, then check the core files with WordPress Toolkit and scan the account with ImunifyAV. Delete files and accounts you do not recognise, change every password and the secret keys, and update or remove the plugin or theme that let the attacker in.

A hacked WordPress site can redirect visitors, send spam, steal data or serve malicious code to anyone who loads a page. This guide is for site owners on cPanel or Plesk hosting who think their site has been hacked. It covers how to confirm it, how to clean the site with the tools in your control panel, and how to stop it happening again.

Before you begin

  • You need access to your hosting control panel (cPanel or Plesk).
  • Take a full backup of your files and database before you change anything. See our guide on backing up WordPress. Keep the infected copy as well, in case you need to investigate later.
  • If the site is serving malicious content to visitors, take it offline while you work.
  • Run a malware scan on any computer you use to log in over FTP or wp-admin. Malware on your own machine can steal your passwords and undo the clean-up.

Is my WordPress site hacked?

You are probably hacked if you see any of these:

  • Visitors are sent to spam, gambling or phishing pages, often only when they are not logged in or are using a phone.
  • Google or your browser warns visitors that the site is dangerous or deceptive.
  • New administrator accounts, email accounts or FTP accounts appear that you did not create.
  • PHP files turn up in the wp-content/uploads folder, or files change when you have not updated anything.
  • Your host tells you malware has been found on the account or that your site is sending spam.
  • You cannot log in to wp-admin with a password that used to work.

For a quick outside check, paste your address into an external scanner such as Sucuri SiteCheck or VirusTotal. They only see what a visitor sees, so a clean result does not rule out a backdoor on the server. The scans below check the files themselves.

How do I fix a hacked WordPress site?

Work through these steps in order. Each one is explained in its own section below.

  1. Back up the site, and take it offline if it is harming visitors.
  2. Check the WordPress core files with WordPress Toolkit and reinstall them if they have been changed.
  3. Scan the whole account with ImunifyAV.
  4. Look through the files yourself for anything the scanners missed.
  5. Change every password and replace the secret keys in wp-config.php.
  6. Delete WordPress users, FTP accounts and email accounts you did not create.
  7. Update or reinstall the plugin or theme that let the attacker in, and apply the hardening steps.

If you cannot get the site clean, open a support ticket with the ImunifyAV report and the file paths involved.

How does malware get into WordPress?

An attacker usually finds a vulnerability in a plugin, a theme or WordPress itself, or logs in with a stolen password. Their first move is typically to upload a backdoor file, which gives them a way back in even after you delete the obvious damage. From there they can change existing files, add email accounts to send spam, or create scheduled tasks in your control panel.

Deleting the suspicious files does not fix the problem. The vulnerability or stolen password must be dealt with as well, or the site will be infected again.

Check WordPress integrity using WordPress Toolkit

WordPress Toolkit compares your core WordPress files with the official checksums. A mismatch means a core file has been modified, which is a common sign of compromise. The check does not cover files that hold site-specific data, such as wp-config.php and index.php.

  1. Log in to your control panel and open WordPress Toolkit. If your installation is not listed, click Scan to find it.
  2. Click Check WordPress Integrity on your site.
  3. Click Verify checksums. WordPress Toolkit compares your core files with the official versions and lists any that differ.
  4. If the check fails, click Reinstall WordPress Core. This replaces the core files with clean copies and leaves your content, plugins, themes and uploads alone.
WordPress Toolkit with the Check WordPress Integrity option

WordPress Toolkit.

The result of a WordPress Toolkit integrity check

Check WordPress Integrity results.

This replaces tampered core files but does not touch your plugins, themes or uploads folder, so carry on with the steps below.

Scan your site with ImunifyAV

ImunifyAV scans every file on your hosting account, including files outside WordPress, and flags malicious content.

  1. In your control panel, open ImunifyAV.
  2. Click Start scanning.
  3. When the scan finishes, open the Malicious tab to see the flagged files. If several detections sit in one plugin folder, that plugin is the likely way in. Update it or remove it.
  4. Open the Scan section to see earlier results. They can show you when the infection first appeared.
ImunifyAV in your control panel

ImunifyAV in your control panel.

Detected malware listed in the ImunifyAV Malicious tab

Detected malware listed in the ImunifyAV Malicious tab.

On our reseller platform we also scan servers for malware from time to time, but we only contact you when malware is found on your accounts or an abuse report is raised against them. Hearing nothing does not mean a clean scan has run recently, so scan your own accounts after any suspicion.

Scanners only catch what they have a signature for, so check the files by hand as well.

Manually check for undetected malware

Brand-new malware may not be in any scanner’s signature list. Open your control panel’s file manager or an FTP client and sort by Last Modified. Look for files that changed without a matching plugin or theme update, and for these signs:

  • Files with random names, for example ajwzxq.php.
  • PHP files that contain eval() or base64_decode().
  • Long strings of random characters, which usually mean obfuscated code.
  • Any PHP file inside /wp-content/uploads/, where executable files should never appear.
  • Unfamiliar rules in the .htaccess file in your site root. Attackers often use it to redirect visitors.
Sorting by Last Modified in cPanel File Manager

Sorting by Last Modified in cPanel File Manager helps identify recently changed files.

If you have SSH access, you can search from the command line. Replace /var/www with the path to your WordPress installation. This lists every PHP file changed in the last seven days:

“ find /var/www -type f -name '*.php' -ctime -7 “

This lists PHP files in the uploads folder:

“ find /var/www/wp-content/uploads -name "*.php" “

Before you delete a suspicious file, check whether it belongs to a plugin or theme. If it does not, delete it. If it does, that plugin or theme is compromised: delete it and reinstall it from the official source.

Change all passwords and remove unrecognised accounts

Attackers harvest FTP, control panel and WordPress logins. If you leave the old credentials in place, the site can be infected again straight after you clean it.

Update your WordPress user passwords and secret keys

  1. In your WordPress dashboard, go to Users and click Edit on each account.
  2. Scroll to Account Management, generate a new password and click Update Profile.
The Account Management section of a WordPress user profile

Update passwords for all WordPress user accounts.

Then replace the secret keys (salts) in wp-config.php with a fresh set from the WordPress secret key generator. This logs out anyone who is still signed in, including the attacker. If the database password may have been exposed, change it in your control panel and update wp-config.php to match.

Change your FTP password

Change the password for every FTP account on the site. To see or remove FTP accounts, follow how to add an FTP account.

  1. In cPanel, go to FTP Accounts and click Change Password next to each account.
  2. In Plesk, go to FTP and click each account to set a new password.
FTP Accounts in cPanel

Change FTP account passwords in cPanel.

FTP accounts in Plesk

Change FTP account passwords in Plesk.

Change your control panel password

  1. Log in to the client area, click Services in the top bar, then My Services, and click Manage next to your service.
  2. On the Overview tab, click Change Password in the Actions list and choose a strong password with a mix of upper and lower case letters, numbers and symbols.
A hosting service page in the client area with the Actions list on the left and the Change Password item outlined in red.

Change your cPanel password from the client area.

Changing a Plesk password from the client area

Change your Plesk password from the client area.

Resellers can only change their own password in the client area. To change passwords for other users, use your control panel directly.

Remove unrecognised WordPress users

Compromised sites often gain new users, sometimes with administrator rights. Go to Users in your WordPress dashboard, review the full list and click Delete next to any account you do not recognise.

The WordPress Users list

Delete any unrecognised accounts from the WordPress Users list.

Remove unrecognised FTP accounts

Attackers may add FTP accounts to keep access after a clean-up. Delete any you did not create.

  1. In cPanel, go to FTP Accounts and click Delete next to any unrecognised account.
  2. In Plesk, go to FTP, tick the account and click Remove.
The FTP Accounts list in cPanel

Remove unrecognised FTP accounts in cPanel.

The FTP account list in Plesk

Remove unrecognised FTP accounts in Plesk.

Remove unrecognised email accounts

Attackers often create email accounts on a compromised site to send spam. Delete any you did not create, and change the password on the ones you keep.

  1. In cPanel, go to Email Accounts, click Manage next to the account, then click Delete Email Account.
  2. In Plesk, go to Mail, then Mail Accounts, and remove the account.
Email Accounts in cPanel

Email Accounts in cPanel.

Deleting an email account in cPanel

Delete unrecognised email accounts in cPanel.

Removing a mail account in Plesk

Remove unrecognised mail accounts in Plesk.

With the credentials changed and the unknown accounts gone, the attacker’s routes back in are closed. Next, deal with the weakness that let them in.

How do I stop my WordPress site being hacked again?

Cleaning without fixing the cause means reinfection. These steps cover the usual causes.

Keep WordPress, plugins and themes up to date

Outdated software is the most common way WordPress sites are compromised, because updates often patch known vulnerabilities. WordPress Toolkit and Softaculous both show available updates and can apply them automatically. You can also update from the dashboard: go to Plugins and click Update beneath any outdated item. Turn on automatic updates for plugins where you can; see how to enable auto-updates for WordPress plugins.

Only use plugins and themes from legitimate sources

Nulled plugins and themes are pirated copies of paid software, and they often arrive with malware already installed. Install from the official WordPress repository or from the developer’s own site. Be wary of a plugin that has not been updated in over a year or has few users. Delete plugins you no longer use, because a deactivated plugin can still be exploited while its files are on the server.

Install a security plugin

A security plugin adds monitoring and protection. Wordfence, for example, offers rate limiting, IP blocking, malware scanning and two-factor authentication for logins, with free and paid tiers. Our blog post on security plugins for WordPress compares the options.

Apply security measures in WordPress Toolkit or Softaculous

Both tools can apply security hardening in a few clicks. In WordPress Toolkit, go to Fix Vulnerabilities, then Security Measures.

Security Measures in WordPress Toolkit

Security Measures in WordPress Toolkit.

In Softaculous, open your WordPress installation and go to the security settings. The Critical Only preset applies the measures least likely to affect how your site works. You can switch on individual measures too, but read the tooltip for each one first, because some change how the site behaves.

WordPress Management in Softaculous

Softaculous WordPress Management.

Softaculous Security Measures with the Critical Only preset

Softaculous Security Measures with the Critical Only preset.

Check file permissions

WordPress recommends 755 for directories and 644 for files, and 400 or 440 for wp-config.php. Looser permissions make it easier for an attacker to write or change files. Check them after a compromise.

Clean every WordPress installation on the account

If the account holds more than one WordPress site, each needs the same clean-up. Malware can move between installations that share a file system, so a clean site next to an infected one can be reinfected.

Can a hacked WordPress site be recovered?

Yes. Most hacked sites can be cleaned, and a backup from before the infection gives you a clean starting point. You can restore one with JetBackup. On our WordPress hosting, JetBackup takes a backup every four hours, so a recent restore point is usually there. Restoring does not close the hole the attacker used, so you still need to update or remove the vulnerable plugin or theme and change your passwords, or the site will be hacked again. Watch the site and ImunifyAV for new detections over the following days.

Troubleshooting

Malware keeps returning after removal

If malware reappears after a clean-up, the vulnerability behind the first infection is still open. Removing files treats the symptom, not the cause.

  • Check the ImunifyAV results for clusters of infected files in one plugin or theme folder. That folder is likely the entry point.
  • Update or reinstall the affected plugin or theme from a clean source.
  • Check your access logs for repeated POST requests to PHP files in unusual places, which can point to a live backdoor.
  • Confirm every credential has been changed, including the database password in wp-config.php.

WordPress Toolkit does not show my installation

  • Click Scan in WordPress Toolkit to search the account for installations.
  • If it still does not appear, use the file manager to confirm the WordPress files are in the directory you expect.

Google or a security vendor has flagged my site

A site that served malware may be on a blacklist, which can hurt search rankings and trigger browser warnings.

  • Use VirusTotal to see whether security vendors list your domain.
  • If Google flagged the site, log in to Google Search Console and request a review once the malware is gone.
  • For other vendors, follow their rescan or removal request process.

ImunifyAV flags files that look legitimate

Scanners can raise false positives, particularly on obfuscated but legitimate code in some commercial plugins and themes.

  • Before you delete a flagged file, check whether it belongs to a known plugin or theme.
  • If it does, reinstall the plugin from the official source and rescan.
  • If you are unsure, send us the file path and the ImunifyAV report in a support ticket.

If you cannot log in to wp-admin because the site is broken, see how to disable plugins using WordPress Toolkit. To get back in with a new password, see resetting your WordPress admin password.

Once the site is clean, set up regular backups so you always have a clean restore point, and force HTTPS if you have not already.

Plans and tools mentioned in this guide

WordPress Hosting

Tuned for WordPress, with one-click installs.

From £5.99/mo

View WordPress Hosting

Did this guide solve your problem?

Still stuck?

Our UK support team answers tickets and live chat every day. Send us the guide you were following and where it stopped working.

Open a ticket

Keep learning

Running a WordPress site?

Get fast, secure and reliable WordPress Hosting with optimised for performance with AccelerateWP.

Get WordPress Hosting

Need multiple accounts?

Create fully isolated individual accounts for your clients and manage them all from one dashboard.

Get Reseller Hosting
Back to top