Blog / Rescue

Your website has been hacked. What to do in the first 48 hours

Spam pages in Google, visitors redirected to somewhere else, and a restored backup that did not fix it. The ordered version: contain, clean, verify, tell Google, then close the door they came in through.

Someone has told you your site is showing pages you did not write. Or you searched for your own business and found listings for products you do not sell. Or the site looks completely normal to you and customers say it sent them somewhere else. Your website has been hacked, you restored a backup, felt relieved for a day, and it came back.

The backup did not fix it because a backup restores the damage, not the door. Whoever got in almost certainly left a way back: an extra administrator account, a file that looks like part of your site, a scheduled task, a modified plugin. Restore the site and the door restores with it. So the order that works is contain, clean, verify, tell Google, and only then close the entry point, and doing those in a different order is why people spend three weeks on a job that takes two days.

Your website was hacked and the backup did not fix it. Here is why

There are three common reasons, and it is usually worth knowing which one you have before you do anything else.

  • The backup contains the break-in. If the site was compromised weeks ago and you restored last night's copy, you restored the compromise. Most of these sit quietly for a while before they start publishing.
  • The way in is still open. An out-of-date plugin with a known vulnerability, a weak administrator password, a stolen hosting login. Restoring files changes none of those, so within hours you are back where you started.
  • They left something outside the site. A scheduled task on the server, a file in a directory your backup does not cover, a database entry rather than a file. Whole categories of persistence survive a file restore untouched.

Which is why the reinfection is not bad luck and not your fault. It is the predictable result of treating a security incident as a broken file.

The first hour: contain

  1. Take a copy of everything as it is now, files and database, before you change anything. It is evidence, it is how anyone works out what happened, and you may need to compare against it later. Store it somewhere separate.
  2. Change the passwords that matter, starting outside the site. The hosting control panel first, then the domain registrar, then the database, then every site administrator, then the email account those accounts recover to. Doing the site first and the hosting later is a common and expensive order.
  3. Turn on two-factor authentication where it exists, particularly on hosting and the registrar.
  4. Force everyone out. Most systems have a way to invalidate existing sessions or rotate the keys that keep people signed in. If you skip this, an attacker who was already logged in stays logged in, and your password change achieves nothing.
  5. Decide about taking the site down. If it is serving malware to visitors or handling payments, put up a holding page while you work. If it is a brochure site quietly hosting spam, leaving it up while you clean usually costs less than the downtime.
  6. Tell your host. They deal with this constantly, many include a malware clean-up in the plan you already pay for, and they can see things from the server side that you cannot.

The first day: clean, then verify

Cleaning means removing everything they added and replacing everything they altered. In practice, on a typical content-managed site, that is:

  • Replace the core software and every plugin and theme with fresh copies from the original source rather than repairing the files in place. Anything no longer maintained or no longer used gets deleted, not disabled, because a deactivated plugin is still a file on your server that can still be reached.
  • Hunt the persistence. Unknown administrator accounts, unfamiliar scheduled tasks, files whose modification date sits on the day of the break-in, code injected into the database, and anything added to the files that control redirects and server behaviour.
  • Look at the uploads folder properly. It is meant to hold images and documents. Anything in there that can execute is not supposed to be there.
  • Scan from two directions. A security plugin from inside gives you file-level detail, and an external scanner visiting your public pages sees what a visitor sees, including redirects that only fire for people arriving from search. Neither alone is sufficient.
  • Then verify like a stranger. Visit from a phone on mobile data, from a Google result, and in a private window. If your host can show you access logs, look for the requests that arrived just before the first spam page appeared.

If your site is large, or if the same infection has already returned once, this is the point where an hour of somebody who does this professionally is cheaper than another fortnight of your evenings. It is what our security and updates work exists for. If the person who built the site has also stopped answering, our guide to recovering a website when a developer disappears covers that half of the problem.

This is the part most guides skip, and it is the part that decides whether your business gets its search traffic back. A cleaned site with a thousand spam pages still in Google's index is still a hacked site as far as your customers are concerned.

  1. Make the fake pages return a proper error. They should answer with 404, or better with 410, which tells search engines the page is deliberately gone. Redirecting them all to your homepage looks tidy and slows the clean-up down.
  2. Check Search Console for a security notice. If Google has flagged the site, there will be a message with example URLs, and those examples are the fastest map of the infection you will get.
  3. Request a review once you are genuinely clean, describing what you found and what you did. Malware warnings are often lifted within a day or two; other categories can take a couple of weeks.
  4. Use the removal tool for the worst offenders. It hides pages from results quickly while the permanent fix works through, which matters if the spam is embarrassing or is being seen by customers.
  5. Resubmit a clean sitemap, and then watch the index shrink over the following weeks rather than checking hourly.
  6. Keep watching for a month. Search your own site with the site: operator once a week. New spam appearing is not a new attack; it means the door is still open.

Finding how they got in

