Real people, 24/7(800) 395-7779

How to Clean Up a Hacked WordPress Site Print

  • wordpress, comprimised, hacked, infected, malware
  • 1

Signs of a hacked WordPress site include redirects to spam or scam pages, strange new admin users, unknown files, Google "This site may be hacked" warnings, a malware notice from our team, or your account suddenly sending lots of email. Act quickly, and work through these steps in order.

Prefer to have experts handle it? See our Hacked WordPress Cleanup Service, or open a ticket as soon as you notice the problem.

Step 1: Contain the Damage

  1. Change your passwords now:

    • Your cPanel password (see How to Change Your cPanel Password), every WordPress administrator password, FTP accounts, and the database user password (update wp-config.php to match).
    • Also change the password of the email address used for the WordPress admin account.
  2. Remove unknown users:

    • In WordPress, go to Users and delete any administrator you do not recognize. In cPanel, check FTP Accounts and Security > SSH Access > Manage SSH Keys for anything you did not create.
  3. Back up the current state:

Step 2: Find the Infected Files

  • Imunify360: Our shared servers scan new and changed files in real time with Imunify360 and automatically remove infected code from files it detects. Open Imunify360 in cPanel (in the Security section) to see what was found and cleaned. Automatic cleanup removes known malware, but it cannot fix the weakness that let the attacker in, so keep working through these steps.
  • Look for recently changed files: In File Manager, sort by Last Modified. Be suspicious of PHP files inside wp-content/uploads, oddly named files (random letters, or names like wp-config-sample.php copies), and recently changed index.php, .htaccess, or wp-config.php files.

Step 3: Clean the Site

  1. Replace WordPress core files:

    • In WordPress, go to Dashboard > Updates and click Re-install version x.x. This replaces wp-admin and wp-includes with clean copies. Delete any extra unknown files in those folders.
  2. Replace plugins and themes:

    • Delete every plugin and theme folder and reinstall fresh copies from WordPress.org or the vendor. Remove plugins and themes you do not use. Never use "nulled" (pirated) premium plugins; they are a very common source of infections.
  3. Clean uploads:

    • wp-content/uploads should contain only media. Delete any .php, .phtml, or other script files found there.
  4. Check wp-config.php and .htaccess:

    • Compare them to a standard WordPress copy and remove any unfamiliar code (often long encoded lines or redirect rules). Then generate new security keys (salts) from https://api.wordpress.org/secret-key/1.1/salt/ and replace them in wp-config.php. This logs everyone out.
  5. Check the database:

    • In phpMyAdmin, look in the wp_options table (siteurl, home) and in posts for injected scripts or spam links. A reputable security plugin can help scan the database.
  6. Check cron jobs:

    • In cPanel > Advanced > Cron Jobs, delete any job you did not create. Attackers often use one to re-infect the site.

Step 4: Harden and Monitor

  • Update WordPress, all plugins, and themes, and turn on automatic updates in WP Toolkit.
  • Apply WP Toolkit's security measures (see How to Secure WordPress with WP Toolkit).
  • Turn on two-factor authentication for cPanel and a 2FA plugin for WordPress admins.
  • Use a supported PHP version (see MultiPHP Manager).
  • If Google flagged your site, request a review in Google Search Console after cleaning.
  • If the account was sending spam, check cPanel > Email > Track Delivery to confirm it has stopped.

Restoring Instead of Cleaning

If you have a clean backup from before the hack, restoring it can be faster. You still need to change all passwords and update everything afterwards, or the site will be re-infected through the same hole. To restore from our backups, open a ticket with the date you want to go back to; there is no charge for restores.

Need help? Open a ticket at https://my.peopleshost.com/submitticket.php and our support team will be glad to assist.


Was this answer helpful?

« Back