Remove WordPress malware: how to clean your site

Titelbild: WordPress Malware entfernen: So säuberst du deine Seite

To remove malware from WordPress, you first secure the current state, scan files and database, replace the WordPress core, plugins and theme with fresh originals, delete malicious code and foreign users, update everything, and change all credentials. Finally, you verify the result with another scan and ask Google to lift the warning.

A red warning screen in the browser, a suspension by your hosting provider, or sudden redirects to shady sites: discovering your website has been hacked is a shock—but no reason to panic. Malware on a WordPress site is not a rare exception: security studies repeatedly show that a large share of infected sites stems from outdated plugins or stolen credentials. The problem: malware likes to hide. It sits in files, in the database, in uploads and sometimes in seemingly harmless plugins. If you only remove the visible symptom, your site will be full of spam again after a few days.

In this article you will learn how to Remove WordPress malware , how to find malicious code safely, which tools help and how to tell that the site is really clean. If you first want to clarify whether your site is affected at all, the overview in the article WordPress hacked: What to do now.

What is malware, and what does it want on your site?

Malware is a collective term for malicious software. On WordPress sites you mainly come across these types:

  • Backdoors: small scripts that give the attacker access at any time, even after a password change.
  • Redirect malware: sends visitors to advertising, casino or fraud sites.
  • SEO spam: generates thousands of foreign pages with pharma or gambling keywords under your domain.
  • Web shells: give the attacker a kind of file manager directly on your server.
  • Skimmers: steal payment and form data, especially dangerous in shops.
  • Cryptominers: use the computing power of your server or your visitors.
  • Spam mailers: send mass emails via your server until your host blocks it.

The motives are almost always financial. Your company is uninteresting to them, but your server resources and your domain trust are not.

Remove WordPress malware: featured image

Preparation: before you delete anything

Good cleanup starts with discipline, not with deleting.

Back up the infected state

Copy all files and export the database, even if everything is infected. If something goes wrong during cleanup, you can go back. The copy also helps with the analysis. How to create a clean full backup is described in the article Create a WordPress backup.

Take the site offline

Put the site into maintenance mode. Visitors stay protected, and the attacker cannot reload further files while you work. The safest way is a block via .htaccess, which only lets your IP address through.

Change access credentials immediately

Change passwords for WordPress, hosting, FTP, database and the administrator email account. Also renew the salts in the wp-config.php. This invalidates all active sessions. You will find more about passwords and login protection in the article Secure your WordPress login.

Infographic: remove WordPress malware in 6 steps
Malware entfernen: Die Säuberung in 6 Schritten (Klick zum Vergrößern)

Step 1: track down the malware

First you have to know where the malicious code is. There are three ways that complement each other.

Use scanners

Security plugins such as Wordfence, Sucuri or Malcare compare your files with the originals from the WordPress directory and look for known malicious patterns. That is fast and finds a lot. It does not find everything, though, because scanners do not always detect new or well-disguised malware. So ideally use two different scanners and do not rely on a single result.

Compare files manually

Sort your files by modification date. Anything that was changed recently and has no reason for it is suspicious. Typical hiding places:

  • wp-content/uploads: there should be no .phpfiles here
  • wp-content/plugins and themes: unknown folders or files with random names
  • wp-config.php and .htaccess: foreign lines at the beginning or end
  • Main directory: files such as wp-tmp.php or admin.php, which do not exist in a normal installation
  • Theme files such as functions.php and header.php: injected code at the end of the file

Check the database

