Blog · 8 min read

How to remove malware from a website, step by step

Published

How to remove malware from a website, step by step

Finding malware on your website is stressful, but it is fixable. The order of the steps matters: contain the damage first, find how the attacker got in, clean everything, and only then bring the site back. Skipping the middle steps is why so many sites are reinfected within days.

This guide applies to any platform, whether your site runs on WordPress, Joomla, Drupal, Magento, a hosted builder or custom code. Where a step is specific to one kind of site, the same idea applies elsewhere. It is general guidance. If customer data may be involved, ask a security professional and check which breach-notification rules apply to you.

Signs your site has malware

Not sure? Run a free outside scan, then read how to check if your website is hacked.

Step 1: stay calm and contain it

  1. Take a copy of the infected site (files and database) for later investigation. Do not overwrite it.
  2. Put the site in maintenance mode, or limit access, so visitors are not exposed and attackers cannot keep changing things.
  3. Tell your host. Many can see logs, scan the server and tell you when the infection started.

Step 2: change every password and key

Change them from a clean computer, not the one you normally use if it might be infected. That means:

Turn on two-factor login as you go.

Step 3: find the malware

Step 4: clean it up

  1. Restore from a clean backup if you have one taken before the infection, as described in our website backup guide. This is often faster and safer than cleaning by hand.
  2. Otherwise replace, do not edit. Delete the platform core, themes and plugins and install fresh copies, then clean your own content and uploads.
  3. Remove backdoors. Delete unknown files, unused plugins and themes, rogue admin users and scheduled tasks you did not create.
  4. Clean the database of injected code, then reset any secret keys.

Step 5: close the way in

If you only clean, the attacker walks back in. Find the cause:

Step 6: verify it is clean

Scan again from the outside with the malware scanner. Check your site from a phone, from a Google search result and in a private window, since some malware only shows itself to certain visitors. Look at your security headers and logs for new suspicious activity.

Step 7: get warnings removed

If Google flagged your site, use the Security issues report in Search Console to request a review once it is clean. Follow our guide to removing the "This site may be hacked" warning and set up Search Console if you have not already. Also ask any blacklist or host that flagged you to re-check the site.

Step 8: stop it happening again

Common questions

Can I just delete the one infected file?

Rarely. Malware usually leaves several copies and backdoors, so removing one file lets the rest reinfect the site.

How long does cleanup take?

A small site with a good backup may take hours. A site without one, or with a database infection, can take days.

Should I pay a cleanup service?

If you are not comfortable working with files and databases, or customer data is involved, yes. Cleaning only the visible symptom is the most common reason infections return.

Will Google remove my warning automatically?

Often only after you request a review once the site is clean. The review usually takes a few days.

Free tools for this problem

More guides