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.
| Symptom | Likely type | First check |
|---|---|---|
| Spam pages for pharmaceuticals, gambling or counterfeit goods in search results | URL 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 mobile | Code injection, often in .htaccess or theme files | Fetch the page with a command line client as a search referrer and as a normal visitor |
| Red full-page warning in Chrome or Edge | Malware, phishing or harmful downloads | Security Issues report; Edge block page details |
| Changed home page or messages from the attacker | Defacement | Hosting file change times; admin account list |
| Hosting provider suspends the account for abuse or spam mail | Mailer scripts or a web shell | Provider's abuse report; outbound mail logs |
- Assemble help: the site owner, whoever has hosting and domain access, and a developer or security provider if you have one.
- 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.
- 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.
- 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
.htaccessand.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
| Approach | When it fits | Risks |
|---|---|---|
| Restore from a clean backup | You have a backup from before the compromise and know roughly when it began | Backup 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 content | No trusted backup, or the infection is old or widespread | Takes longest; database content must still be checked |
| Clean in place | Small, well understood infection with a known cause | Easy 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.iniandphp.inioverrides. - Template files:
index.php,header.php,footer.phpandfunctions.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.
| Credential | Action | Notes |
|---|---|---|
| CMS user accounts | Force a password reset for all users, especially administrators; delete unknown accounts | Add multi-factor authentication for every administrator |
| CMS secret keys and salts | Generate new values (WordPress offers a key generator) and replace them in wp-config.php | Logs out every existing session, including the attacker's |
| Hosting control panel | New password and multi-factor authentication; review other users | cPanel, Plesk or the provider's own panel |
| FTP, SFTP and SSH | New passwords; replace SSH keys; remove unused accounts; prefer SFTP over FTP | Includes accounts held by former developers or agencies |
| Database user | New user or password, updated in the CMS configuration | The configuration file was readable to the attacker |
| API keys and tokens in the site | Revoke and reissue payment gateway, email delivery, maps, cloud storage and backup keys | Any key in site files or the database should be treated as exposed |
| Domain registrar and DNS | New password, multi-factor authentication, registrar lock; check DNS records | If 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.
| Warning | Where to request review | Typical processing time stated by the provider |
|---|---|---|
| Google: hacked with spam | Search Console Security Issues report, Request Review | Up to several weeks |
| Google: malware or unwanted software | Security Issues report, Request Review | A few days |
| Google: phishing or deceptive pages | Security Issues report, or the Safe Browsing error report form | About a day |
| Microsoft Defender SmartScreen (Edge) | The block page link "Report that this site doesn't contain threats", or the Microsoft security intelligence submission portal | Not 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
| Framework | Reference | Where it applies |
|---|---|---|
| NIST CSF 2.0 | RS.MI-01; RC.RP-01 | Containment; executing recovery |
| NIST SP 800-53 Rev 5 | IR-4 Incident Handling; SI-3 Malicious Code Protection; CP-10 System Recovery and Reconstitution | Handling, cleaning and rebuilding the site |
| MITRE ATT&CK v20 | T1190 Exploit Public-Facing Application; T1505.003 Web Shell; T1491.002 External Defacement; T1608.004 Drive-by Target | Common 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
- Google Search Console Help: Security issues report
- Google web.dev: Request a review
- Microsoft Learn: Unexpected Microsoft Defender SmartScreen block warning
- WordPress: FAQ My site was hacked
- ICO: Personal data breach self-assessment
- OWASP: Top 10 Web Application Security Risks
Related NHI Mgmt Group resources: Small Business Website Security Guide · Website Defacement Playbook · WordPress Security Checklist · Web Shell Response Playbook