If your WordPress site shows strange redirects, unknown admin accounts, or a sudden drop in search rankings, you’re probably dealing with a breach. The right response is a disciplined, step-by-step cleanup that preserves evidence, removes the attacker’s foothold, and strengthens the whole installation.

How does a WordPress hack happen?

WordPress is built on PHP and MySQL and relies heavily on plugins and themes. Each added component is a potential attack surface. Common entry points include:

  • Out-of-date core, plugins, or themes that contain known vulnerabilities.
  • Weak passwords for admin, FTP/SFTP, or database users.
  • Misconfigured file permissions that allow unauthorized file writes.
  • Insecure server settings, such as allowing execution of files in the uploads directory. When an attacker exploits any of these, they can inject malicious code, create backdoors, or gain database access. Understanding the vector is essential for preventing recurrence.

What’s the first thing to do after noticing a breach?

Before you start changing anything, you need to verify that the site is indeed compromised. Follow the checklist in the guide to confirm the site is really hacked. Look for unexpected file changes, unknown admin users, or alerts from search engines. This confirmation stops you from chasing a false alarm and gives you a baseline for evidence collection.

How do I contain the attack and stop further damage?

  1. Put the site into maintenance mode - use a simple .htaccess rule or a temporary index.php that returns a 503 status. This blocks visitors and stops the attacker from executing more code.
  2. Restrict access - disable public HTTP access to wp-admin and wp-login.php using IP allow-lists if your host permits it.
  3. Take the site offline if needed - many hosts provide a one-click “maintenance” or “suspend” option, or can do it for you on request. Containment buys you time to work on a clean copy without the attacker continuing to modify files.

How should I change the locks and reset credentials?

  1. WordPress admin passwords - generate strong, unique passwords for every user with admin capabilities. Use the built-in password generator or a reputable password manager.
  2. Database credentials - change the database user's password in your hosting panel, then put the new password in DB_PASSWORD in wp-config.php.
  3. FTP/SFTP and hosting account - change these passwords as well. If you use SSH keys, generate a new key pair and replace the old public key on the server.
  4. Regenerate secret keys - replace all eight keys and salts in wp-config.php (AUTH_KEY through NONCE_SALT). You can obtain random strings from the WordPress secret-key service. Changing these keys invalidates all existing sessions, forcing every user to log in again.

How do I preserve evidence for later analysis?

Before you start deleting or overwriting files, create a full backup of the current state:

  1. File system backup - copy the entire WordPress directory, preserving permissions, to a secure location outside the web root.
  2. Database dump - use mysqldump with the --single-transaction flag to export the database without locking tables.
  3. Server logs - download the access and error logs for the last 30 days. These logs often reveal the IP address and request that triggered the compromise. Keep this archive untouched; you’ll refer to it when you trace the entry point and when you need to report the incident to authorities or your host.

How can I find the entry point that the attacker used?

  1. Check for outdated components - compare the versions of core, plugins, and themes against the official WordPress release notes. Any component that is older than the latest security patch is a red flag.
  2. Look for recently modified files - run find . -type f -mtime -7 to list files changed in the last week. Unexpected modifications in core files (wp-includes) are a strong indicator of compromise.
  3. Search for unknown admin users - in the WordPress admin area, go to Users and look for accounts you did not create. With WP-CLI, wp user list --role=administrator lists every administrator.
  4. Review server logs - grep for suspicious POST requests to wp-login.php or xmlrpc.php. Look for repeated 404 errors that may indicate scanning activity. Document every finding; it will guide the cleaning process and help you close the gap.

What steps are required for a thorough clean?

  1. Replace core files - delete all files in the WordPress root except wp-config.php and wp-content. Then download the exact version of WordPress you were using from the official archive and extract it.
  2. Reinstall plugins and themes - delete the wp-content/plugins and wp-content/themes directories, then reinstall each component from its original source (the official repository or a trusted developer). Do not reuse files from the backup.
  3. Scan for malware - run a malware scanner, and with WP-CLI run wp core verify-checksums to confirm the core files match the official release. Focus on files containing base64_decode, eval, gzinflate, or long strings of random characters.
  4. Clean the database - our guide to removing malware from WordPress covers this in detail. Search for injected JavaScript or iframe code in the wp_posts and wp_options tables. Use SQL statements such as SELECT ID, post_content FROM wp_posts WHERE post_content LIKE "%<script%"; and remove the malicious snippets.
  5. Remove backdoors - follow the detailed guide on how to find and remove backdoors. Typical backdoors are hidden PHP files in wp-content/uploads that contain obfuscated code.
  6. Reset file permissions - set directories to 755 and files to 644. Ensure the wp-config.php file is 600.

How do I verify that the site is clean and ready to go live?

  1. Run a second malware scan - use a different scanner than the one you used for the initial clean. The goal is to catch anything the first pass missed.
  2. Check the site as a visitor - open it in a private window and from a phone on mobile data, because some injected code only runs for logged-out visitors or for people arriving from search engines.
  3. Use Google Search Console - request a review if the site was flagged for malware. The review process confirms to search engines that the site is safe again.
  4. Monitor the site for a few days - enable file-change monitoring (e.g., a cron job that runs find and compares hashes) and watch the logs for any new suspicious activity.

What hardening measures prevent the next breach?

  1. Enable a firewall - configure the server or a web-application firewall to block known attack vectors such as XML-RPC abuse.
  2. Enforce two-factor authentication for all admin accounts. This adds a second verification step beyond passwords.
  3. Limit login attempts - restrict the number of failed logins per IP address within a short time window.
  4. Disable file editing - add define('DISALLOW_FILE_EDIT', true); to wp-config.php to prevent code changes from the dashboard.
  5. Regular backups - schedule daily backups of both files and database, storing them off-site and testing restoration regularly.
  6. Automatic updates - enable core, plugin, and theme updates where possible, or set a schedule to apply them promptly.
  7. Monitor file integrity - use a simple script that generates and stores SHA-256 hashes of all core files; compare them daily to detect unauthorized changes.

How Silent Threads helps

Silent Threads helps at every step: finding infected and obfuscated files, spotting unknown admin users, monitoring changes, and hardening the site so the next attempt fails.

The short version

  1. Verify the hack.
  2. Put the site in maintenance mode.
  3. Change every password and regenerate WordPress secret keys.
  4. Back up the compromised site and logs.
  5. Identify the entry point (out-of-date code, unknown users, logs).
  6. Replace core, reinstall plugins/themes, scan and clean files and database.
  7. Remove backdoors using the dedicated guide.
  8. Update everything and run a final scan.
  9. Request a Google review if needed.
  10. Harden the site with a firewall, 2FA, login limits, file-edit disabling, backups, and integrity monitoring. Following these steps restores a clean environment and reduces the chance of another intrusion.