Join our Newsletter — 33% off our NHI Course
Home› Guides› How to Clean Up a Hacked Website: Contain,…
Guide Incident Response & Forensics

How to Clean Up a Hacked Website: Contain, Clean, Harden and Get Browser Warnings Removed

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 12 min read
On this page

When a website is hacked, owners usually find out from a red browser warning, a search result labelled as hacked, or a customer complaint, and by then visitors are already being turned away. Cleaning the visible damage is not enough: the attacker's way in, their backdoors and every credential they may have seen must go too, or the site will be reinfected and the warnings will stay. This guide walks through containment, evidence, removal, credential rotation and hardening, then explains how to ask Google and Microsoft to review the site once it is clean. It is written for small business owners and web administrators running a content management system such as WordPress, and for the IT providers who support them. For defacement handled as a formal incident with roles and communications, use the Website Defacement Playbook alongside this guide.

Key takeaways

  • Contain first, clean second. Put the site into maintenance mode or take it offline, tell your hosting provider, and take a snapshot of the infected site before changing anything.
  • Find the way in. An outdated plugin, a stolen admin password or a leaked hosting credential will let the attacker straight back in if you only delete the files you can see.
  • Rotate every credential the site could reveal. CMS users, hosting panel, FTP or SFTP and SSH, database user, CMS secret keys and any API keys stored in the site or its configuration.
  • Restore from a known clean backup when you can. Cleaning in place is slower and riskier; reinstall core, plugins and themes from official sources at the same version either way.
  • Request review only when fully fixed. Google says a premature request extends the time a site stays flagged; after a successful review, warnings are removed within 72 hours.

Confirm and contain

Start by confirming what you are dealing with. The Google Search Console Security Issues report is the source of truth for Google's view of the site: browser warnings depend on context, so you may not be able to reproduce them yourself. It groups problems into hacked content, malware and unwanted software, and social engineering, with specific types including Hacked: Code injection, Hacked: Content injection, Hacked: URL injection, Hacked: Malware, Deceptive pages and Harmful downloads, with sample URLs.

SymptomLikely typeFirst check
Spam pages for pharmaceuticals, gambling or counterfeit goods in search resultsURL or content injection (hacked spam)Security Issues report samples; unknown files and database rows
Visitors redirected to another site, often only from search or on mobileCode injection, often in .htaccess or theme filesFetch the page with a command line client as a search referrer and as a normal visitor
Red full-page warning in Chrome or EdgeMalware, phishing or harmful downloadsSecurity Issues report; Edge block page details
Changed home page or messages from the attackerDefacementHosting file change times; admin account list
Hosting provider suspends the account for abuse or spam mailMailer scripts or a web shellProvider's abuse report; outbound mail logs
  1. Assemble help: the site owner, whoever has hosting and domain access, and a developer or security provider if you have one.
  2. Contact the hosting provider. WordPress's own guidance notes that on shared hosting the hack may have affected more than your site; ask what the host has seen, what they are doing, and what backups they hold.
  3. Stop the harm: put the site into maintenance mode or a static holding page served from outside the compromised files, or have the host take it offline. If customers' payment or login pages are involved, take them offline first.
  4. Freeze changes from other administrators until you have a snapshot.

Preserve evidence

Before you clean, take one more full copy of the infected site. WordPress recommends this snapshot so you have the bad copy to refer to, and it is the only record of what the attacker changed. Keep it offline and never restore from it.

  • Files: a full archive of the web root, including hidden files such as .htaccess and .user.ini.
  • Database: a full export, which holds injected content, rogue admin users and changed settings.
  • Logs: web server access and error logs, hosting control panel login history, FTP or SFTP logs, and CMS audit logs if a plugin records them. Hosts often keep these for only a short time, so ask for them on day one.
  • Timeline: when the problem was noticed, by whom, and the Search Console notice dates and sample URLs.

Decide early whether personal data could have been taken. Under UK GDPR, the ICO says you must notify it if a breach is likely to result in a risk to people's rights and freedoms; GDPR Article 33 sets a deadline of 72 hours after becoming aware, where feasible. Card data or customer logins on the site make notification more likely. For larger incidents follow the Incident Response Guide, and for a deeper evidence process see the Digital Forensics (DFIR) Guide.

