You've just discovered your WordPress site has been hacked. Maybe Google Chrome is showing a "Deceptive site ahead" warning. Maybe your hosting provider suspended your account. Maybe a security scan found malware. Maybe visitors are being redirected to a spam website.
Your WordPress site has been hacked — don't panic
Whatever the sign, discovering a hacked WordPress site is a genuinely alarming experience — but it is recoverable. Thousands of WordPress sites are cleaned and restored to full health every single day.
The key is to act quickly, methodically, and completely. A partial cleanup that leaves one backdoor in place means the attacker comes back — often within hours. This guide walks through every step of a complete WordPress hack recovery.
How to Tell If Your WordPress Site Has Been Hacked
Before starting the recovery process, identify what kind of compromise you're dealing with:
Visitor-facing signs:
- Visitors are redirected to spam, gambling, or adult websites
- Browser shows "Deceptive site ahead" or "This site may be hacked" warning
- Unfamiliar pop-ups, banners, or ads appearing on your site
- Site content has been defaced — replaced with the attacker's message
- New pages have appeared that you didn't create (pharmaceutical spam, casino pages)
Admin-facing signs:
- Unknown admin user accounts you didn't create
- WordPress admin password changed without your action
- Unfamiliar plugins or themes installed
- Content changes you didn't make
- Emails being sent from your domain that you didn't send
Technical signs:
- Your hosting provider suspends your account (usually for sending spam or hosting malware)
- Server resource usage spikes inexplicably
- Google Search Console shows a "Security issues" alert
- Google Search Console shows URLs in your sitemap you didn't create
- Security scan detects malware, backdoors, or modified core files
Confirm the hack:
- Run a free scan with Sucuri SiteCheck (sitecheck.sucuri.net) — checks for blacklisting and visible malware
- Check Google Search Console → Security Issues for Google's assessment
- Run a Wordfence scan from inside WordPress if you can still access wp-admin
- Google your domain name (
site:yourdomain.com) and look for unfamiliar pages in the results
Before You Start: Take Stock
Don't immediately delete everything — you need to investigate first to understand the full extent of the compromise and how it happened.
Document what you find:
- When did the hack appear to start? (Check security plugin logs, server logs, Google Search Console dates)
- Which files have been modified? (File dates, security plugin alerts)
- Are there new admin users you didn't create?
- Are there unfamiliar plugins or themes?
Notify relevant parties: If you collect customer data, check your local data breach notification requirements. If your site is for a client, inform them immediately.
Put the site in maintenance mode: To protect visitors while you clean the site, create a simple maintenance.html file and use .htaccess to redirect all traffic to it:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/maintenance\.html$ RewriteRule ^(.*)$ /maintenance.html [R=302,L]
01
Back Up the Infected Site
Before making any changes, back up the infected site — files and database.
This sounds counterintuitive. Why back up a compromised site?
- You need the database backup to restore your content after cleaning (the malware is in files, not your posts and pages)
- It preserves evidence for investigation
- If your cleanup attempt goes wrong, you can return to this state
Via cPanel: Go to Backup Wizard → Back Up → Full Backup → Download the backup to your local computer.
Via FTP: Download the entire WordPress directory to your computer.
Important: Keep this backup separate and clearly labelled as "infected backup" — don't accidentally restore malware from it later.
02
Change All Passwords Immediately
Every password associated with your WordPress site must be changed right now — before starting any cleanup. This closes the door on the attacker's current access methods.
Change these passwords:
- All WordPress admin account passwords
- Your hosting account / cPanel password
- FTP/SFTP password
- Database (MySQL) user password — update
wp-config.php with the new password
- All email accounts associated with your domain
- Your domain registrar account password
Regenerate WordPress security keys: In wp-config.php, replace the auth keys and salts with freshly generated ones from api.wordpress.org/secret-key/1.1/salt/
Pro Tip: Regenerating security keys invalidates all existing login sessions — including any sessions the attacker may have active. Do this immediately.
03
Scan and Identify All Infected Files
Now find every piece of malicious code on your site.
Method A: Wordfence Scan (If You Can Access wp-admin)
- Install and activate Wordfence Security
- Go to Wordfence → Scan
- Click Start New Scan
- Review results — files marked "Unknown file in WordPress core" are prime suspects
- For modified files, use the "Restore" option to replace them with clean versions
Method B: Sucuri SiteCheck + Server Scan
Run the free Sucuri SiteCheck for blacklisting status. Then install the Sucuri Security plugin for server-side file integrity monitoring.
Method C: Manual File Inspection via FTP
Sort your FTP client by "Date Modified" — files modified around the time of the compromise are prime suspects. Look for:
// Base64 encoded malicious code
eval(base64_decode('...'));
// Variable function execution
$a = 'system'; $a('command');
// Hidden iframes
<iframe src="http://malicious-site.com" width="0" height="0">
- Any PHP files in
wp-content/uploads/ — uploads should not contain PHP
- Unfamiliar PHP files like
wp-load2.php, xmlrpc2.php — subtle variations of legitimate filenames
- Check
.htaccess for unexpected redirect rules
04
Clean the Infection
Replace WordPress Core Files: Download a fresh copy of WordPress from wordpress.org. Delete wp-content from the download. Upload everything else, overwriting existing files.
Remove Unknown and Suspicious Files: Any PHP files in wp-content/uploads/ must be deleted — these are almost always backdoor web shells. Any unfamiliar PHP files in your root directory should be deleted.
Clean Infected Theme and Plugin Files:
- Plugin file: Delete the entire plugin folder via FTP and reinstall from wordpress.org
- Theme file: If from wordpress.org, delete and reinstall. If custom, carefully review and remove malicious code manually
- Custom file: Review and remove injected code — malware is usually at the top or bottom of the file
Clean the Database:
-- Check for eval/base64 in post content
SELECT ID, post_title, post_content FROM wp_posts
WHERE post_content LIKE '%eval(%'
OR post_content LIKE '%base64_decode%';
-- Check wp_options for suspicious data
SELECT option_name, option_value FROM wp_options
WHERE option_value LIKE '%eval(%'
OR option_value LIKE '%base64_decode%';
-- Check for unknown admin accounts
SELECT user_login, user_email, user_registered FROM wp_users;
For any results, examine the content and remove the malicious portions carefully. Delete any users you don't recognise.
Remove Malicious .htaccess Rules: Replace with the standard WordPress .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
05
Identify and Close the Entry Point
Cleaning the malware without closing the entry point means your site will be reinfected — often within hours.
Common entry points:
- Compromised admin credentials: If an attacker logged in with valid credentials (through brute force or phishing), changing all passwords (Step 2) closes this.
- Vulnerable plugin or theme: Check your security plugin's logs and server access logs for requests to specific plugin or theme files before the compromise. Update or remove the affected plugin/theme.
- File upload vulnerability: Malware in your uploads folder indicates a file upload vulnerability — usually in a form plugin or WooCommerce that allowed PHP file uploads.
- Compromised hosting account: If your cPanel or FTP credentials were stolen, change them and consider enabling IP restrictions for admin access.
- Nulled/pirated theme or plugin: If you installed any pirated software, remove it completely — it was almost certainly the infection vector. Replace with legitimate alternatives.
Critical: If you installed any nulled/pirated themes or plugins, remove them immediately. They almost always contain pre-installed malware and are the most common infection vector for non-technical WordPress users.
06
Harden the Site After Cleaning
After cleaning, implement hardening measures to prevent reinfection:
- Update WordPress core, all plugins, and all themes to the latest versions
- Delete any deactivated plugins and unused themes
- Install and configure Wordfence Security
- Enable two-factor authentication on all admin accounts
- Change the WordPress login URL (WPS Hide Login)
- Set correct file permissions (644 for files, 755 for directories)
- Protect
wp-config.php in .htaccess
- Disable PHP execution in the uploads directory
- Set up UpdraftPlus for daily automated backups to a remote location
- Set up UptimeRobot for uptime monitoring
Critical: Block PHP in uploads directory — Add a new .htaccess file inside wp-content/uploads/ with:
<Files *.php>
deny from all
</Files>
This prevents any PHP files in the uploads directory from being executed — a critical protection against file upload attacks.
07
Request Review from Google and Hosting Provider
Google:
- Go to Google Search Console → Security Issues
- Review what Google found
- After cleaning, click Request a Review
- Describe the steps you took to clean the site
- Google typically reviews within 1–3 days
If your site shows the "Deceptive site ahead" warning, it's on Google's Safe Browsing blacklist. Cleaning and requesting review in Search Console automatically triggers Safe Browsing review too.
Your hosting provider:
- Contact support and explain you've cleaned the site
- They'll typically scan for malware before reinstating
- Ask them to review your access logs to help identify the entry point
Other blacklists: Check your site against multiple blacklists using mxtoolbox.com/blacklists.aspx and request removal from any that have blacklisted you.
When to Call in Professional Help
Some hack scenarios are complex enough to warrant professional assistance:
- You can't identify all infected files despite multiple scans
- Malware keeps reappearing after cleaning (persistent backdoor)
- Your database has been extensively modified
- You're not comfortable with FTP or server-level access
- The site collects customer payment data (PCI compliance may be required)
- You need forensic analysis for legal or insurance purposes
Professional options:
- Sucuri Malware Removal (premium plan) — Professional team cleans your site with guaranteed results
- Wordfence Site Cleaning (one-time service, approximately $490) — Wordfence security experts perform a full manual cleanup
- WordPress development agencies (like ours) — Comprehensive cleanup, hardening, and post-recovery monitoring
Frequently Asked Questions
Q: Should I restore from a backup instead of cleaning?
A: Only if you have a clean backup from before the compromise. Check your backup dates against when the malware appeared — restoring a backup that itself contains malware just takes you back to the infected state. If you have a clean pre-compromise backup, restoring it is faster and more reliable than manual cleaning.
Q: My site keeps getting rehacked after I clean it. Why?
A: A persistent backdoor is being missed in your cleanup. Common hiding spots: PHP files in the uploads directory, modified wp-config.php, unknown admin users, malicious code in functions.php, or infected database entries. Consider using a professional malware removal service with a guarantee.
Q: How long does it take to get off Google's blacklist after cleaning?
A: After submitting a review request in Search Console, Google typically responds within 1–3 days. The "Deceptive site ahead" warning is removed once Google confirms the malware is gone.
Q: Will my SEO rankings recover after a hack?
A: Usually yes, over time. The biggest impact is the duration of the infection and whether Google indexed spam pages. Remove all malicious content, submit a clean sitemap, and monitor Search Console. Rankings typically recover within 2–8 weeks after a clean site review.
Final Thoughts
A hacked WordPress site is serious — but it's recoverable. Work through this guide systematically: back up, change passwords, scan, clean files, clean the database, close the entry point, harden the site, and request blacklist review.
Speed matters — every day your site remains compromised, more visitors see malware warnings, more SEO damage accumulates, and more data is potentially at risk.
If you're unsure about any step or need the site cleaned urgently, our WordPress security team handles hack recovery regularly — from initial assessment to full cleanup and hardening.
Contact us immediately