
In this article
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
- Google or your browser shows a warning such as "This site may be hacked" or "Deceptive site ahead".
- Visitors are redirected to other sites, especially when they arrive from Google or on a phone.
- Search results show pills, casino or loan pages under your name.
- Your host suspends the account, or you receive an abuse report.
- New admin users, unknown files or sudden slowdowns appear.
Not sure? Run a free outside scan, then read how to check if your website is hacked.
Step 1: stay calm and contain it
- Take a copy of the infected site (files and database) for later investigation. Do not overwrite it.
- Put the site in maintenance mode, or limit access, so visitors are not exposed and attackers cannot keep changing things.
- 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:
- Site admin and all user accounts with high privileges.
- Hosting control panel, FTP/SFTP and SSH.
- Database password, and the keys and salts in your configuration.
- Email accounts, domain registrar and any API keys or payment settings.
Turn on two-factor login as you go.
Step 3: find the malware
- Compare against clean copies. Re-download your platform's core files, themes and plugins from the official source and compare them with what is on the server. Anything that differs, or is extra, is suspect.
- Look for recently changed files. Sort by modification date and check files changed around the time the trouble began.
- Search for suspicious code. Functions such as
eval(,base64_decodeandgzinflateare used by many legitimate programs, so treat a match as a lead, not proof. - Check uploads and cache folders. Script files in folders meant for images are a classic sign.
- Check the database. Look for injected scripts in posts, options and widgets, and for admin users you did not create.
- Look for hidden spam and cloaking. See how to find hidden spam links and what cloaking is.
Step 4: clean it up
- 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.
- Otherwise replace, do not edit. Delete the platform core, themes and plugins and install fresh copies, then clean your own content and uploads.
- Remove backdoors. Delete unknown files, unused plugins and themes, rogue admin users and scheduled tasks you did not create.
- 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:
- An outdated plugin, theme or platform is the most common entry point. Update everything.
- Weak or leaked passwords. Check login security.
- Exposed files such as backups and configuration. Read about exposed .env and .git files.
- Other sites on the same shared server. Ask your host about isolation.
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
- Keep software updated and delete what you do not use.
- Use strong, unique passwords and two-factor login.
- Keep tested, off-server backups.
- Scan your site on a schedule and monitor for changes.
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
- Website malware scanner: Spam links, malicious scripts, cloaking, bad redirects and exposed backups.
- Security headers checker: Grade HSTS, CSP, clickjacking and referrer headers, with fixes to copy.
- Free website check: Security, SEO and speed in about 30 seconds.
