| Security

Your website has been hacked. What to do first.

The instinct is to delete the bad thing and get the site back up. That instinct destroys the evidence of how they got in, which means it happens again next week. Here is the order that actually works, written for the owner rather than for whoever ends up doing the technical part.

If you are reading this during the event: nothing here needs to be done in the next five minutes except taking the site offline. Everything else goes better slowly. The most expensive mistakes in a website hack are all made in the first hour, in a hurry, with good intentions.

First, confirm it is real

A surprising number of emergencies are not one. Before anything else, rule out the ordinary explanations:

  • An expired SSL certificate produces a full-page browser warning that reads, to most people, exactly like a hacked site. Check the renewal date first.
  • A plugin or theme update gone wrong can blank a site or scramble a layout. If it broke immediately after an update, that is almost certainly what it is.
  • A domain or hosting bill that was not paid will take a site down or park it on an advert.
  • An email claiming you have been hacked, demanding payment, with no evidence beyond an old password from somebody else’s breach, is a mass-sent scam. Check the site before you believe the email.

Real signs are different: pages you did not write, visitors from Google being redirected while you see nothing wrong, a Google warning in search results, your host suspending the account, or administrator users you do not recognise.

The first hour, in order

01

Put the site into maintenance mode

Not deleted, not reverted - offline, behind a holding page. This stops visitors being harmed, stops Google indexing more of it, and stops the damage growing while you work.

02

Write down what you can see

Screenshots, the exact addresses of any bad pages, the time you noticed, what first made you suspicious. In an hour you will have changed things and this will be the only record of how it started.

03

Call your host before you change anything

They see this daily, they hold the server logs that say when and how it began, and they know which backups exist from before the infection. Changing files first makes their logs harder to read.

04

Work from a computer you trust

If the first thing compromised was your own laptop, every password you type into it now is also taken. If there is any doubt, use a different machine.

05

Change the passwords, in the right order

Email first, because it can reset everything else. Then hosting, then CMS admins, then FTP and SFTP, then the database. Any password used in two places is now gone in both.

06

Check your email account itself

New forwarding rules, unfamiliar signed-in sessions, a changed recovery address. A quiet forwarding rule outlasts every password you just changed, and almost nobody looks.

The first hour after a website is hacked: take it offline, record what you see, call the host, change passwords in order
The order matters more than the speed. Everything here is reversible; deleting the evidence is not.

Do not delete anything yet

This is the single most common mistake and the reason sites get hacked twice.

The files the attacker left are the only record of how they got in. Delete them in a hurry and you have removed the symptom and kept the cause: the out-of-date plugin, the open account, the form that accepted too much. All of it is still there, and the same automated scan that found you in March will find you again in April.

Taking the site offline already protects your visitors. That buys you the time to find out what happened before you clean it. Keep a copy of the infected site - all of it - before anybody starts removing things.

Why restoring a backup is not the fix

Restoring a clean backup is usually the fastest way to get a working site back, and it is worth doing. It is not a repair, for three reasons people discover one at a time:

  • It restores the hole as well. The backup contains the same out-of-date plugin that was the way in. You have put the site back exactly as it was on the day it was broken into.
  • You may not know how far back clean is. Quiet infections sit for months. A backup from last week can be infected too, and restoring it just resets the clock.
  • You lose everything since. Orders, enquiries, new pages, comments. On a shop, that is real money and real customers.

So the order is: restore if it helps, then immediately update everything, then close the way in. A restore that is not followed by those two steps is a countdown.

Finding the way in

Somebody technical has to do this part, but you should know what they are looking for, because it determines whether you are paying for a repair or a rinse:

  1. The server access logs, around the time the first strange file appeared. This usually names the address and the page that was used.
  2. File modification dates. Everything changed within a few minutes of each other, on a date when nobody was working, is the event.
  3. The list of installed plugins and themes with their versions, checked against the published flaws for each. This is where the answer is found most often.
  4. The user list, for administrators created around that date - and the SSH keys and FTP accounts, where an old one may simply have been used.
  5. Scheduled tasks, which are how a site reinfects itself at 3am after being cleaned.
What to ask whoever cleans it. One question settles it: how did they get in? If the answer is a specific plugin, version and date, the job was done properly. If the answer is "we removed the malware", the hole is still open and you should expect to be back here.

Cleaning, and being sure it is clean

