If your website was hacked, the first 24 hours have one job: cut off the attacker's access, preserve the evidence, then clean. Put the site into maintenance mode, rotate every password and API key, and take a full backup of the compromised state before you delete a single file. Restoring last week's backup without finding the entry point only resets the clock until the next intrusion.
Work through the phases below in order. Each one takes minutes, not days, and none of them requires a security team.
Why this matters for your website
A compromised site is rarely the attacker's end goal. It is an asset they monetise: spam pages for SEO, a phishing kit in a hidden folder, a card skimmer on your checkout, or a relay for sending mail in your domain's name.
Every hour of that costs you something measurable. Search engines flag the domain, mailbox providers start rejecting your mail, and payment processors ask questions. Acting in an ordered sequence protects both the site and the record you will need later for your insurer, your payment provider or a regulator.
Phase 0: Confirm it is really a compromise
Not every strange symptom is an intrusion. Before you tear the site down, screenshot what you see, with the URL bar and the system clock visible. Save the screenshots outside the server.
Then match the symptom to the likely cause:
- Redirects to an unknown domain for mobile visitors only — injected JavaScript or a malicious
.htaccessrule. - Unknown pages indexed in Google (pharma, casino, replica goods) — SEO spam injection, usually in the uploads directory.
- Admin users you did not create — stolen or brute-forced credentials, or a privilege-escalation flaw in a plugin.
- Browser or Search Console warning about deceptive content — phishing kit or malware hosted in a subfolder.
- Outbound spam and a damaged domain reputation — compromised mail credentials or a vulnerable contact form.
- Checkout page loading an extra script — card skimmer injected into the theme or a payment plugin.
- Sudden CPU or bandwidth spike from your host — cryptominer, botnet node, or simply a traffic surge. Verify before panicking.
If two or more symptoms appear together, treat it as a compromise and continue.
Phase 1: Contain (first hour)
- Enable maintenance mode, or serve a static holding page. Taking the site fully offline is acceptable and often safest.
- Rotate every credential: CMS admins, database user, FTP/SFTP and SSH keys, hosting control panel, DNS registrar, and all API keys and webhook secrets.
- Force a logout of all active sessions so stolen cookies stop working. In WordPress, changing the authentication salts in
wp-config.phpdoes this instantly. - Check the hosting account and the registrar for added users, forwarding rules or new API tokens.
- Check your DNS records for unfamiliar A, MX or TXT entries. A modified MX record means your mail is being read.
Enable two-factor authentication on the registrar and hosting account now, not later. Those two accounts control everything else.
Phase 2: Preserve evidence before you clean
Cleaning destroys the only copy of how you were attacked. Preserve it first.
- Take a full archive of files and database in their compromised state, and store it offline, clearly labelled.
- Download the web server access and error logs, plus any CMS or WAF logs, for at least the last 30 days.
- Record file modification times before you touch anything:
find . -type f -mtime -14 -ls > /tmp/changed.txt.
Phase 3: Find the entry point
Sort the file list by modification date and find the earliest suspicious change. Then search the access log for requests to that file and for the hours around that timestamp.
Most intrusions on small business sites trace back to one of four causes:
- An outdated plugin, theme or CMS core with a published vulnerability. Cross-check versions against the WPScan vulnerability database and NVD.
- Weak or reused credentials, visible in the log as repeated POST requests to the login endpoint.
- An exposed file: a
.zipbackup, an.env, a readable.gitdirectory, or a strayphpinfo.php. - Host-level or neighbour compromise on shared hosting. If other sites on the account are infected, ask your host to investigate.
If you cannot identify the entry point, assume credentials and plugin vulnerabilities both and remediate both.
Phase 4: Clean or restore
Restoring from a known-good backup is faster and more reliable than manual cleaning, provided the backup predates the first suspicious file change. Manual cleaning is only sensible when no clean backup exists or when recent orders and content would be lost.
- Restore the backup, then immediately update core, themes and plugins before the site goes public again.
- Reinstall core files and all plugins from official sources rather than trusting an in-place repair.
- Delete plugins and themes you do not use. Deactivated code is still reachable code.
- Inspect the database for injected
<script>tags in post content and options, and for rogue scheduled tasks.
Phase 5: Verify and reharden
- Remove unknown admin users, unrecognised SSH keys and unexpected cron jobs (
crontab -land the CMS scheduler). - Enforce 2FA for every administrator and unique passwords stored in a password manager.
- Set the security headers: Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options, Referrer-Policy and Permissions-Policy.
- Mark session cookies
Secure,HttpOnlyandSameSite. - Block direct access to backups,
.gitand.env, and disable file editing in the CMS admin. - Re-scan the whole site and compare the result against your pre-incident state.
Our WordPress security guide covers the platform-specific hardening steps in more depth.
Phase 6: Communicate
- Customers and users — tell them plainly what happened, what data was involved and what action they should take. Force a password reset if account credentials were exposed.
- Your payment provider — contact them the same day if the checkout was touched. Do not wait for them to notice.
- Your regulator — under GDPR Article 33, a notifiable personal data breach must reach the supervisory authority without undue delay and, where feasible, within 72 hours of awareness.
- Google — once the site is clean, request a review in the Security Issues report in Search Console, described in Google's documentation.
How to check your own site
After cleanup you need two answers: is the site hygienic again, and is the hole closed. Free checks cover the first question quickly — the Security Headers Checker, the SPF & DMARC Checker and the Website Security Check need no account.
Scantinel (scantinel.ai) is an automated website security assessment platform that runs OSINT, network, and OWASP Top 10 web vulnerability tests against ownership-verified assets and delivers actionable, business-owner-legible reports. The Essential scan runs in minutes and passively confirms hygiene: DNS and SPF/DKIM/DMARC posture, TLS configuration, security headers, cookie flags, exposed common files, CMS version and known-vulnerable plugins.
The Full scan is the one that answers the second question. It adds active OWASP Top 10 testing, port and service fingerprinting with CVE correlation, a WordPress and WooCommerce deep scan, and supply-chain checks for exposed .git, .env and leaked secrets. Run it again after remediation — the retest is how you prove the fix held. You can scan your site after cleanup once ownership is verified. This is an automated assessment, not a penetration test, and it will not replace a forensic investigation after a serious breach.
Key takeaways
- Contain first: maintenance mode, rotate every credential, revoke sessions, check DNS and the registrar.
- Back up the compromised state and export logs before you clean anything.
- Find the entry point, or you will be cleaning the same site again next month.
- Restore from a backup that predates the earliest suspicious file change, then update everything before going live.
- Check the 72-hour GDPR clock the moment you suspect personal data was affected.
Frequently asked questions
How do I know if my website has been hacked?
Look for unexplained redirects, spam pages in Google's index, admin accounts you did not create, browser warnings, or a sudden reputation drop in your outbound email. Any two of those together is strong evidence. Confirm by comparing file modification times against your last deployment, and see our guide on how to check your website security.
Should I restore from backup or clean the hack manually?
Restore if you have a backup that predates the earliest suspicious file change and you can afford to lose the content since then. Clean manually only when no clean backup exists or recent orders would be lost. Either way, update every component and rotate every credential before the site goes public again.
Do I have to report a hacked website?
If personal data was accessed or exposed and you fall under the GDPR, you must notify your supervisory authority without undue delay and, where feasible, within 72 hours of becoming aware. Notify affected individuals too when the risk to them is high. Tell your payment provider immediately if checkout or card data was involved, and check any sector rules that apply to you.
Published November 2025. Security guidance changes: verify details against primary sources such as [OWASP](https://owasp.org/www-project-top-ten/), [NVD](https://nvd.nist.gov/) and [WPScan](https://wpscan.com/), and see our broader [website security guide](https://scantinel.ai/blog/website-security-guide).
Comments
No comments yet.