Malicious code is often hidden in the database too. Check the table wp_users for unknown administrators, the table wp_options for foreign entries at siteurl, home or in widgets, and the table wp_posts for injected <script>or <iframe>tags. A search for base64_decode or eval( in the database often delivers quick results.

Step 2: replace core, plugins and theme

The safest way to clean program code is not to cut the malicious code out, but to reload everything that can be replaced completely.

  1. WordPress core: Download the current version from wordpress.org. On the server, delete the folders wp-admin and wp-includes and upload the fresh folders. Also overwrite the files in the root directory (except wp-config.php).
  2. Plugins: Delete the entire plugin folder and reinstall all needed plugins from the official directory. Plugins you no longer need stay gone.
  3. Theme: The same applies to the theme. If you have made customizations in the theme, check those files by hand before reinstalling them.
  4. Premium plugins: Download them fresh from the vendor. You remove nulled versions without replacement, they are often the cause themselves.

Step 3: clean up the remaining findings

After the replacement the areas remain that you cannot reload: uploads, wp-config.php, .htaccess and the database.

Uploads

Search the folder for .php, .phtml, .icofiles with PHP content and files with a double extension such as bild.jpg.php. Delete them. To permanently forbid the execution of PHP in this folder, you can place an .htaccess file that blocks access to PHP files.

wp-config.php and .htaccess

Open both files and remove everything you do not recognize. The .htaccess you can reset to the default version if necessary (WordPress regenerates it via the permalink settings). In the wp-config.php file, check whether there is code at the beginning or end that does not belong there.

Users and database

Delete unknown administrators. Also check existing accounts for changed email addresses. Remove injected scripts in posts and options. If you are unsure about SQL, do not do it by guesswork: a wrong delete command does more damage than the malicious code.

Step 4: update and harden

After the cleanup, the vulnerability the attacker used has to go. That only works with an up-to-date state.

  • Bring WordPress, plugins and theme to the latest version
  • Raise the PHP version to a supported version
  • Set file permissions: folders 755, files 644, wp-config.php 600 or 640
  • Disable file editing in the backend (DISALLOW_FILE_EDIT in the wp-config.php)
  • Two-factor authentication for all administrators
  • Activate a firewall (see WordPress firewall)

You will find a complete list of these measures in our security checklist. If you do not want to take care of it yourself every time: the Security package costs $32 per month, the maintenance with updates $99 per month.

Step 5: check the result

Before you release the site again, check whether everything is really clean.

  • New scan with two different tools, without findings
  • No unknown files, no changes in the critical folders
  • The site loads normally, also on mobile and from Google
  • Contact forms, login and shop work
  • A fresh backup is available

Watch the site particularly closely over the following two weeks. If malware shows up again, a backdoor has been left behind somewhere. Then you have to search more thoroughly once more or choose the backup approach, as the article Restore a WordPress backup describes.

Lift the Google warning

If Google has marked your site as dangerous, the cleanup alone does little. You have to actively request the review.

  1. Log in to Google Search Console.
  2. Open "Security and manual actions" and there "Security issues".
  3. Check whether the listed example URLs are really cleaned.
  4. Request the review and describe in one sentence what you have done.

Google usually answers within a few days. If SEO spam pages are in the index, you can also report them for removal there. The ranking usually recovers within a few weeks.

Why does malware keep coming back?

If the infection returns, one of these points is almost always to blame:

  • A backdoor was overlooked, for example in a rarely used plugin folder or in the database.
  • The original vulnerability is still open because a plugin was not updated.
  • The credentials are still known, for example through a data breach, or the password was not changed everywhere.
  • Another site on the same server is infected and infects yours. With shared hosting this happens often.
  • Nulled plugins or themes were used.

The last point in particular is underestimated. If you use premium software from untrusted sources, you may remove the malware ten times and reintroduce it yourself an eleventh time with the supposedly free plugin.

Do it yourself or have it done?

Cleaning the site yourself is feasible if you have access to files and the database, feel confident using FTP and phpMyAdmin, and can spare the time. One to two hours are enough for a small website, while larger or stubborn cases can easily take a full day. It is worth getting help if:

  • the site generates revenue and every hour of downtime costs money,
  • personal data could be affected,
  • the malware returns after the cleanup,
  • you do not feel sure with files and database.

With the Emergency Recovery Service for $539 we take over the cleanup or restore a clean backup and close the vulnerability. For a single, clearly limited error the Error Fix service for $129 is often enough.

Prevention is cheaper than cleaning

A clean site stays clean if you permanently do three things: apply updates promptly, protect the login and regularly store backups that are not on the same server. Add a firewall and a regular scan. The monthly effort is small compared to a cleanup. The reasons why brute force attacks are often the first step are explained in the article Detecting and stopping brute force attacks.

Practical example: malware in an online shop

A small online shop with WooCommerce attracts attention because customers get in touch: after ordering they receive foreign emails, and some report unknown debits. An analysis finds a skimmer, a short JavaScript in the footer of the theme that sends the entries to a foreign server when the payment form is submitted.

Here is how we handled the cleanup:

  1. Shop put into maintenance mode, payment methods deactivated for the time being.
  2. Copy of files and database secured as evidence.
  3. All theme and plugin files compared with fresh originals. The manipulated footer.php was found quickly.
  4. Database searched: a second, obfuscated script was hidden in the theme options.
  5. Core, plugins and theme reloaded, credentials and salts renewed, payment provider informed.
  6. Affected customers informed immediately and the data protection authority notified within the statutory 72-hour GDPR deadline.

The case shows: with shops, cleaning is not enough. You also have to check whether payment data was affected and fulfil your duties towards customers and authorities.

Tools compared

Tool Strength Limit
Wordfence File comparison with the official directory, firewall Does not always detect new malware
Sucuri Strong signatures, cloud firewall Cleanup limited in scope
Malcare Server-side scan, saves your resources Fewer settings
Manual check Finds backdoors that scanners miss Needs experience and time
Host scan Directly on the server, often included Quality varies a lot

No tool is perfect because each has different strengths: Wordfence is ideal for deep file comparisons right inside the WordPress backend, Sucuri SiteCheck reliably scans externally for blacklists and visible scripts, MalCare detects complex patterns via cloud analysis, and WP-CLI (wp core verify-checksums) verifies core files for tampering in seconds. The most reliable combination remains a scanner plus a manual check of modification dates, uploads, and the database.

Recognizing typical malicious code patterns

You do not have to be a programmer to recognize suspicious code. Watch for these oddities:

  • Very long strings of letters and numbers, often in combination with base64_decode or gzinflate
  • eval(), assert() or preg_replace with the modifier /e
  • Files named like official WordPress files, for example wp-config-sample.php in the uploads folder or class-wp-http.php in a plugin folder
  • Code that only reacts to certain visitors (mobile devices, Google origin, certain countries)
  • Lines in the .htaccess with RewriteCond on the user agent or the referrer
  • Entries in wp_options with huge content that looks like random text

Common mistakes during cleanup

  • Only cleaning the files and forgetting the database
  • Not checking the uploads folder
  • Changing passwords but not renewing the salts
  • Only deactivating plugins instead of deleting them (deactivated malicious code remains directly executable via URL on the server)
  • Going online too early and not informing Google
  • Not creating a backup after the cleanup

Key terms around malware

Signature

A typical pattern in the code that scanners use to recognize known malware. New or modified malware does not have a signature yet and is therefore overlooked more easily.

Obfuscation

Deliberately disguising code so that it is hard to read. Typical are Base64 encoding and long strings that are only decoded when executed.

Core files

The files of the WordPress core in wp-admin and wp-includes. They can be replaced with fresh originals at any time and should never be changed by hand.

Dropper

A small script whose only job is to reload further malware. If you remove the reloaded files but not the dropper, they come back.

Quarantine

When removing malware, some scanners move suspicious files into a secured area. That way you can examine them before you delete them for good.

Reinfection

The renewed infection of an already cleaned site. It almost always arises from overlooked backdoors or a vulnerability that was not closed.

The key points in brief

  • First secure the state and change credentials.
  • Scan files, uploads and database thoroughly.
  • Replace core, plugins and theme with fresh originals.
  • Then update, harden and scan twice.
  • Without a closed vulnerability the malware returns.

If you need help, the emergency recovery for $539 is ready.

After the cleanup: Monitor the first 30 days properly

Once the immediate checks after going live are done, the real test begins: many persistent infections lie dormant for days and only reactivate later via cron jobs or bots. Therefore, plan a structured monitoring routine for the first 30 days after cleanup.

Week 1: Check daily

  • Look at the file changes if your security plugin keeps a log. New PHP files in the uploads folder are a warning sign.
  • Check the user list for unknown administrators.
  • Test the contact form, login and shop so that nothing was broken by the cleanup.

Weeks 2 to 4: Check weekly

  • Run another malware scan and compare the result with the state right after the cleanup.
  • In Search Console, check the "Security issues" area and the indexed pages. Unknown pages with strange titles point to hidden spam content.
  • Look in the server logs for suspicious requests to files that should not exist.

Blocked by Google? Here is what to do

Once the Google warning has been lifted, monitor your indexing in Search Console over the following weeks: check under Pages to verify that all former spam URLs cleanly return a 404 or 410 status code and gradually drop out of Google's index.

In the end, there is a simple rule: document what happened and close the cause. Without this step, the next infection is only a matter of time.

Conclusion

Removing WordPress malware means: secure the state, search thoroughly, replace files, check the database and users, update and harden, and then inform Google. If you do not remove the cause, you clean again soon. If you would rather hand this over, take a look at our security offer or write to us via the Contact page.

Frequently asked questions about removing malware

How do I find malware in WordPress?

Use a scanner such as Wordfence or Sucuri, compare files with the originals, sort by modification date and check uploads, wp-config.php, .htaccess and the database. Two different scanners increase the hit rate.

Is it enough to install a security plugin?

No. A plugin can find and partly remove malware, but it does not eliminate the cause. You still have to update, change credentials and close the vulnerability.

How much does it cost to have malware removed?

At Boudmedia, our complete emergency recovery service costs a flat rate of $539—regardless of how extensive the infection is.

Can malware come back after removal?

Yes, if a backdoor is left over or the vulnerability stays open. That is why replacing all files, changing passwords and updating are mandatory.

Do I have to delete plugins completely?

If you reload them fresh from the official directory, yes. Replacing is safer than repairing individual infected files.

How long does the removal take?

For a small site one to two hours, for complex cases a day or longer. The Google review then usually takes a few days.

Is my Google ranking lost?

No, after the cleanup and the review request it usually comes back. The longer the malware was active, the longer it takes.

What if I have no backup?

Then you clean manually, as described above. Create a backup immediately afterwards so you are not left without one next time.

Can I remove malware with one click?

Some plugins offer a repair with one click. That can help with simple infections. For backdoors and database spam it is often not enough. Always check manually afterwards.

How do I know which files are infected?

Comparing with the original files from wordpress.org and sorting by modification date are the fastest ways. Scanners also name concrete findings.

Amine Boudounite

About the author

Amine Boudounite

Amin is the founder of Boudmedia and builds WordPress websites, online shops and business sites. In his guides he explains technology, loading speed and visibility so that you can apply them without any prior knowledge.

Contents
Help with your WordPress site?

We take a free look and tell you honestly what is needed and what it costs.

Share post

You might also be interested in

WordPress Backend Slow? How to Speed Up the Dashboard

Wenn das WordPress-Dashboard träge ist: Ursachen und Maßnahmen im Überblick.

Finding and Fixing a WordPress Plugin Conflict

So findest du den Plugin-Konflikt in WordPress und löst ihn ohne Datenverlust.

Google Shopping with WooCommerce: How to Make Your Feed Error-Free

Wie ein sauberer Produktfeed für Google Shopping aussieht und welche Fehler du in WooCommerce vermeiden kannst.

Problems with your WordPress site? We fix them at a fixed price.

  • Free check of your site
  • Honest assessment of what is needed
  • Fixed price before we start
  • Reply within 24 hours on business days
Scroll to Top