Find and remove the compromise

Restore or clean in place

ApproachWhen it fitsRisks
Restore from a clean backupYou have a backup from before the compromise and know roughly when it beganBackup may already contain the backdoor; content added since is lost; the hole is still open until you patch
Rebuild: fresh core, plugins and themes, then import checked contentNo trusted backup, or the infection is old or widespreadTakes longest; database content must still be checked
Clean in placeSmall, well understood infection with a known causeEasy to miss a second backdoor; reinfection is common

Whichever route you take, reinstall the CMS core, plugins and themes from official sources. WordPress advises using the same version the site already runs, copying files over SFTP rather than using the admin dashboard reinstall, because those installers often only overwrite existing files while hacks often add new ones. The /wp-admin and /wp-includes directories can be replaced wholesale; wp-content needs file by file care. Once clean, update to the latest version.

Where attackers hide

  • Server configuration: .htaccess, which WordPress calls the file most often modified for malicious purposes, plus .user.ini and php.ini overrides.
  • Template files: index.php, header.php, footer.php and functions.php, which run on every page request.
  • Uploads folders: PHP or other executable files where only images and documents belong; a web shell here gives the attacker a way back in. See the Web Shell Response Playbook.
  • Database: new administrator accounts, injected scripts in posts, widgets and options, and scheduled tasks.
  • Must-use plugins and drop-ins: code that loads automatically and does not appear in the normal plugin list.
  • Third-party scripts: a tag manager, analytics or chat script changed to load malicious code; the Lottie Player npm compromise showed how a stolen developer token pushed a wallet drainer onto many sites through one script.

Compare file listings and hashes against a clean copy of the same versions, check file modification times against your timeline, and remove anything you cannot account for. Then check pages the way Google does: Google suggests using a command line client such as Wget or cURL to fetch your home page and a URL the attacker modified, and making sure crawlers are not blocked by robots rules or noindex.

Rotate credentials and harden

Rotate after the site is clean, not before, or the attacker may capture the new values. WordPress makes the same point: change passwords again once you are sure the site is clean.

CredentialActionNotes
CMS user accountsForce a password reset for all users, especially administrators; delete unknown accountsAdd multi-factor authentication for every administrator
CMS secret keys and saltsGenerate new values (WordPress offers a key generator) and replace them in wp-config.phpLogs out every existing session, including the attacker's
Hosting control panelNew password and multi-factor authentication; review other userscPanel, Plesk or the provider's own panel
FTP, SFTP and SSHNew passwords; replace SSH keys; remove unused accounts; prefer SFTP over FTPIncludes accounts held by former developers or agencies
Database userNew user or password, updated in the CMS configurationThe configuration file was readable to the attacker
API keys and tokens in the siteRevoke and reissue payment gateway, email delivery, maps, cloud storage and backup keysAny key in site files or the database should be treated as exposed
Domain registrar and DNSNew password, multi-factor authentication, registrar lock; check DNS recordsIf records were changed, follow the DNS Hijack Playbook

API keys and other machine credentials are the item most often forgotten. The Football Australia AWS keys exposure showed how cloud keys embedded in a public web page opened 127 storage buckets; keys like these belong on the server side with the narrowest scope possible.

Harden before going live: remove unused plugins and themes, turn on automatic updates where the CMS supports them, block PHP execution in uploads folders, set file permissions so the web server cannot write to code directories, put a web application firewall in front of the site (see the Web Application Firewall Guide), and confirm off-site backups run and restore. The WordPress Security Checklist covers the full baseline.

Request review from browsers and search engines

Google lists four conditions before you ask: site ownership verified in Search Console, the attacker's changes removed, the vulnerability corrected, and the clean site back online. Fix every issue on every page; partial fixes do not earn a partial return.

