Your website got hacked: a step-by-step recovery plan
Take the site offline, change every password, find how they got in, restore a clean copy, patch the hole, then ask Google to review. In that order.
By Sohail Hussain21 November 20265 min read
If your website has been hacked, work in this order: record what you see, take the site offline, change every password, find out how the attacker got in, restore a clean copy or clean the site, close the hole, then ask Google to review it. The order matters. Restoring a backup before you know how they got in usually means being hacked again within days, and changing passwords after a clean-up leaves the attacker a way back.
The steps below apply to any platform, but most of the hacked sites we are asked to recover run WordPress with outdated plugins. If that is you, WordPress site hacked adds the platform-specific detail.
How do you know your site has been hacked?
Some hacks are obvious. Most are designed not to be. Common signs:
- Google shows "This site may be hacked" under your listing, or Chrome shows a red warning page.
- Search Console's Security Issues report lists a problem, or Google emails the site owner.
- A search for
site:yourdomain.comshows pages you never made, often in Japanese or selling pharmaceuticals. - Visitors from Google or on mobile are redirected to another site, while you see nothing wrong when you type the address directly.
- Admin users you do not recognise appear in the CMS.
- The host suspends the account for sending spam or using too many resources.
- Email from your domain starts bouncing because the server's address has been blacklisted.
The redirect trick is why owners miss hacks for months. The malicious code checks where the visitor came from and leaves the owner alone.
What should you do in the first hour?
Record what you see. Screenshots of warnings, the strange URLs, the date and time. Do not delete anything yet. The infected files and logs are the evidence that shows how the attacker got in.
Take the site offline. Turn on maintenance mode, or ask the host to suspend the site or block public traffic. This protects visitors and stops the spam spreading further in search results.
Change every password and revoke access. Hosting, CMS admin, FTP or SFTP, database, registrar, DNS host and the email accounts tied to them. Log out all sessions, remove any admin user you do not recognise, and turn on two-factor authentication. Use long unique passwords from the password generator, stored in a password manager, not reused from anything else.
Tell your host. Many hosts have a security team, and some will scan the account or restore from their own backups. They also need to know if your site is attacking others.
If you need a team to take this on, our website care and maintenance service recovers hacked sites, including ones we did not build, and then keeps them patched so it does not recur.
How do you find out how they got in?
This is the step most clean-ups skip, and the reason many sites are reinfected. Look at:
- Outdated plugins, themes or platform versions. Check each against its latest release. A plugin with a publicly known flaw is the usual entry point on WordPress.
- Nulled or pirated themes and plugins, which often ship with a backdoor built in.
- Weak or reused passwords, especially on admin and FTP accounts.
- Server access logs around the time the first strange file appeared. Look for repeated requests to one file, or uploads to unusual paths.
- Recently modified files. Your host or developer can list files changed in the last few weeks; malicious files often have innocent names.
- File permissions that let the web server write to places it should not. The usual WordPress guidance is 755 for folders and 644 for files, with
wp-config.phptighter still. The chmod calculator translates between the number and what it allows.
Should you restore a backup, clean the site, or rebuild?
| Option | When it fits | Risk |
|---|---|---|
| Restore from backup | You have a backup from before the infection and you know the entry point | Losing content added since the backup |
| Clean in place | No clean backup exists, and the site is worth keeping | Missing one backdoor means reinfection |
| Rebuild | Repeated hacks, unsupported software, or no clean backup and a dated site | Cost and time, though often less than repeated clean-ups |
Retention decides which options you have. A site with 30 days of backups can often go back to before the infection; a site with three days usually cannot, because the hack started earlier than anyone noticed. Website backups: what good looks like covers how much to keep.
Whichever route you take, finish by updating everything, deleting unused plugins and themes, and changing the passwords again once the site is clean.
How do you get Google to trust the site again?
Open the Security Issues report in Search Console. It lists what Google found and sample URLs. Fix the problem across the whole site, not only on the sample pages; Google does not lift warnings for a partial clean-up.
Then select Request Review and describe what you fixed, including how the attacker got in and what you changed. Google says reviews for malware take a few days, and reviews for spam hacks can take several weeks.
For spam pages the attacker created, make sure those URLs now return a 404 or 410 status, not a redirect to your homepage. Resubmit your sitemap so Google recrawls the real pages. Do not ask for a mass removal of URLs unless the pages are causing real harm in results; they drop out naturally once they return 404.
Who do you need to tell?
If personal data was stored on the site, such as form submissions, customer accounts or orders, you may have legal duties to report the incident. The rules depend on where you and your customers are:
- India. CERT-In's 2022 directions require organisations to report listed cyber incidents, which include website intrusions and defacement, within six hours of noticing them. Under the DPDP Rules 2025, breach notification to the Data Protection Board and affected people applies once those obligations come into force, expected in May 2027.
- EU and UK. Under the GDPR, a breach affecting personal data generally has to be reported to the supervisory authority within 72 hours, and to the people affected if the risk to them is high.
- Card payments. If card data could have been exposed, tell your payment provider immediately.
These are summaries, not legal advice. Check what applies to you with your lawyer the same day; the deadlines are short.
Once the site is clean, the job is to make sure it stays that way: updates on a schedule, backups that go back far enough, monitoring that tells you within minutes, and someone responsible for all three. The website maintenance guide sets out that routine, and WordPress security covers the measures that stop most attacks on that platform.
Was this guide useful?