Skip to content
SecurityPHP2Shell affects most WordPress sites. Am I affected? →
presscomet
Security

WordPress hacked? A step-by-step recovery checklist

Redirects to spam sites, admin users you never created, a warning from Google or a suspension notice from your host. Here’s the order to do things in, so you clean the site once and it stays clean.

By the Presscomet teamPublished 14 min read

On this page
  1. Is it really a hack?
  2. The recovery checklist
  3. 1. Contain and preserve
  4. 2. Find the way in
  5. 3. Restore or rebuild
  6. 4. Rotate secrets
  7. 5. Get back into Google
  8. When to hire help
  9. Make it not happen again

First: is it really a hack?

“Hacked” covers a lot of ground, and a broken plugin update can look alarming too. WordPress.org’s own guidance starts with indicators of compromise: things that only happen when someone else is in control. If you see any of these, assume a compromise until you’ve proved otherwise.

Redirects
Visitors (often only from Google or on mobile) land on spam, scam or adult sites
Spam pages
site:yourdomain.com shows pharma, casino or foreign-language pages you never wrote
Unknown admins
Users › All Users lists administrators nobody on your team created
Host action
Your host suspended the site or reports malware, spam or abuse
Google warning
“This site may be hacked” in search results, or a red browser warning
Antivirus alerts
Readers say their antivirus blocks your site

Not a hack (usually)

A white screen, “There has been a critical error on this website” or a database connection error after an update is usually a plugin, theme or PHP-version conflict, not an intruder. Check the PHP error log and recently updated plugins first.

The recovery checklist

Work top to bottom. The order matters: cleaning before you close the entry point is the most common reason sites get reinfected within days. Your ticks are saved in this browser, so you can come back mid-task.

Interactive checklist

Hacked WordPress recovery

0/19

checked

1 · Contain and preserve
2 · Find and close the way in
3 · Restore or rebuild
4 · Rotate secrets
5 · Recover and watch

Ticks are saved in this browser only, so you can come back later.

1. Contain and preserve

The instinct is to start deleting suspicious files. Resist it for ten minutes. First, stop the damage: block public traffic at the CDN or server (a password prompt in the web server config, or your host’s “disable site” switch). A maintenance-mode plugin isn’t enough, because it runs inside the very software that’s compromised.

Then take a full copy of the hacked state: files, a database export and the web server and PHP logs. You’ll need it to find the entry point, and it’s a fallback if the cleanup breaks something.

Snapshot the hacked state (adjust paths)
# Files, including dotfiles like .htaccess$ tar -czf ~/incident-$(date +%F)-files.tgz -C /var/www yoursite# Database (WP-CLI)$ wp db export ~/incident-$(date +%F)-db.sql# Logs — paths vary by host$ cp /var/log/nginx/access.log* /var/log/php*-fpm.log* ~/ 2>/dev/null

2. Find the way in

Most WordPress compromises come through one of three doors. Check all three, because closing the wrong one leaves the real one open.

  • The server’s software. Unpatched PHP is the obvious one this month: PHP2Shell could give an attacker code execution before WordPress even loads. Confirm your version with our PHP version guide, and ask your host if you’re unsure.
  • A vulnerable plugin or theme. Look at what was installed or updated around the time things went wrong, and at abandoned plugins that haven’t had an update in years. Public vulnerability databases list known issues per plugin.
  • Stolen credentials. Reused passwords, a leaked hosting login, or malware on the computer of someone who logs in. Your login history (if you have one) and your host’s access logs show unexpected logins.

The access log is the best witness. Find the first suspicious file’s modification time, then look at requests just before it. POST requests to odd URLs, uploads to pages that never take uploads, and requests to files in wp-content/uploads ending in .php are all telling.

Find recently changed and out-of-place files
# PHP files where only media should be$ find wp-content/uploads -type f -name '*.php'# Everything changed in the last 14 days (newest first)$ find . -type f -mtime -14 -printf '%TY-%Tm-%Td %TH:%TM  %p\n' | sort -r | head -50# Common obfuscation patterns (expect some false positives)$ grep -rlE 'eval\(base64_decode|gzinflate\(base64|str_rot13\(' --include='*.php' .

3. Restore or rebuild

Which route you take depends on one question.

This is the fastest and most reliable path.

  1. Pick a backup from before the compromise. If you don’t know exactly when it started, go further back rather than less. For PHP2Shell, the first recorded attempt was 17 October 2026.
  2. Restore files and database together, using your host’s backup tool or your backup plugin.
  3. Close the entry point immediately (patch PHP, update or remove the vulnerable plugin) before you take the site out of maintenance.
  4. Re-apply legitimate changes made since the backup by hand: new posts, orders, form entries. Don’t copy files across from the hacked copy.
  5. Verify with the checksum commands below, then rotate secrets (next section).
Rebuild and verify with WP-CLI (from the WordPress root)
# Which files differ from the official release? --include-root also flags unknown files in the root$ wp core verify-checksums --include-root# Same for plugins from WordPress.org (premium plugins can't be checked this way)$ wp plugin verify-checksums --all# Reinstall core files for your current version, keeping wp-content$ wp core download --force --skip-content --version=$(wp core version)# Reinstall every WordPress.org plugin at its current version$ wp plugin install $(wp plugin list --field=name) --force# Look for scripts injected into posts$ wp db search '<script' --all-tables --stats# Check the site URLs haven't been changed$ wp option get siteurl && wp option get home