WarningWhere to request reviewTypical processing time stated by the provider
Google: hacked with spamSearch Console Security Issues report, Request ReviewUp to several weeks
Google: malware or unwanted softwareSecurity Issues report, Request ReviewA few days
Google: phishing or deceptive pagesSecurity Issues report, or the Safe Browsing error report formAbout a day
Microsoft Defender SmartScreen (Edge)The block page link "Report that this site doesn't contain threats", or the Microsoft security intelligence submission portalNot stated; a confirmation email follows from the SmartScreen Reputation Group
  • What to write: Google asks you to explain the exact issue, the steps taken to fix it and the outcome; for hacked spam, a short explanation per category of spam, for example removed injected pages and updated an outdated plugin.
  • Do not resubmit while a request is pending. Google warns that requesting review before the issue is fixed can lengthen the next turnaround and can mark the site as a repeat offender.
  • If the review fails: the report may show more sample URLs. Go back to the find and remove step rather than resubmitting.
  • Afterwards: once Google finds the site clean, warnings in browsers and search results are removed within 72 hours. For Microsoft, reply to the Reputation Group email if the matter is urgent.

Prevent recurrence

Reinfection is common when something was missed, so monitor closely for at least the first month, then keep a lighter routine.

  • File integrity: alert on new or changed files in code directories and uploads. See the File Integrity Monitoring Guide.
  • Search Console: keep email alerts on and check the Security Issues report and new indexed pages weekly.
  • Admin activity: alert on new administrator accounts and logins from new locations.
  • Uptime and content checks: an external monitor that fetches key pages and alerts on unexpected redirects or changed content.
  • Patching: a weekly window for core, plugin and theme updates, and removal of anything abandoned by its developer.

Metrics that show recovery is holding

  • Days since last Security Issues report finding (target: no new findings).
  • Time from vendor update release to installation on the site.
  • Number of administrator accounts, and number with multi-factor authentication (target: all).
  • Unexpected file changes detected per week after the first month (target: zero).
  • Successful backup restore tests per quarter.

Common failure patterns

  • Deleting the spam, leaving the hole: the vulnerable plugin or stolen password is still there and the site is reinfected within days.
  • Restoring an infected backup: the backdoor predates the visible symptoms, so the restore brings it back.
  • Rotating before cleaning: new passwords and keys are captured by the still-present web shell.
  • Forgetting machine credentials: payment, email and cloud keys in the configuration remain valid and are misused later.
  • Requesting review too early: the failed review lengthens the time the warning stays up.
  • Ignoring the host: on shared hosting, another compromised site on the same server reinfects yours.

Framework mapping

FrameworkReferenceWhere it applies
NIST CSF 2.0RS.MI-01; RC.RP-01Containment; executing recovery
NIST SP 800-53 Rev 5IR-4 Incident Handling; SI-3 Malicious Code Protection; CP-10 System Recovery and ReconstitutionHandling, cleaning and rebuilding the site
MITRE ATT&CK v20T1190 Exploit Public-Facing Application; T1505.003 Web Shell; T1491.002 External Defacement; T1608.004 Drive-by TargetCommon entry, persistence and impact techniques on compromised sites

Practitioner checklist

  • Check the Search Console Security Issues report and note every issue type and sample URL.
  • Contact the hosting provider, put the site into maintenance mode, and freeze changes.
  • Take a full snapshot of files, database and logs before cleaning, and store it offline.
  • Assess whether personal data was exposed and whether regulator notification applies.
  • Restore from a pre-compromise backup or rebuild from official sources; reinstall core, plugins and themes over SFTP.
  • Find and fix the entry point, then remove unknown files, admin users and scheduled tasks.
  • Rotate CMS, hosting, FTP or SSH, database, secret key and API key credentials after cleaning, and turn on multi-factor authentication.
  • Harden: remove unused plugins, block code execution in uploads, add a web application firewall, and test backups.
  • Request review from Google and, if blocked in Edge, from Microsoft, with a clear description of the fix.
  • Monitor file changes, admin accounts and Search Console weekly for at least a month.

Standards and references

Related NHI Mgmt Group resources: Small Business Website Security Guide · Website Defacement Playbook · WordPress Security Checklist · Web Shell Response Playbook

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.