Last updated: · By Asael Dreyer
Short answer: there are three ways to remove malware from a WordPress site: clean it by hand (replace core and plugin files with official copies and hunt for foreign code in the database), use a security plugin that scans and cleans from inside WordPress, or use automatic server-level cleaning that runs outside your site. Manual cleanup is free but takes know-how and hours. A plugin is convenient, but it runs on the same layer the malware runs on. Server-level protection, like Cloudways Malware Protection at $2 to $4 per application per month, also cleans the database and keeps protecting the site after the cleanup.
⏱ Time needed: 30 minutes (server-level cleanup) to 4–8 hours (manual cleanup) · Difficulty: intermediate to advanced · Last checked: 6 Nov 2026
What “a virus on your site” really means, and why it is so hard to get rid of
Malware on a website is code that was inserted without permission and does something you never asked for. On WordPress sites it usually shows up in one of four forms:
- Backdoor: a small PHP file that lets the attacker come back even after you change your passwords. It is the most important thing to clean, and the easiest to miss.
- Malicious redirect: sends visitors to another site, sometimes only from mobile or from Google.
- SEO spam: thousands of hidden pages or links that exploit your domain’s authority in Google.
- Data theft: a script on the checkout page that copies card details, or code that steals user passwords.
Malware is hard to clean for two reasons. First, it spreads: there are several copies in different places, and some of them live in the database rather than in files. Second, if the door they came through (a vulnerable plugin, a leaked password) stays open, the site gets reinfected within days. For an example, see what a WP File Manager hack on Cloudways looks like and what to do afterwards.
Before you start cleaning
- Isolate the site and save a copy of its current state, as explained in the emergency guide for a hacked site. If you haven’t done that yet, start there.
- Change every password: hosting account, SFTP/SSH, WordPress admin users, the database and email.
- Check whether you have a backup from before the hack. If you do, restoring it may be faster than cleaning (see backup and restore on Cloudways).
- Make sure you have SFTP or SSH access to the server. Cleaning only through the WordPress dashboard does not reach every file.
Which way of removing malware from a site should you choose?
| Manual cleanup | Security plugin | Server-level cleanup | |
|---|---|---|---|
| Cost | Free (your time) | Free versions exist. Paid cleanup services, for example Sucuri from $229 per year (official site, 6 Nov 2026) | Malware Protection on Cloudways: $4 per application per month (1–5), $3 (6–15), $2 (16 and above) |
| Skills needed | High: SSH, WP-CLI, SQL | Low | Low |
| Time | Hours | Minutes to an hour for a scan | The first scan starts as soon as you enable it |
| Database | Only if you search it yourself | Depends on the plugin | Yes, for WordPress, Joomla and Magento |
| Can malware disable it? | Not applicable | Yes, it runs inside WordPress | No, it runs outside your site |
| Protection after cleanup | None | Yes, as long as the plugin is active | Yes, including runtime blocking (RASP) |
| Best for | Developers, small sites, zero budget | Any hosting, including shared | Anyone hosting on a Cloudways Flexible server |
There is no single “best” option. If you are on shared hosting and don’t plan to move, a plugin is the practical choice. If you manage several sites on your own server, server-level cleanup saves the most time. And if you are a developer who wants to understand what happened, manual cleanup teaches you the most.
Way 1: manual cleanup of a WordPress site, step by step
The core idea: don’t try to find every malicious line. Replace everything you can replace with a clean official copy, and search by hand only through what you can’t replace (your content, the uploads and the database). The commands here are WP-CLI, which is available on Cloudways servers over SSH (see connecting over SSH and the WP-CLI guide).
- Check the core files against the official version:
wp core verify-checksums. Any file reported as different or unexpected is suspicious. - Replace the core with a clean copy without touching your content:
wp core download --force --skip-content. The command downloads the WordPress files again and leaveswp-contentandwp-config.phpalone. - Check the plugins:
wp plugin verify-checksums --allcompares plugins against the official repository. Reinstall any plugin that fails the check. Premium plugins should only be re-downloaded from the vendor’s own site. - Delete unused plugins and themes, and anything downloaded from an unofficial source (a “nulled” version of a paid plugin).
- Look for PHP files in the uploads folder:
find wp-content/uploads -name "*.php". There should be no PHP files in that folder. Any result is almost certainly malicious. - Go through the active theme’s files, mainly
functions.php,header.phpandfooter.php. Search foreval(,base64_decode(and long unreadable strings. If the theme comes from the official repository, just reinstall it. - Check
.htaccessin the root folder and in subfolders.RewriteCondrules that look at where the visitor came from (Referrer) or which browser they use (User-Agent) are a clear sign of a malicious redirect. - Search the database for injected scripts:
wp db search '<script' --all-tables. Also check thesiteurlandhomevalues in the options table. - Check users and scheduled tasks:
wp user list --role=administratorandwp cron event list. Delete administrators you don’t recognize and tasks with odd names. - Replace the security keys (salts) in
wp-config.php:wp config shuffle-salts. This logs out everyone who is currently signed in, the attacker included.
Before deleting anything, make sure you have a copy. And on a WooCommerce store, don’t run search-and-replace commands on the database without a fresh backup: one mistake in a search-and-replace is enough to break orders.
Way 2: cleaning with a security plugin
Security plugins like Wordfence and Sucuri offer a scanner that compares your files against official copies and looks for signatures of known malware. Some also offer a paid cleanup service done by their team. The advantage: it works on any hosting, shared hosting included, and needs no SSH.
The structural weakness: the plugin runs inside WordPress, on the same layer as the malware. Malware with write permissions can disable the plugin, modify it, or hide from its scan. Cloudways makes the same argument for server-level protection, and it holds true regardless of the vendor. On top of that, a full scan of a large site uses server resources, on the site itself.
If you chose a plugin: run a full scan, deal with every finding (if the plugin isn’t sure, don’t delete a core file, reinstall it), and then go through steps 4, 5 and 9 of the manual cleanup. A plugin doesn’t always find PHP files in the uploads folder or users that were added.
Way 3: server-level cleanup with Cloudways Malware Protection
Malware Protection is a paid add-on for Cloudways Flexible servers, built on Imunify360. It runs at the server level, so code planted in your site can’t turn it off. It scans files and the database, cleans automatically, and sends a report. As of November 2026 the price is per application per month: $4 for 1 to 5 applications, $3 for 6 to 15, and $2 from 16 up.
- Log in to the management panel, open Servers and choose the server your site lives on.
- Click the www icon (the globe) and choose the application.
- Under Application Management, choose Application Security → Malware Protection. Already here you can see whether the application is marked as Infected.
- Click Enable Protection. Real-time protection is switched on, and the first scan of the files and database starts automatically. You don’t need to keep the panel open.
- When the scan finishes, go to the Malicious tab. Every finding appears with a status: Cleaned (the code was removed from inside the file), Removed (the whole malicious file was deleted), Quarantined (isolated, and can be restored) or In Progress.
- Go through the list. If a legitimate file was flagged by mistake, restore it from the Actions column. The restore is automatically reported as a “False Positive” for review. Check with your developer before restoring anything.
- Check Scan History and Proactive Defense. The second shows attempts that were blocked at runtime, including the script path they came from. That is a good hint to where the hole is.
Two important things to know. First, if the automatic cleanup doesn’t succeed, you open a support ticket, and according to Cloudways its security analysts clean manually at no extra charge. Second, the add-on does not give you a full investigation of how the attacker got in. Cloudways says so explicitly. Closing the hole is still your job (see below). To get the warning removed from Google, see Google’s “this site may harm your computer” warning.
One more clarification: malware detection is included for free on Flexible servers. What you pay for is the automatic cleanup, the runtime protection and the database scan. You can enable the add-on only on selected sites. Full setup guide: Malware Protection on Cloudways. Prices of all add-ons: add-on pricing.
The code BFCM802 takes 80% off your bill for the first two months (up to $200 off per month), including unlimited free site migrations. New customers only, and only until the offer ends.
The offer ends on December 4, 2026 at 23:59 (UTC+2).
Start with a free trial, no credit card. Enter the code at checkout and check that it shows up.
After Black Friday: 30% off for 3 months with the code ASAEL. On a large server (above about $444 a month) ASAEL already saves more today. BFCM802 vs. ASAEL calculator
Start a free trial server, no credit card. When you move to a paid plan, the code ASAEL takes 30% off your bill for the first three months.
The link fills in the code on the signup form. Just make sure it shows up.
How do you make sure the site is really clean afterwards?
Verify it systematically, because a cleanup you haven’t checked is a guess. After any of the three ways, go through this list:
- Run another scan. A new finding a day or two later means the backdoor is still there.
- Visit the site from a mobile phone, from an incognito window and through a Google result. Those are the scenarios malware tends to target.
- Search Google for
site:yourdomain.comand check whether any spam pages are left in the index. - Check the Security issues report in Google Search Console, and if there is a warning, submit a review request.
- Close the hole: update everything, check the Vulnerability Scanner in the panel (under Application Security), and turn on two-factor authentication.
When to call a professional
There are situations where you shouldn’t clean the site yourself: when the site processes payments and card theft is a possibility, when the site gets reinfected after two cleanups, when you suspect customers’ personal data leaked, or when you simply don’t have time to learn this under pressure. A security specialist will also look for the entry point, which is the part automated tools don’t do. For cleaning up and recovering after spam, see the Japanese keyword hack and spam pages in the index.
What mistakes do people commonly make when removing malware from a site?
Cleaning without changing passwords: the attacker comes back with the old password. Change them first, clean afterwards.
Deleting only the suspicious file: malware almost always leaves several copies. After you find one file, search for the same string across the whole site.
Forgetting the database: redirects and scripts injected into posts and settings won’t show up in a file scan.
Installing another security plugin on top of an existing one: two scanners running at once slow the site down and can conflict. Pick one.
Restoring a file flagged as malicious “because the site broke”: sometimes it really is a false positive, and sometimes the theme itself is infected. Check the code before you restore it.
The offer ends on December 4, 2026 at 23:59 (UTC+2).
Start with a free trial, no credit card. Enter the code at checkout and check that it shows up.
Start a free trial server, no credit card. When you move to a paid plan, the code ASAEL takes 30% off your bill for the first three months.
The link fills in the code on the signup form. Just make sure it shows up.
Don’t want to handle this yourself? On the website maintenance page I explain what a maintenance plan should include and what it costs.
Frequently asked questions
Clean fast, return a 404 or 410 for the spam pages that were added, and ask Google for a review in Search Console. Your real pages haven’t changed, so rankings usually recover once the warning is removed. What really hurts rankings is leaving the site infected for a long time.
Sometimes, for a simple hack. But a plugin runs inside WordPress, and malware with write permissions can disable it. After the scan, manually check the uploads folder for PHP files, admin users and the database.
Manual cleanup costs only your time. On Cloudways, Malware Protection costs $2 to $4 per application per month, and includes manual cleanup by support if the automatic one fails. External cleanup services, such as Sucuri’s, start at hundreds of dollars a year.
Because the hole is still open or a backdoor is still there. The usual causes: a vulnerable plugin that wasn’t updated, a password that wasn’t changed, or a malicious file that wasn’t found. Change passwords, update everything and replace the security keys in wp-config.php.
According to Cloudways, the performance impact is negligible, because the scan runs at the server level and not inside WordPress. It notes that noticeable resource use may appear only on a small server with a huge number of files.
Yes, they shouldn’t conflict, because Malware Protection blocks requests at the server level before they reach the plugins. Cloudways recommends moving fully to server-level protection, but the decision is yours. If you keep a plugin, turn off its heavy scanning to save resources.
Related guides
- Hacked site? Emergency guide: the first 10 steps
- Malware Protection on Cloudways: setup and use
- Cloudways add-on pricing
- Website security: all the layers
- WP-CLI on Cloudways
- All security guides: security guides
Sources
- How to Use Malware Protection to Protect Your Applications
- Detect Security Bugs Using Vulnerability Scanner
- Cloudways Malware Protection
- Sucuri pricing
- WP-CLI: wp core verify-checksums
Official source: How to Use Malware Protection to Protect Your Applications, Detect Security Bugs Using Vulnerability Scanner (Cloudways Knowledge Base); Cloudways Malware Protection; Sucuri pricing (checked 6 Nov 2026); WP-CLI: wp core verify-checksums. This guide was written and checked by Asael Dreyer · Updated: 6 Nov 2026
Disclosure: this is an independent site, not the official Cloudways site. Some links on this site are affiliate links: if you sign up through them we earn a commission, at no extra cost to you. Full details