Hacked WordPress: the written procedure behind every rescue
How I clean a hacked site so it stays clean. Evidence first, every hiding place checked, the way in found and closed, and proof at the end.
- Typical cleanup, when the site can be cleaned in place
- 3-6 h
- Full rebuild, when it can't
- 2-3 days
- Steps, always in the same order
- 11
- Known traps written down
- 20
The problem
Most cleanups remove what is visible: the strange ads, the redirect, the files a scanner flags. A few weeks later the site is hacked again, and it looks like bad luck. It isn’t. Whoever got in left themselves a way back, and it is usually not a file. It is an extra administrator account, code stored in the database, a scheduled task, or a password that keeps working after everyone’s password has been reset.
A scanner that reports “clean” only tells you that the files it knows about are unchanged. It says nothing about what was added.
What I do
I follow one written procedure of eleven steps, in the same order every time. These are the ones that matter most.
- Keep the evidence before removing anything. Every malicious file is copied off the server and fingerprinted, and the database is exported. If something has to be checked later, it still exists.
- Contain it if it is doing harm. If the site is serving malware to visitors, a maintenance page goes up first, served from outside the infected folder so it can’t be tampered with.
- Compare against a copy I can trust. The site’s files are checked against the original WordPress, plugin and theme code, and against the project’s own history. First I confirm that copy is really current, or the comparison means nothing.
- Look where files aren’t. Every administrator account, compared with the number the owner expects. Code stored in the database. Scheduled tasks. Application passwords. The folders WordPress loads before everything else.
- Find how they got in. The time the first malicious file appeared is matched against the server’s access log for that minute. Until I can say how they entered, the job isn’t finished.
- Decide: clean or rebuild. If the server itself was taken over, or there is no trustworthy copy to compare against, the site is rebuilt on a fresh server from clean code and a cleaned database.
- Remove, then close the door. The entry point is blocked at the server, write access is taken away from the folders that were written to, and WordPress, plugins and theme are updated.
- Prove it. Every “it’s clean” at the end is a command and its output, not an opinion.
What a scanner misses
Each of these is in the procedure because it happened on a real site.
- A full integrity scan came back clean on a site that was carrying three separate backdoors. None of them belonged to a package the scanner knew, so none of them counted as a change.
- An attacker’s administrator account was named after a well-known security plugin. In a list of users it reads as something that belongs there.
- A backdoor was hidden inside a file with a
.cssname. Searching the PHP files never finds it. - After a malicious file is deleted, the server can keep running it from memory. Without a restart of the right service, a successful removal looks like a failed one.
- A leftover folder from the developers can quietly switch off WordPress’s automatic security updates, so the site stays on a vulnerable version while the settings say it is updating.
The result
A cleanup that takes hours instead of days, because nothing is being worked out from scratch, and a short report at the end: what happened, how they got in, what was removed, what was changed, and what to do so it doesn’t happen again. Every time a site surprises me, the procedure gets a new entry.
What this means for you
If your site has been hacked, or was cleaned once and it came back, this is what you get with a website rescue: one fixed price, the same procedure, and the proof in writing.