How can a customer open your website and land on a gambling site, while you open it on your computer and see your normal site? It happens a lot. Today’s hacks are built so the site owner won’t notice: the redirect only fires on phones, only for people coming from Google, or only once per visitor. And some hacks don’t touch what visitors see at all. They add thousands of spam pages to the site, or links that only Google notices.
Last week we cleaned up a site like that. At the bottom of every page, in tiny type, sat eight links to gambling sites. Inside the site was code that let whoever planted it swap the links remotely, and the user list held two administrators that had been created five months earlier. Nobody at the business knew. The attacker most likely got in through an old maps plugin that had never been updated.
So here’s how we handle it, in order: four steps for the first hour, to stop the damage, and four for the days after, to clean the site and make sure the attacker doesn’t come back. The examples are from WordPress, because most small business sites run on it, but most of the steps apply to any site.
How to tell your site was hacked
Sometimes it’s obvious: you open the homepage and find a message from the attacker. Most of the time the signs are smaller:
Visitors tell you the site sent them to another site, usually when they came in on their phone.
Chrome shows a red screen in front of the site warning that it’s dangerous.
Google shows pages from your site that you never wrote, sometimes in Japanese, sometimes about gambling or pharmaceuticals. Search Google for site: followed by your domain and go through the results.
A message is waiting in Search Console’s “Security issues” report.
The site’s user list has an administrator none of you created.
Your hosting company writes that the site is sending spam, or it has already suspended it.
The site suddenly got slow, without you adding anything.
Any one of these is enough to start acting. Don’t wait for a second one.
The first hour: stop the damage
Save a copy of the site as it is, hacked
The first impulse is to wipe everything and restore. Before that, take a full backup of the files and the database, exactly as they are now. That copy is how you’ll later figure out how the attacker got in and what they left behind. Without it, you’re guessing. Keep it off the site’s server, and never restore from it.
Change every password, not just WordPress
That means the site’s administrators, the hosting control panel, FTP and the database. And also the email inbox connected to the admin account. If the attacker can read that inbox, they’ll reset every password you change. While you’re at it, turn on two-factor authentication everywhere it’s offered. One more thing most people don’t know about: the wp-config.php file holds security keys (salts). When you change them, everyone currently logged in to the site is logged out, including the attacker, if they’re still inside.
Go through the user list
Delete every administrator you don’t recognize. WordPress will ask who should get their content; assign it to yourselves. Be especially suspicious of usernames that look like a serial number and of odd email addresses, for example one ending in localhost. Then check who has access to Search Console. Attackers sometimes add themselves there as owners of the site, so they can submit their own sitemap with the spam pages to Google.
Decide whether to take the site offline
If the site sends visitors to a malicious site or tries to download files onto their devices, put it in maintenance mode until it’s clean. Every such visit hurts the visitor, and their trust in you. If the hack is spam links or hidden pages, you can usually keep the site live while you clean it. Either way, call your hosting company. They have logs showing when and from where the attacker got in, and sometimes a backup from before the hack.
The days after: clean up and close the door
Find out when it started, and restore only from a clean backup
Restoring from a backup is a good, fast fix, as long as the backup predates the hack. That’s the catch. On the site we described at the start, the fake administrators were created five months before anyone noticed. A backup from a month earlier would have brought the hack right back. So first you look for the date: when the unknown user was created, when the suspicious files changed, what the logs show. No backup from before that date? Clean it by hand.
Look for what the attacker left behind to get back in
An attacker who knows what they’re doing leaves themselves a back door. Where does it hide? A small PHP file in the uploads folder (wp-content/uploads), which should only hold images and documents. A plugin in the mu-plugins folder that doesn’t show up in the regular plugin list. New lines in .htaccess or wp-config.php. A scheduled task that puts the malicious code back after you delete it. A security scanner like Wordfence or Sucuri finds most of these. What it misses, you find by comparing the WordPress, theme and plugin files against their original copies.
Close the hole they came in through
You cleaned up, but the hole is still open? Within a few weeks you’ll be right back where you started. On most of the sites that come to us, the attacker got in through a plugin or theme that wasn’t updated, through a pirated copy of a paid plugin someone downloaded from an unofficial site, or through a weak password. So update WordPress, the theme and every plugin. Delete plugins you don’t use, even if they’re deactivated. And replace any plugin whose developer has stopped updating it.
Tell Google the site is clean
First check what Google sees. Some hacks show the spam only to Google, so run URL Inspection in Search Console on the homepage and a few inner pages, and make sure the code Google received is clean. If Google detected the hack, you’ll find it in the “Security issues” report. That’s where you send a review request (Request review), with a few lines on what you found and what you fixed. The answer usually comes within a few days, and for spam hacks sometimes only after a few weeks. Delete the spam pages themselves, so each of those URLs shows a 404 or 410 page, and over time Google drops them from the results. The urgent ones can be hidden faster with the Removals tool. And if the site disappeared from the results altogether, we wrote about what to check when your site isn’t showing up on Google.
Think your site has been hacked?
We’ll check it and tell you what we found and what needs fixing so it doesn’t happen again. Leave your details.
How to keep it from happening again
No site is impossible to hack. But you can make it much harder for whoever tries. Most hacks of small business sites aren’t personal. They’re bots that scan millions of sites looking for one old plugin or one easy password. A business website with five pages and one form gets hacked just like a big online store. The bot doesn’t care how much the site earns. What stops most of them:
Regular updates to WordPress, the theme and the plugins, and a check that the site works after each update.
Two-factor authentication for everyone with admin access, and a separate user for each person. No single password that everyone knows.
A daily backup stored off the site’s server, going back several weeks, not just a day or two.
An alert when a file on the site changes, when a new administrator is created, or when a new message appears in Search Console.
You can do most of this yourself. If you’d rather not have to remember, hand it over to ongoing maintenance, or add automated monitoring that checks the site every day and alerts you the moment something changes.
What people ask us after a hack
The site works fine. Wouldn’t it be better to leave it alone?
No. A hacked site that looks normal is still working for someone else. It can send spam from your server until your business emails start landing in your customers’ spam folders. It can push other people’s sites up in Google at the expense of your reputation. And once Google detects the hack, visitors may see a warning screen before they enter the site.
I restored from a backup and the hack came back a week later. Why?
Almost always for one of two reasons. Either the backup was already infected, because the hack started before it was saved, or the hole the attacker came in through is still open, for example a plugin that wasn’t updated. A restore brings back files; it doesn’t close holes. So first find out when the hack started and find the hole (steps 5 to 7), and only then decide whether to restore.
Do I need to rebuild the site?
Usually not. A thorough cleanup and an update are enough. You rebuild only when the site is very old: a WordPress version that hasn’t been updated in years, a theme its developer abandoned, and plugins that no longer exist. On a site like that every update breaks something, so people stop updating, and the site stays exposed to the next hack. In that situation, building a new website can turn out cheaper than maintaining the old one.
I dropped in Google because of the hack. Will I get my position back?
In most cases yes, gradually. Once the site is clean, the warning is removed and the spam pages are out of the index, Google goes back to ranking your real pages. It takes weeks, sometimes longer, and there’s no way to speed it up beyond what we described in step 8. What does help is checking in Search Console that your important pages are being recrawled and carry no leftovers of the code.
