A website compromise occurs when an attacker gains unauthorised access to your site's files or database and inserts malicious code. This can lead to visitors being redirected to phishing pages, customer credentials being stolen, or your server being used to distribute malware to other users. Search engines and email providers frequently flag compromised domains, resulting in browser warnings, email blacklisting, and a significant loss of customer trust.
Step 1: Secure Your Local Computer First
Before changing any website passwords, confirm that the computer you use to manage your site is clean. Malware on your local machine can capture keystrokes and reinfect your website immediately after you change passwords.
- Disconnect your computer from the internet temporarily.
- Run a full system scan using updated antivirus or anti-malware software.
- Remove all detected threats and restart your computer.
- Only reconnect to the internet and proceed with website password changes after your local machine is confirmed clean.
Step 2: Take the Website Offline
Prevent visitors from accessing infected pages and stop the malware from spreading further.
If you use cPanel
- Log in to your cPanel account.
- Navigate to the Files section and click File Manager.
- Open the
public_htmlfolder. - Create a new file named
.htaccessif one does not exist, or edit the existing.htaccessfile. - Add the following directive at the top of the file to return a 503 error to all visitors:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^.*$ /maintenance.html [R=503,L]
- Save the file and create a simple
maintenance.htmlpage inpublic_htmlinforming visitors the site is temporarily offline.
If you use Plesk
- Log in to your Plesk control panel.
- Go to Websites & Domains.
- Click Hosting Settings.
- Clear the Hosting enabled checkbox to suspend the site temporarily.
- Click OK to apply the change.
If you use WordPress
- Log in to your WordPress admin dashboard.
- Go to Plugins > Add New.
- Search for and install a reputable maintenance mode plugin.
- Activate the plugin and enable maintenance mode from its settings page.
Step 3: Change All Website and Hosting Passwords
Attackers often retain access through compromised credentials. Change passwords only after your local computer is confirmed clean.
- Hosting control panel (cPanel or Plesk admin password)
- CMS administrator accounts (WordPress, Joomla, Drupal)
- FTP and SFTP accounts
- Database users
- Email accounts associated with the domain
Use strong, unique passwords for each account. Do not reuse passwords across different services.
Step 4: Restore from a Clean Backup
If you have a backup taken before the infection, restore your website files and database from that point.
cPanel users
- Log in to cPanel.
- Go to Files > Backup or Backup Wizard.
- Select Restore and choose the backup file that predates the compromise.
- Follow the prompts to restore files and databases.
Plesk users
- Log in to Plesk.
- Go to Websites & Domains > Backup Manager.
- Select the backup created before the infection date.
- Click Restore and confirm the restoration.
Step 5: Update All Software
Outdated CMS versions, plugins, and themes are common entry points for attackers.
WordPress users
- Log in to your WordPress admin dashboard.
- Go to Dashboard > Updates.
- Update WordPress core, all plugins, and all themes.
- Go to Plugins > Installed Plugins and delete any plugins or themes you no longer use.
Joomla users
- Log in to the Joomla administrator panel.
- Go to Components > Joomla! Update.
- Apply all available updates for core and extensions.
Step 6: Remove Malicious Code
If you cannot restore from a clean backup, you must identify and remove infected files.
- Check
index.php,header.php, andfooter.phpfor unfamiliar code. - Inspect
.htaccessfiles for suspicious redirect rules. - Review WordPress
wp-config.phpandfunctions.phpfiles. - Look for recently uploaded files in media or upload directories.
Use a reputable security scanner to identify infected files, then remove or replace them with clean versions. If you are unsure about any file, do not delete it—seek professional assistance.
Step 7: Notify Affected Customers
If customer data, login credentials, or payment information may have been accessed, you must inform affected individuals promptly. Explain what happened, what data may have been exposed, and what steps they should take, such as changing their own passwords and monitoring accounts for unusual activity. Depending on your industry and location, you may also have legal obligations to report the breach to relevant authorities.
Step 8: Resolve Search Engine and Email Warnings
Once the site is clean, request a review to remove warnings and blacklistings.
- Verify ownership of your domain in Google Search Console.
- Go to the Security Issues section and request a malware review.
- If your emails are blocked, contact your email service provider to request delisting from blacklists.
- This process can take several days. Continue monitoring Search Console and email delivery until warnings are removed.
Step 9: If Your Hosting Account Is Suspended
Some hosting providers suspend accounts when malware is detected. If your website is offline because your host suspended it:
- Contact your hosting provider through their support portal.
- Provide evidence that the infection has been removed, such as scan reports or a list of cleaned files.
- Request that they reactivate your hosting account.
- Do not attempt to reactivate the site yourself until the host confirms the suspension is lifted.
Step 10: Implement Ongoing Security Measures
After cleanup, reduce the risk of future compromise by adding protective layers.
- Install a reputable security plugin or extension for your CMS (for example, Wordfence or Sucuri Security for WordPress).
- Configure a Web Application Firewall (WAF) to filter malicious traffic before it reaches your site.
- Schedule automatic, regular backups of your website files and database.
- Enable two-factor authentication on all administrator and hosting accounts.
- Set up automatic updates for your CMS, plugins, and themes where possible.
- Monitor your site files regularly for unexpected changes.