WordPress Site Hacked? What to Do in the First Hour
Contain it, preserve evidence, find how they got in, then rebuild from clean sources and rotate every credential. The order matters, and skipping a step is how sites get reinfected.
Spam pages, strange admin users, redirects to other sites or files you did not add.
Do this first
Diagnose it
Most compromised sites stay online, because the attacker wants your traffic and your server. The symptom tells you what kind of infection you are dealing with.
| What you see | What it usually is |
|---|---|
Google results for your site with Japanese or pharmacy titles, or This site may be hacked under your listing | SEO spam: thousands of generated pages or a cloaked spam layer shown only to search engines. |
A red full-page warning: Deceptive site ahead or The site ahead contains malware | Google Safe Browsing has flagged the site. Search Console lists it under Security issues. |
| Visitors from Google or on phones land on a scam site, but you never see it | A conditional redirect that skips logged-in users and repeat visitors. |
| Admin users you did not create | A backdoor account, often created through a vulnerable plugin. |
PHP files in wp-content/uploads, or files with random names in the site root | Web shells or backdoors. |
| Bounces you never sent, or a host notice about outgoing spam | A mailer script on the site or a compromised mailbox. |
| A suspension notice for malware or phishing | Your host’s scanner or an outside abuse report found it. |
A fake Verify you are human box that tells visitors to press Win+R, or to paste a command into Terminal or PowerShell | A ClickFix overlay injected into the site to trick visitors into running malware. See fake CAPTCHA and ClickFix. |
1. Look at your site the way search engines see it.
curl -s -A 'Googlebot/2.1 (+http://www.google.com/bot.html)' https://example.com/ | grep -ioE 'viagra|cialis|casino|slot gacor|replica' | sort | uniq -c
Run it on your own computer, replacing example.com with your domain. -A sends the Googlebot user agent, which cloaked spam is set up to answer. Good: no output. Bad: spam words that do not appear when you view the page normally.
2. Look at it the way a phone user from Google sees it.
curl -sI -A 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148' -e 'https://www.google.com/' https://example.com/ | grep -iE '^(HTTP|location)'
Run it on your own computer. -e pretends you arrived from Google; -A pretends to be an iPhone. Good: HTTP/2 200 and no location line, or a location on your own domain. Bad: a location pointing at a domain you do not own.
3. Search Google for pages you did not write.
site:example.com
Type this into Google search. Scroll several pages. Titles in other languages or about products you do not sell mean spam pages exist or existed.
4. Find PHP files where none should be.
find wp-content/uploads -type f -name '*.php'
Run it in an SSH terminal inside the site’s folder (the one with wp-config.php). The uploads folder holds images and documents. Good: no output, or only an empty index.php placed by a plugin. Bad: any other PHP file.
5. Check plugin files against the official copies.
wp plugin verify-checksums --all
Run it in the same SSH terminal, in the site’s folder. --all checks every installed plugin against the files published on WordPress.org. Good: Verified for each one. Bad: File was added or Checksum does not match. Premium plugins not hosted on WordPress.org are reported as unverifiable, so check those against a fresh download.
These are the usual ways in. Knowing which one happened decides whether your cleanup holds.
admin-ajax.php or a REST route. Fix: update or remove it; delete anything that no longer gets updates.POST /wp-login.php from an unfamiliar IP, followed by a plugin upload or a theme file edit. Fix: new unique passwords and 2FA for every admin.eval(base64_decode( sits inside it from the day it was installed. Fix: delete it and install a licensed copy.phpinfo files or migration installer scripts reachable by URL. Fix: delete them and keep backups outside the public folder.Did this fix it?
Still stuck? Start again from what you can see in the Emergency Room.
The full fix
Contain it, preserve evidence, find how they got in, then rebuild from clean sources and rotate every credential. The order matters, and skipping a step is how sites get reinfected.
Seeing “Sorry, you are not allowed to access this page”, lost your admin role, your password, your 2FA device or tripped a security lockout? Get back in from the server, safely.
Google shows Japanese, pharmacy or casino pages under your domain that you never wrote. Find the cloaked spam, remove it at the source, then get the junk URLs dropped from Google.
Visitors land on a scam, dating or fake prize site, often only on mobile, only from Google or only once. Reproduce the conditional redirect, then remove it from the database, files or CDN.
Browsers show a red warning before your site loads. Confirm which blocklist flagged you, find the phishing kit or malware behind it, then get reviewed by Google and the other vendors.
Your host suspended the account over malware, phishing or outgoing spam. Decode the abuse notice, find the mailer script or stolen mailbox, clean every site on the account and get reinstated.
You cleaned the site and the malware came back. Something survived: a backdoor, hidden admin, cron job, stolen password or unpatched plugin. Find it and prove the site is clean.
Bounces mention Spamhaus, Barracuda or “blocked using”? Learn how DNS blocklists work, how to check them by hand, and how to fix the cause before you request removal.
Getting bounces for mail you never sent, or customers reporting fake emails from your domain? Learn how spoofing works and how to lock your domain down with DMARC.
Pick the right restore point, restore from a host snapshot, a backup plugin or raw files plus a SQL dump, and keep the orders and comments that arrived since.
No backup? Check host snapshots, CDN caches, the Wayback Machine and old copies first, then rebuild from feeds and uploads, or rescue a database MySQL will not start.
Hundreds of fake subscribers or a comment queue full of junk? Close every registration door, bulk-remove fake users safely and lock down comments.
Search the field manual
Or jump straight to a symptom
Press / to search from any page, Esc to close