If you skip this, you will be doing all of the above again. In the overwhelming majority of small business sites, the answer is one of five things:

  • An out-of-date plugin, theme or core version with a publicly known vulnerability. This is the most common answer by a wide margin, and the least interesting.
  • A weak or reused password, on the site, the hosting or the email account those recover to.
  • A compromised computer. If the machine you edit the site from is infected, your saved credentials went with it, and cleaning the server changes nothing.
  • A shared hosting neighbour. On cheap shared plans, a compromise of another site on the same server can reach yours. If your host has a habit of this, that is a reason to move rather than to keep cleaning.
  • An old account nobody removed. The developer from four years ago, the marketing agency you stopped using, the plugin you trialled once.

Making it much less likely to happen again

  • Updates applied on a schedule, by someone whose job it is. Almost every one of these begins with a patch that existed and was not applied.
  • Fewer plugins. Every one is a door. Delete what you do not use rather than deactivating it.
  • Two-factor authentication and unique passwords on hosting, registrar, site and the recovery email.
  • Backups you keep somewhere else, with a retention long enough to reach back past a slow-burning compromise, and at least one restore you have actually tested.
  • Monitoring that tells you, rather than a customer telling you. Uptime checks, file-change alerts and a weekly external scan cost very little and change the story from three weeks of spam to one afternoon, which is most of what always-on monitoring is for.

Not for you if

What this costs

For a straightforward infection on a small site, a professional clean is illustratively a few hundred dollars, and your host may do it for nothing. Where it grows is reinfection, a compromised database, a large store, or search recovery after a long infection: illustratively $800 to $4,000, most of it in the careful verification rather than the deleting. Ongoing care that makes a repeat unlikely is a modest monthly figure, and it is worth comparing honestly against what a fortnight of spam in your search results costs a business like yours.

One last thing, because people are often embarrassed to be in this situation and it slows them down. Almost nobody is hacked because they were careless. They are hacked because a plugin they trusted had a hole in it and nobody was watching. What matters now is the order you work in, and you have it.

Also asked

Questions that usually follow

My WordPress site was hacked and restoring the backup did not fix it. Why?

Because a backup restores the damage, not the way in. Either the backup already contained the compromise, or the entry point (an out-of-date plugin, a weak password, a stolen hosting login) is still open, or the attacker left something a file restore does not touch, such as a scheduled task, a database entry or an extra administrator account. Clean the site, remove the persistence, and close the entry point, in that order, or it will come back within days.

Google is showing spam pages from my site. How do I get rid of them?

Make the fake pages return a 404 or, better, a 410 so search engines know they are deliberately gone rather than redirecting them to your homepage. Check Search Console for a security notice and use its example URLs as a map of the infection. Once the site is genuinely clean, request a review describing what you found and fixed, use the removal tool to hide the worst pages quickly, and resubmit a clean sitemap. Malware warnings often lift within a day or two; the index shrinks over the following weeks.

My site looks fine to me but visitors say it redirects them. What is happening?

That is a deliberate feature of the attack, not a coincidence. Many of these infections show the clean site to anyone who looks like the owner, someone typing the address directly, on a desktop, while logged in, and show the spam or the redirect to people arriving from a search result on a phone. Test the way a stranger would: mobile data, from a Google result, in a private window.

There are administrator accounts on my site that I did not create. What do I do?

Treat it as a confirmed compromise rather than something to simply delete. Take a full copy first, change the hosting, registrar and database passwords before touching the site accounts, force all existing sessions to expire, and only then remove the unknown accounts. Deleting them on their own achieves very little, because whoever created one can create another until the way in is closed.

How much does it cost to clean a hacked website?

Often nothing beyond what you already pay, because many hosting plans include malware clean-up, and that is worth asking before hiring anyone. For a professional clean on a small site, illustratively a few hundred dollars. It rises to illustratively $800 to $4,000 where the site has already been reinfected, the database is involved, it is a store handling payments, or a long infection means recovering the search results is now the larger job.

Will being hacked hurt my search rankings permanently?

Usually not permanently, but it does real damage while it lasts, and the damage keeps compounding until the spam is out of the index and any warning is lifted. Sites that are cleaned quickly and properly, with the fake pages returning 410 and a review requested, generally recover. The ones that struggle are those cleaned repeatedly without closing the entry point, because each reinfection restarts the clock.

Should I just rebuild the site from scratch?

Sometimes, and it is worth pricing honestly rather than assuming. Rebuilding is often the right call when the site was already old and unmaintained, when the infection has been present for a long time, or when nobody can be confident the clean-up was complete. It is not a shortcut around the important part: if you rebuild and restore the same content, same plugins and same passwords onto the same hosting, you have rebuilt the entry point too.

Next step

If it is happening right now, send us the URL

Tell us the address and what you are seeing. We will confirm what has actually been compromised, what is already in Google's index, and what it would take to clean and close it. Same-day where we can.

See Security & recovery Start the conversation