Automated scanners are good at the obvious files and poor at the thing that matters: the backdoor. A backdoor is a small, innocuous-looking file whose only job is to let the attacker back in after everything else has been tidied up. They are deliberately written to resemble ordinary site files, and they are often placed several of them, in different folders, precisely so that removing one changes nothing.

A site is clean when all of these are true, and not before:

The way in is named and closed

A specific plugin, version, account or form - and the update or removal that closes it, done.

Everything is on a current version

CMS, plugins, themes and PHP. Anything no longer maintained removed rather than updated.

Every credential is new

Including the database password and any API keys, which are the two people forget.

The site still works

Forms arriving, checkout completing, emails sending, logins working. A clean site that does not take enquiries is not recovered.

Getting the Google warning removed

If Google flagged the site, fixing it does not unflag it. Open Search Console, find the Security Issues report, and request a review once the site is genuinely clean. Requesting it too early is worse than waiting: a failed review takes longer the second time.

If hidden spam pages were indexed, they need to be dealt with as well. Let them return a proper "gone" response rather than redirecting them all to the homepage, which looks to Google like one more thing being hidden. Recovery of rankings is usually weeks rather than days, and it is faster the sooner the review is requested.

If customer data may have been exposed

This stops being a technical question and becomes a legal one. If your site holds customer accounts, orders or any personal information and there is a real chance it was reached, you may have a duty to notify - under the GDPR if you have UK or EU customers, and under state law in much of the US, often within a fixed number of days.

We are not lawyers and this is not legal advice; for anything involving customer data, take some. What we would say from the practical side is that the businesses that come out of this well are the ones that said so early and plainly. The ones that are still dealing with it a year later are the ones that hoped nobody would notice.

The week after

Once the site is back, three things are worth doing while it is still fresh enough to bother:

  • Shorten the access list. Old developers, dead FTP accounts, staff who have left. This is the cheapest hour you will spend and it is a short job.
  • Put updates on a date. Monthly, in the calendar, with somebody’s name against it - yours or ours. Out-of-date software is the largest single category in every published dataset.
  • Test a restore. Not take a backup - restore one, somewhere harmless, and confirm it works. You now know exactly how much that is worth.

And if you are in the middle of this right now and would rather not be, send us the address. We will tell you what we can see from outside, what it will take, and whether you need us at all - some of these are a twenty-minute job and we will say so.

| Questions

Questions people ask about this

What should I do first if my website is hacked?

Put it into maintenance mode so visitors are not harmed and Google stops indexing the bad pages, then write down and screenshot what you can see, then contact your host before changing any files. Do not start deleting things - those files are the evidence of how they got in, and removing them leaves the hole open.

Should I delete the hacked files straight away?

No. They are the only record of how the attacker got in, and deleting them removes the symptom while leaving the cause - the out-of-date plugin or open account - exactly where it was. Taking the site offline already protects visitors, which buys you time to find the way in before cleaning up. Keep a full copy of the infected site first.

Will restoring a backup fix a hacked website?

It will usually get a working site back quickly, but it is not a repair. The backup contains the same weakness that was used, so you have restored the site exactly as it was on the day it was broken into. Quiet infections also sit for months, so a recent backup may be infected too. Restore if it helps, then update everything and close the way in.

How do I know the hack is really gone?

When four things are true: the way in has been named specifically and closed, everything is on a current version with unmaintained software removed, every credential including the database password has been changed, and the site’s forms, checkout and emails have been tested. Automated scanners frequently miss backdoors, which are small innocuous files placed in several folders so that removing one changes nothing.

How long does it take to recover a hacked website?

The technical clean-up on a straightforward site is usually a day or two. Getting a Google security warning removed takes as long as the review takes after you request it, and search rankings damaged by hidden spam pages typically recover over weeks rather than days. Requesting the review before the site is genuinely clean makes it slower, not faster.

Do I have to tell my customers my website was hacked?

If personal data may have been reached, very possibly yes, and within a fixed period - under the GDPR for UK and EU customers and under state law across much of the US. This is a legal question rather than a technical one, so take advice on it. Practically, the businesses that recover well are the ones that said so early and plainly.

My website keeps getting hacked again. Why?

Because the way in was never closed. A clean-up that removes the malicious files but not the out-of-date plugin, the open account or the scheduled task that reinstalls everything at 3am will be undone within days. Ask whoever cleaned it one question: how did they get in? A specific plugin, version and date means the job was done. "We removed the malware" does not.

Dealing with this right now?

Send us the address. We will tell you what we can see, what it will take, and whether you need us at all.

WhatsApp us