How to Clean Malware from a Compromised Website

If your website has been infected with malware, it is important to clean it properly to prevent reinfection and avoid being blocked by search engines like Google. Malware can damage your site’s reputation, slow performance, and compromise user data.

This step-by-step guide explains how to remove malware from a cPanel-hosted website safely and effectively.

Step 1: Create a Full Backup

Before making any changes, always create a complete backup of your hosting account.

This ensures you can restore your website if anything goes wrong during the cleanup process.

Step 2: Identify Infected Files

Use your malware scan results (such as from cpGuard) to locate infected files.

Common locations where malware is found:

Step 3: Remove or Replace Infected Files

⚠ Important: Never use nulled or pirated plugins or themes, as they are a major source of malware infections.

Step 4: Clean the Database

Malware can also hide inside the database.

  1. Open phpMyAdmin from cPanel

  2. Inspect database tables such as:

  3. Look for suspicious scripts, spam links, or unknown code

  4. Remove malicious entries carefully

Always take a database backup before making changes.

Step 5: Change All Passwords

Once malware is removed, update all access credentials immediately:

Use strong, unique passwords for every account.

Step 6: Update Website Software

Keeping your software updated is critical for security.

Outdated software is one of the most common causes of website infections.

Step 7: Fix File and Folder Permissions

Use secure permission settings:

Avoid using 777 permissions, as they allow anyone to modify files and increase security risks.

Step 8: Enable Security Protection

Strengthen your website’s defenses:

Step 9: Scan the Website Again

After cleanup is complete:

After the Cleanup

Once your site is secure:

Cleaning malware properly not only restores your website but also helps protect your visitors and maintain search engine trust. Regular updates, backups, and security scans are the best defense against future infections.