Skip to content
0850 554 5439 [email protected]

What do you need help with?

Search the guides and tutorials, or browse the categories.

My WordPress site was hacked: clean up with passwords, scanning, a clean backup and updates

Shared Hosting 31 views Step-by-step guide Last verified: Markdown
What you will learnHow to cut off the attacker's access on a hacked WordPress site (passwords), find malicious files (scanning), return the site to a clean backup, update everything, and harden your site so it doesn't happen again.
Time30 minutes or more (depends on the site)

1. Has my site really been hacked?

Someone may have gained unauthorized access if:

  • Visitors are redirected to another site (gambling, pharmacy, fake prizes).
  • Spam pages in a foreign language appear in search results under your domain.
  • The browser or a search engine warns that "this site may be harmful".
  • WordPress has administrator users you didn't create.
  • Large amounts of spam are sent from your account, or your hosting account hits its resource limits.
  • Folders such as wp-content/uploads contain .php files you don't recognize.
Warning

Before starting, check whether the site is harming visitors. If visitors are being sent to a malicious site, consider taking the site offline temporarily with a maintenance mode plugin until the clean-up is done.

2. Step 1: Change every password

The attacker may know one of your passwords. Cut off their access before cleaning:

  1. cPanel password: open Password & Security in the Preferences section of the cPanel home page and set a new, strong password. Change your customer panel password too.
Change your cPanel password with Password & Security in the Preferences section.
  1. WordPress admins: in WordPress Manager by Softaculous, click Manage Users on your site's row. If the Username list contains users you don't recognize, note them and delete them in the WordPress dashboard. Change every administrator's password (details: B32).
In Manage Users, check the admin users and change each one's password.
  1. Database user: change the password of the site's database user in Manage My Databases, and put the same password in the DB_PASSWORD line of wp-config.php (B35).
  2. FTP and email accounts: delete FTP accounts you don't use, and change the passwords of the rest and of your email accounts.
  3. Scan your own computer with an up-to-date antivirus. If passwords were stolen from your computer, new ones can be stolen too.

3. Step 2: Scan for malicious files

If Imunify360 appears in the Security section of your cPanel:

  1. Open Imunify360.
  2. Scan your account in the Malware Scanner section.
  3. Review the list of files found and use the clean-up or quarantine option the tool offers.
If it appears in your cPanel, Imunify360 is in the Security section.

If Imunify360 doesn't appear, or it opens with a message saying the scanner isn't running, install a trusted security scanning plugin from the WordPress dashboard, scan the site, and let us know in a support ticket.

Info

Besides what the scanners find, look in File Manager for files whose last-modified date is close to the time of the attack. There should be no .php files in wp-content/uploads.

4. Step 3: Return to a clean backup

If you have a backup taken before the attack, this is the most reliable way to clean up.

  1. Open the Backups and Restore list in Softaculous.
  2. Check the backup dates and find one from before the day the symptoms started.
  3. Click the Restore icon on that row.
In the backups list, click the Restore icon on the row of a backup you know is clean.
  1. Leave Restore Directory and Restore Database ticked. Also tick Delete existing files/folders so files added by the attacker don't remain. Use this option only with a full directory backup.
  2. Click Restore Installation and wait for it to finish.
Restore the directory and database; tick delete existing files so infected files don't remain.
Warning

Restoring deletes posts, orders and comments added after the backup. If you run a WooCommerce store, export recent orders first. The restored site must be updated straight away so the hole is closed (step 4).

If you have no Softaculous backup, check the Account Backups section on the cPanel Backup page. As stated on our hosting page, daily and weekly backups are taken for accounts up to 2 GB; you can open a support ticket to ask about restoring from a backup with a suitable date.

5. Step 4: Update and clean everything

  1. In the WordPress dashboard, go to Dashboard → Updates and update WordPress, plugins and themes. Use the Re-install version … button on the same page to reinstall the WordPress core files as well.
  2. Delete plugins and themes you don't use. "Free" copies of paid plugins downloaded from unofficial sources are the most common source of infection; remove them and install the official versions.
  3. Replace plugins that haven't been updated for a long time or have been abandoned by their developer.
  4. If your PHP version is old, move to a current one (B34).
  5. Apply the security recommendations under Tools → Site Health.

6. Step 5: Harden your site

  1. In WordPress Manager, click Security Measures on your site's row.
  2. Turn on these measures in particular: Change default administrator's username, Block unauthorized access to xmlrpc.php, Disable file editing in WordPress Dashboard, Forbid execution of PHP scripts in the wp-content/uploads directory.
  3. Click Apply and test your site.
After the clean-up, harden your site from the Security Measures window.
  1. Install a two-factor authentication plugin for administrators and keep the Loginizer plugin, which limits login attempts, turned on.
  2. Take regular backups (B38) and check for updates every week.

7. Step 6: Clear search engine warnings

  1. Verify your site in Google Search Console and check the Security issues report.
  2. Once the problem is fixed, request a review with Request review on the same screen.
  3. If spam pages still show in search results, hide them temporarily with the Removals tool; they disappear as the cleaned site is crawled again.

8. Common problems

Symptom Cause Fix
Malicious code returns a few days after cleaning A backdoor file remained or the hole wasn't closed Restore a clean backup with Delete existing files/folders; update all plugins; change the passwords again.
A deleted unknown admin keeps coming back A malicious plugin or theme file recreates the user Delete plugins and themes of unknown origin; reinstall the core files.
The site doesn't open after restoring The database password changed but wp-config.php wasn't updated Update the DB_PASSWORD line with the new password.
Spam keeps going out from the account An email password was compromised, or a malicious mailer file is on the site Change email passwords; scan again; open a support ticket.
The browser warning doesn't go away The search engine hasn't reviewed the site yet Request a review in Search Console.

9. FAQ

Can the Gyro team clean my site?

You can do every step in this guide yourself from cPanel and the WordPress dashboard. Tell us in a support ticket which step you're stuck on and what you're seeing, and we'll point you to the tools available on your account. For an in-depth clean-up you can also work with a WordPress security specialist.

I have no backup. What can I do?

Clean the files found by the scan, reinstall the WordPress core, and reinstall all plugins and themes from their official sources. Then start taking regular backups.

Did the attacker access my customers' data?

If the database was accessed, it's possible. Consider resetting administrator and customer passwords, and consult your legal adviser about any notification obligations.

What's the single most important step to prevent this?

Staying up to date. Most attacks exploit known holes in plugins and themes that weren't updated.

Did you know?

Backing up a Softaculous site with one click before every major update lets you return to a clean version within minutes after an attack.

Next step

  • B32: Resetting your WordPress admin password
  • B38: Hosting settings and security checklist for a WooCommerce store
  • B36: Exporting and importing databases with phpMyAdmin
Was this helpful?

Thanks for your feedback!

Still Need Help?

The support team is here around the clock for anything you can't find in the knowledge base.