Checksums only cover what WordPress.org publishes

wp plugin verify-checksums works for plugins distributed through WordPress.org. Premium and custom plugins can’t be verified this way — reinstall them from a fresh download instead.

4. Rotate every secret

Assume anything stored on, or typed into, the site was seen. Some attacks (PHP2Shell among them) can also leak server memory, which can include passwords and keys that were never written to a file.

  1. Step 1: Remove unknown users and application passwords

    Users › All Users for accounts, and each admin’s profile for Application Passwords. Reassign their content to a real user.
  2. Step 2: Reset every user’s password

    At minimum every administrator and editor. Turn on two-factor login for admins while you’re there.
  3. Step 3: Replace the salts in wp-config.php

    Generate new ones at WordPress.org’s secret key service and paste them over the old AUTH_KEY…NONCE_SALT lines. Everyone, including the attacker, is logged out. Or run wp config shuffle-salts.
  4. Step 4: Change the database password

    In your hosting panel, then update DB_PASSWORD in wp-config.php to match.
  5. Step 5: Change hosting, SFTP and SSH logins

    And remove any SSH keys you don’t recognise from ~/.ssh/authorized_keys.
  6. Step 6: Rotate API keys

    SMTP, payment gateways, analytics, CDN and backup storage. Revoke the old keys rather than just adding new ones.

5. Get back into Google

If Google flagged the site, open Search Console › Security & Manual Actions › Security issues. Google’s guidance is to fix every listed issue across the whole site (the sample URLs may not be complete), then select Request Review and explain what happened, what you fixed and the result. Reviews take from a few days to several weeks, and you’ll get email updates. Don’t resubmit while one is pending.

Spam pages the attacker created should return 404 or 410 once removed. If you used a redirection tool, make sure none of the attacker’s redirects survived in it.

When to hire a professional

Doing it yourself is realistic for a small site with a clean backup. Get help when:

  • The site handles payments, member accounts or personal data — you may have legal notification duties, and you need to know what was accessed, not just make the symptoms go away.
  • You’ve cleaned it once and it came back.
  • You can’t find the entry point, or you don’t have server access to look.
  • Several sites on the same account are affected.

Ask any cleanup service how they identify the entry point, whether they keep the forensic copy, and what they guarantee if the infection returns.

Make it not happen again

Once you’re clean, run through the interactive WordPress security checklist: patched PHP, two-factor login, fewer plugins, off-site backups and someone watching the logs cover most of the risk.

It’s also worth asking how much software your site really needs to run. A typical WordPress site depends on the PHP runtime, a MySQL server and a dozen plugins, each with its own update schedule. Presscomet keeps the same wp-admin and URLs but has no PHP runtime and no PHP plugins, so PHP-runtime and PHP-plugin vulnerabilities don’t apply. It still needs its own updates, strong logins and backups, so nobody should call it unhackable. Read the trade-offs in Can you run WordPress without PHP? or on our WordPress security page.

Clean first, then move

Migrating an infected site moves the infection. Recover with this checklist first; once you’re clean, check what would move over or let us run it on managed hosting.

Sources

Facts checked against these sources on October 23, 2026. Things change quickly; the vendor advisory always wins.

  1. [1]FAQ: My site was hacked — WordPress.org Documentation
  2. [2]Hardening WordPress — WordPress Developer Resources
  3. [3]wp core verify-checksums — WP-CLI
  4. [4]wp plugin verify-checksums — WP-CLI
  5. [5]Secret key generator (salts) — WordPress.org
  6. [6]Security issues report — Google Search Console Help
  7. [7]PHP2Shell advisory (indicators of compromise) — Sophos

Frequently asked questions

What should I do first if my WordPress site is hacked?

Stay calm and document what you see and when. Then contain it: put the site into maintenance at the server or CDN level (or take it offline), and take a snapshot of files, database and logs before changing anything. Cleaning comes after you know how the attacker got in.

Why does my WordPress site redirect to a spam site?

Redirect hacks usually live in a modified .htaccess file, injected JavaScript in the theme or database, a rogue plugin or must-use plugin, or changed siteurl and home options. Redirects often only fire for visitors from search engines or on mobile, so you may not see them while logged in.

Will reinstalling WordPress from the dashboard remove malware?

Not reliably. The built-in reinstall only overwrites existing core files; malware usually adds new files and lives in wp-content, the database, .htaccess or must-use plugins. Replace wp-admin and wp-includes from a clean download, reinstall plugins and themes from their official sources, and inspect the rest.

Can a security plugin clean a hacked site?

Scanners help you find infected files, and WordPress.org’s own hacked-site FAQ lists several. But a scan only finds what it recognises. If you can’t identify how the attacker got in, a clean backup or a full rebuild is more reliable than deleting the files a scanner flags.

How long does it take Google to remove the hacked warning?

After you fix every issue and select Request Review in Search Console’s Security issues report, Google says reviews can take from a few days to several weeks. Don’t resubmit while a request is pending.

Should I just move to a new platform?

Clean up first: moving an infected site moves the infection. Once you’re clean, a stack with less to patch is a reasonable next step. Presscomet keeps the WordPress admin and URLs but has no PHP runtime and no PHP plugins to keep updated, though it still needs its own updates, strong logins and backups.

Run WordPress without a PHP runtime to patch.

Presscomet keeps your wp-admin, editor, URLs and content, and serves pages without PHP or MySQL. Check your site for free, then migrate in one click — your old site is only ever read.

Check my site