Realising your WordPress site is hacked is alarming, but fast, calm action limits the damage. This is your emergency plan for a WordPress site hacked and needing recovery, covering exactly what to do in the next two hours to contain, clean, and restore it.
Your First Two Hours: A Time-Boxed Plan
When your WordPress site is hacked, it is easy to jump straight into deleting files. Work in this order instead, so you do not destroy evidence or leave the attacker a way back in:
- Minutes 0 to 15, contain: put the site into maintenance mode or ask your host to restrict access, and tell your team not to log in from shared or unknown devices.
- Minutes 15 to 30, preserve: download a full copy of the files and database as they are now, and label it clearly as infected. Ask your host for the access logs before they rotate.
- Minutes 30 to 60, lock out the attacker: change the hosting, SFTP, database and WordPress passwords, remove any administrator accounts you do not recognize, and replace the security keys in wp-config.php to end every logged-in session.
- Minutes 60 to 90, find the damage: scan the site, verify core files against official checksums and check recently modified files, as described below.
- Minutes 90 to 120, decide: restore a clean backup from before the infection, or begin a careful manual cleanup. Then update everything and bring the site back online.
A deep infection can take longer to clean. That is fine, as long as the site is not serving malware while you work.
WordPress Site Hacked: Assess the Situation First
When a WordPress site is hacked, the immediate priority should be to assess the situation thoroughly. Assessing the extent of the breach will enable you to determine the appropriate steps to mitigate the damage and regain control of your website. Start by checking for unauthorized changes on your site. This includes reviewing any recent updates to plugins, themes, or core files that were not initiated by you or your team.
Next, monitor any error messages that might indicate a hack. Look for signs such as unexpected redirects, unusual error notifications, or warnings about security vulnerabilities. These messages can provide critical insights into how the breach occurred and the potential damage inflicted upon your site.
Additionally, examining your site’s functionality is crucial. If plugins or features are malfunctioning, it could signify that your site’s integrity has been compromised. Make note of any discrepancies or irregularities in your site’s performance, as these can serve as indicators of the type and severity of the attack.
To further assist in your assessment, utilize security tools such as Sucuri or Wordfence. These plugins can help identify malware, unauthorized changes, and security vulnerabilities within your WordPress environment. Running a complete scan can reveal insights into any malicious code that might have been injected into your files. Collecting as much information as possible will aid in correctly diagnosing the issue and determining the next steps.
Also check whether Google has noticed. In Search Console, the Security issues report lists hacked content or malware Google has detected, often with example URLs.
Secure the Site: Immediate Actions to Take
When faced with a security breach, the initial actions taken are crucial in preventing further damage to a compromised WordPress site. The first step is to temporarily take the site offline. This action not only helps to curb any ongoing malicious activities but also protects your visitors from potential harm. You can do this with a maintenance mode plugin, by asking your host to restrict access, or with a temporary server rule that only allows your own IP address. If the site is sending visitors to malicious pages, taking it offline protects them and your reputation.
Next, it is essential to change all passwords associated with the site. This includes the administrator account, as well as FTP, database, and hosting account passwords. Choose strong, unique passwords that incorporate a mix of letters, numbers, and symbols, as this will significantly enhance your site’s security. It is worth noting that reusing passwords across different accounts increases vulnerability, so it’s advisable to deploy a password manager if necessary.
Another vital step is to implement two-factor authentication (2FA) where possible. This additional security layer requires users to provide a second form of identification, which drastically reduces the likelihood of unauthorized access. WordPress offers several plugins that can facilitate 2FA implementation, thus enhancing the overall security of your site.
Our two-factor authentication setup guide explains which methods to choose and how to roll 2FA out to everyone with admin access.
Lastly, ensure that any sensitive data is safeguarded. This includes checking for data breaches and ensuring user data is not exposed. If customer data is compromised, take immediate steps to inform your users and adhere to any legal obligations pertaining to data protection. By following these immediate actions, you can create a secure environment while initiating the recovery process for your WordPress site.
If personal data may have been exposed and you serve customers in the UK or EU, check your reporting duties early. Under GDPR, a notifiable breach must be reported to the supervisory authority within 72 hours of becoming aware of it, as set out in Article 33. US states have their own rules.
Analyze and Clean Up: Finding the Source of the Breach
Once your WordPress site is secured from ongoing threats, the next critical step is to analyze and identify the source of the breach. This process begins with reviewing your site’s access logs. These logs can provide vital information about unusual activity, such as unauthorized login attempts or changes made to files. Pay special attention to any unfamiliar IP addresses or login times that seem out of the ordinary, as these might indicate potential breaches.
If you have WP-CLI access, a few commands speed this up:
wp core verify-checksumslists any WordPress core file that differs from the official release. See the verify-checksums documentation for options.wp plugin verify-checksums --alldoes the same for plugins from the WordPress.org directory.wp user list --role=administratorshows every administrator account.
Hidden administrator accounts are a common backdoor; our guide to finding and removing a hidden WordPress admin user explains how to deal with them.
Next, it’s essential to check for malware. Utilizing security plugins such as Wordfence, Sucuri, or Solid Security (formerly iThemes Security) can help in scanning your website for common types of malware. These tools can identify compromised files, malicious scripts, and other vulnerabilities that may have been exploited during the hacking incident. Regular scanning should be a part of your ongoing maintenance routines.
Moreover, understanding common hacking techniques can aid in narrowing down the source of the attack. Hackers often exploit outdated plugins or themes. Therefore, review each present theme and plugin for any known vulnerabilities. Ensure that all elements of your site are current; deactivating or removing any that are obsolete can enhance your site’s security.
It’s also crucial to revert your site to a previous version if recent updates coincide with the time of the breach. Backups can serve as a safeguard, allowing restoration from a clean state. However, for extensive breaches or if you feel overwhelmed, consulting with cybersecurity professionals may be the most prudent course of action. Their expertise can provide insights into complex security issues that might elude an average user and can facilitate a more thorough clean-up.
For the full cleanup process, including the database and the places malware usually hides, follow our step-by-step WordPress malware removal guide.
For further reading, the official WordPress ‘my site was hacked’ guide offers helpful, authoritative guidance.
Prevent Future Hacks: Implementing a Security Plan
Addressing website security is an ongoing commitment that requires vigilance and a proactive approach. To prevent future hacks on your WordPress site, implementing a comprehensive security plan is essential. First and foremost, regularly updating WordPress, along with all themes and plugins, is crucial. Outdated software is one of the most common vulnerabilities that hackers exploit. Ensure that automatic updates are enabled wherever possible, and monitor for any critical updates that may require manual intervention.
In addition, creating regular backups of your site is vital. By establishing a routine for backups, you can secure your content and restore your website quickly in case of an incident. It is advisable to leverage reputable backup solutions that store your data off-site, ensuring that even in the case of a catastrophic failure, your website remains recoverable.
Keep several restore points: malware can sit unnoticed for weeks, so the latest backup may already be infected. Our WordPress backup guide covers retention, encryption and restore testing.
Choosing a trustworthy hosting provider also plays a significant role in securing your WordPress site. Opt for a host that prioritizes security features, such as firewalls, malware scanning, and DDoS protection. These layers of security can significantly reduce the risk of a breach and protect your sensitive information.
Moreover, educating your team about security best practices is equally important. Staff should be trained to recognize phishing attempts, utilize strong passwords, and apply two-factor authentication where possible. A well-informed team can act as a frontline defense against potential threats.
Security is an ongoing routine, not a one-time fix: review updates, backups, user accounts and scan results on a regular schedule.
Frequently Asked Questions
Will restoring a backup fix a hacked site?
Only if the backup was taken before the infection, and only if you also fix the weakness that let the attacker in. Otherwise the same hole is exploited again. Change passwords and update everything straight after restoring.
How do I get a Google warning removed after a hack?
Clean the site completely, then open the Security issues report in Search Console and request a review. Google checks the site again before it removes the warning, so make sure nothing malicious remains first.
When should I call a professional?
Call for help if the infection keeps coming back, if the site takes payments or stores customer data, or if you cannot find how the attacker got in. Our post on when to call for WordPress emergency support covers the warning signs.
If you would rather have this handled for you, our WordPress hacked-site recovery service takes care of this end to end.
Get a free audit covering security, updates, backups, and performance gaps. Takes 60 seconds to request and costs nothing.
