Knowledgebase

How to clean a hacked WordPress site (step by step)

If your WordPress site has been hacked, you may see strange pages, unknown admin users, spam links in Google results, redirects, or a warning from your browser or hosting provider. This guide shows you how to clean a hacked WordPress site step by step, close the hole the attacker used, and stop it from happening again.

Do not panic and do not delete everything. Work in order: take a backup of the infected site first (it is evidence and a safety net), then clean, then secure. If you are not comfortable with files and databases, open a ticket and our team can help.

1. Confirm the hack and contain it

  1. Note the symptoms: which pages are affected, when it started, whether visitors on mobile or from Google see something different.
  2. Take a full backup of files and database as they are now. See how to back up and restore your website.
  3. If you have a clean backup from before the infection, restoring it is often the fastest fix. You still need to finish steps 4 to 6, otherwise the attacker gets back in through the same hole.
  4. Optionally enable a maintenance page while you work so visitors are not exposed to malware.

2. Change every password

  1. Your cPanel / client area password.
  2. All WordPress administrator passwords. If you cannot log in, see how to reset your WordPress admin password.
  3. FTP accounts and the database user password. If you change the database password, update DB_PASSWORD in wp-config.php to match.
  4. In Users in WordPress, delete any administrator you do not recognise.

3. Replace WordPress core, themes and plugins with clean copies

  1. Go to Dashboard > Updates and use Re-install to refresh WordPress core files.
  2. Delete themes and plugins you do not use. Hackers love abandoned and "nulled" (pirated) plugins.
  3. Re-install each remaining plugin and theme from the official source (WordPress.org or the vendor) instead of trusting the existing files.
  4. Never re-use plugins downloaded from piracy sites. They are one of the most common causes of infections.

If WP-CLI is available on your plan, you can verify core and plugin files against the official checksums:

cd ~/public_html
wp core verify-checksums
wp plugin verify-checksums --all

4. Look for backdoors in your files

Attackers usually leave a hidden file so they can come back. Use cPanel File Manager or Terminal and check:

  • PHP files inside wp-content/uploads: this folder should only contain media.
  • Recently modified PHP files.
  • Unknown files in the site root with random names, and changes to .htaccess and wp-config.php.
cd ~/public_html
find wp-content/uploads -type f -name "*.php"
find . -type f -name "*.php" -mtime -7

Review each result before deleting it. Some legitimate plugins create PHP files too, so if you are unsure, rename it or ask us rather than deleting it.

5. Clean the database

Open phpMyAdmin from cPanel and check:

  • The siteurl and home values in the wp_options table (your table prefix may differ).
  • Posts and pages containing unexpected <script> tags or hidden spam links.
  • The users table for accounts you did not create.

6. Close the hole and harden the site

  1. Update everything: WordPress, plugins, themes and the PHP version (see how to change the PHP version).
  2. Enable two-factor authentication for administrators and limit login attempts.
  3. Follow our full checklist on how to secure your WordPress website.
  4. Set up automatic off-site backups so you always have a clean restore point.

7. Clean up after the hack

  • In Google Search Console, check Security issues, and request a review once the site is clean.
  • Remove spam URLs that Google indexed (they should now return 404 or 410).
  • Watch the site for a few weeks: new admin users, new files, or the same symptoms coming back mean a backdoor is still there.

Common problems

Frequently asked questions

Can I just restore an old backup?

Yes, if the backup is from before the infection. But you must still update everything and change passwords, because the original vulnerability is still in the old copy.

Does my hosting scan for malware?

EgWeb servers run server-side security tools that can detect many infected files. They help a lot, but cleaning the database, removing fake users and fixing the vulnerable plugin still has to be done on the site itself.

How do I know which plugin was the entry point?

Check plugins with known recent vulnerabilities, abandoned plugins, and anything pirated. File modification dates and access logs in cPanel can also point to the date and file used.

Need help? Open a support ticket or message us on WhatsApp +20 127 113 3655.

  • hacked WordPress, clean hacked WordPress, WordPress malware, malware removal, WordPress security, موقع ووردبريس اتهكر, تنظيف موقع مخترق

Was this answer helpful?

0 Users Found This Useful