What to Do in Case of a Website Hack
Learn how to quarantine your site, change credentials, clean malware, and restore your web application safely after a security breach.
Quick answer
5 steps — read this before anything else
-
1
Quarantine the website by enabling maintenance mode or taking it offline to protect visitors.
-
2
Reset passwords for all server, database, FTP, and website administration accounts immediately.
-
3
Restore your site from a known clean backup created prior to the breach.
-
4
Update all core software, themes, and plugins to patch the underlying vulnerability.
-
5
Submit a reconsideration request to search engines once malware has been completely removed.
Discovering that your website has been compromised is a critical situation that requires immediate, methodical action. Unintended redirects, spam links, defaced pages, or warning notices from search engines are clear indicators of a security breach. Following a structured response plan helps secure your data, protect site visitors, and restore normal operations.
What Is Happening
A website hack occurs when an unauthorized party gains access to your web server, content management system (CMS), database, or administrator accounts. Attackers frequently exploit outdated software, weak credentials, or insecure plugins to inject malicious scripts, steal user data, or use your hosting resources for malicious activities.
Step-by-Step Recovery Actions
- Quarantine the website: Place your site in maintenance mode or temporarily suspend public access through your hosting control panel. Taking the site offline prevents malicious code from infecting site visitors and stops unauthorized data exfiltration.
- Change all access credentials: Immediately reset passwords for all accounts associated with the website. This includes web hosting control panels, FTP and SFTP accounts, database users, SSH keys, content management system administrator accounts, and related email addresses. Ensure all new passwords are complex and unique.
- Document the incident: Take notes and screenshots of altered files, unexpected administrator accounts, or error messages. This information is valuable if you work with forensic experts or report the incident to authorities.
- Inspect and clean site files: Compare your current website files with original, uncompromised source files. Delete unrecognised files, suspicious backdoors, and unfamiliar database entries. Utilizing server-side security scanners can help detect obfuscated code.
- Restore from an uninfected backup: If available, restore your website using a clean backup created before the breach occurred. After restoring, immediately update the CMS core, themes, and plugins to their latest secure versions.
- Remove backdoors and fix security gaps: Identify how the attackers gained entry. Update all software, remove unused plugins, restrict file permissions, and enforce two-factor authentication for all administrative accounts.
- Request search engine reconsideration: If browsers or search engines flagged your site for malware, submit a review request through webmaster tools after confirming your site is completely clean.
What NOT to Do
- Do not ignore minor signs of infection: Small issues like unexpected admin users or minor script changes often precede complete site takeovers.
- Do not overwrite good backups: Never create a new backup over your clean, historical backups while the site is infected.
- Do not rely solely on automated cleanup plugins: Automated tools may miss hidden backdoors planted in system directories or database tables.
- Do not reuse old passwords: Reusing compromised passwords on other services puts your entire digital infrastructure at risk.
When to Seek Professional Help
If your website handles sensitive personal data, healthcare records, or payment information, contact a certified cybersecurity incident response team immediately. In many jurisdictions, data breaches involving user information carry legal notification obligations. Additionally, if you cannot isolate the entry point or successfully eliminate the malware, professional remediation services can perform deep forensic analysis to fully secure your environment.
Once recovery is complete, set up automated off-site backups, continuous file integrity monitoring, and a web application firewall to safeguard your site against future attacks.
Sources & references
Information verified with official organizations.
Spotted an error? Report it — we correct factual mistakes promptly.
Read next
What to Do in Case of a Computer Crash
A computer crash can freeze your screen, cause unsaved data loss, or force an unexpected restart. Follow these practical steps to safely reboot and troubleshoot your device.