The instinct after a hack is to clean up. Every step of cleaning destroys the information you need to learn how they got in, to tell your insurer what happened, and to decide whether you must notify anyone. Here is what to capture first, in order, and how to keep it usable as evidence.
Restoring gets the site back and answers none of the questions that follow. How did they get in? If you do not know, the restored site has the same hole. When did it start? If the compromise is older than your backup, you have restored the backdoor. What did they reach? Without that you cannot tell customers, your insurer or a regulator anything true.
Preserving evidence takes an hour or two. It is almost always worth that, including when the site is losing money while it is down, because the alternative is to be hacked again next month by the same route.
You need to stop the damage without altering the scene.
Web server access and error logs are the best record of how an attacker got in, and the shortest-lived. Many hosts keep a few days. Download everything available, including the rotated and compressed files. If you cannot find them, ask the host's support for the logs for the affected period in the same message in which you tell them about the incident.
wp db export incident-2026-11-20-db.sql --add-drop-tableThis preserves the user accounts and when each was registered, active session tokens with their IP addresses, options that may have been changed, injected content, and the table of any activity log you run.
tar --numeric-owner -cpzf incident-2026-11-20-files.tar.gz -C /var/www example.comArchive the whole web root, uploads included. Modification times are evidence: they show which files changed, and together with the access log, which request changed them. Copying files over FTP file by file usually resets those times, which is why an archive made on the server is better.
Cron entries for the site's system user, .htaccess and server configuration, the list of SFTP and SSH accounts and keys, and the hosting control panel's own login history if it has one.
Evidence is worth little if you cannot show it is unchanged since you took it.
sha256sum incident-2026-11-20-* > incident-2026-11-20.sha256Then keep a plain text note alongside, written as you go:
2026-11-20 09:14 UTC — J. Meyer — noticed redirect to pharmacy site on /checkout
2026-11-20 09:31 UTC — J. Meyer — site restricted to office IP at firewall
2026-11-20 09:40 UTC — J. Meyer — downloaded access logs 2026-11-06 to 2026-11-20 from host panel
2026-11-20 09:52 UTC — J. Meyer — db export + file archive created on server, checksums recorded
2026-11-20 10:05 UTC — J. Meyer — copies moved to encrypted drive; originals untouched
That note is a chain of custody. It does not need to be elaborate. It needs times in UTC, a name against each action, and no gaps. Store the copies somewhere the compromised server cannot reach, and work on duplicates.
If an activity log was running, it holds what server logs cannot: which account did what. Export it for a period starting well before the first sign of trouble. Look especially for new administrator accounts, role changes, plugin installs, file editor use, and changes to the admin email or site address.
Treat that log with some suspicion. An attacker with administrator or database access may have deleted entries. Whether you can tell depends on the tool: a log whose records are cryptographically chained will report missing or altered rows, and an ordinary one will look complete either way. Note which kind you have in your custody note.
Entities in scope must send an early warning within 24 hours of a significant incident.
If personal data was or may have been accessed, you must notify your supervisory authority within 72 hours of becoming aware, unless the breach is unlikely to result in a risk to people. You can notify with partial information and add to it later. You cannot notify late without explaining why.
If card data may be involved, your acquirer's rules apply immediately, and they may require a specific forensic investigator. Stop and call them before touching anything further.
Most policies require prompt notice and some require you to use the insurer's own responders. Cleaning up first can jeopardise the claim. If you run the site for a client, your agreement probably sets a notification period.
With copies made and checksummed, the site can be cleaned or rebuilt. Work out the entry point from the evidence before restoring, so that you restore to a state from before it and close the hole. Then rotate everything: all WordPress passwords, the authentication salts in wp-config.php, database and SFTP credentials, API keys and application passwords. The practical walkthrough is in site hacked: how to find out what changed.
Get professional help when card data or health data may be involved, when you expect a legal dispute or an insurance claim, when the site has been reinfected after a previous clean-up, or when you simply cannot find the entry point. Evidence you have preserved as above is what a responder will ask for first, and it makes their work shorter and cheaper. The author of this guide does this for a living at WP Server Guard; any competent incident responder will want the same material.
Most of the difficulty above comes from evidence that was never recorded or was easy to erase. Three preparations change that: keep server logs for at least 90 days, keep backups off the server, and run an activity log that can show whether it has been tampered with. Who Changed It, which this site documents, hash-chains its records and signs its exports for that reason; this page explains how.