Malware on a WordPress site doesn't always announce itself. Unlike a defaced homepage or a browser warning, many forms of WordPress malware operate silently — stealing data, sending spam, injecting SEO links, or building a botnet — while your site appears completely normal to you.
By the time most site owners discover the infection, it has been active for weeks or months. That's what makes WordPress malware particularly dangerous: its invisibility.
Most malware is invisible to site owners
This guide covers every type of WordPress malware, every method to detect it, and a complete removal process for clearing infections — whether you're dealing with a simple code injection or a sophisticated multi-file backdoor.
What Is WordPress Malware?
WordPress malware is malicious code that has been injected into or installed on a WordPress site without the owner's authorisation. It encompasses a wide range of threats:
- Backdoors — Hidden code that gives attackers persistent access to your server even after you change passwords. Often disguised as legitimate WordPress files or injected into existing files.
- SEO spam / pharma hack — One of the most common WordPress infections. The attacker injects hidden links to pharmaceutical, gambling, or adult sites into your pages — boosting their own SEO while damaging yours. Often only visible to search engine bots.
- Redirect malware — Rewrites
.htaccess or injects JavaScript to redirect visitors (or only mobile visitors, or only visitors from search engines) to malicious sites.
- Drive-by downloads — Injects scripts that attempt to download malware to your visitors' computers automatically when they visit your site.
- Phishing pages — Creates fake login pages for banks or payment processors on your server, using your domain's reputation to avoid blacklisting.
- Cryptomining scripts — Uses your visitors' (or your server's) CPU to mine cryptocurrency, causing performance problems.
- Mailer/spam scripts — Uses your server to send thousands of spam emails, leading to your domain and server IP being blacklisted.
- Data harvesting — Steals form submissions, WooCommerce orders, login credentials, and credit card data from your site.
Signs Your WordPress Site Has Malware
Visible to visitors:
- Browser security warnings ("Deceptive site ahead")
- Unexpected redirects to other websites
- Pop-ups or ads that aren't part of your site
- New pages you didn't create (often pharmaceutical or casino content)
- Site defacement — your content replaced with attacker's message
Visible to you in admin:
- Unknown admin users
- Unfamiliar plugins or themes installed
- Settings you didn't change have been changed
- Emails being sent from your domain you didn't send
In search results:
- Google showing unfamiliar pages from your domain in search results
- Google Search Console Security Issues alert
- Your site title/description in search results showing spam content (Japanese keyword hack, pharma hack)
Technical/hosting signs:
- Hosting account suspended for malware or spam
- Unexplained server resource spikes
- Your domain on email blacklists
- Error logs showing suspicious activity
What you WON'T necessarily see: Many malware types are specifically designed to hide from logged-in admin users. SEO spam is often only visible to search engine bots. Redirect malware often only fires for mobile visitors or visitors arriving from Google.
How to Scan WordPress for Malware
01
Wordfence Security Scanner
Wordfence provides the most comprehensive server-side malware scanner available in a free WordPress plugin.
- Install and activate Wordfence Security (free)
- Go to Wordfence → Scan
- Click Start New Scan
- Wordfence scans all WordPress core files, all plugin files, all theme files, files in wp-content/uploads, and your database
- Review the results — issues are ranked by severity (Critical, High, Medium, Low)
What Wordfence flags:
- Files that don't match their official versions
- Known malware signatures
- Suspicious code patterns (eval/base64 combinations, etc.)
- PHP files in uploads directory
- Changed WordPress core files
- Unknown files in the WordPress installation
Pro Tip: Not everything Wordfence flags is malware — modified plugin/theme files may be legitimate customisations. Focus on Critical severity issues, files in unexpected locations, and files that Wordfence can compare against a known-good repository version.
02
Sucuri SiteCheck (Remote Scan — Free)
Visit sitecheck.sucuri.net and enter your URL. Sucuri SiteCheck:
- Checks your domain against major blacklists (Google, McAfee, Norton, etc.)
- Scans your publicly accessible HTML for malware signatures
- Checks for drive-by download scripts
- Looks for spam content and injected links
Limitation: SiteCheck only scans what's publicly visible — it can't scan server-side PHP files that don't produce output. Combine with server-side scanning for complete coverage.
03
MalCare Scanner
MalCare performs deep server-side scanning that checks every file — including obfuscated malware that uses variable functions or layered encoding to avoid signature-based detection.
- Install MalCare Security
- Go to MalCare → Scan
- Run a full site scan
- MalCare performs its analysis on its own servers (no performance impact on yours)
- Review results in the MalCare dashboard
MalCare's deep scanning is particularly good at finding sophisticated malware that simpler scanners miss.
04
Manual File Inspection
For a thorough investigation, manually inspect your files via FTP or SSH.
What to look for — PHP execution of encoded data:
eval(base64_decode('...long encoded string...'));
eval(gzinflate(base64_decode('...')));
eval(str_rot13('...'));
Variable function calls (obfuscated execution):
$func = 'system';
$func($_POST['cmd']);
Hidden iframes:
<iframe src="https://malicious-site.com" width="0" height="0" style="display:none"></iframe>
Using command line (SSH):
# Find files modified in the last 7 days
find /path/to/wordpress -mtime -7 -type f -name "*.php"
# Search for eval(base64_decode in all PHP files
grep -rl "eval(base64_decode" /path/to/wordpress --include="*.php"
# Find PHP files in uploads directory
find /path/to/wordpress/wp-content/uploads -name "*.php"
# Search for common malware patterns
grep -rl "str_rot13\|gzinflate\|eval\|base64_decode" /path/to/wordpress/wp-content/themes --include="*.php"
Also look for unfamiliar files with names that slightly mimic legitimate WordPress files — wp-logi n.php, wp-con fig.php, index_.php.
How to Remove WordPress Malware
01
Quarantine the Site and Back Up
Step 1: Quarantine — Put your site in maintenance mode to prevent visitors from being exposed to malware while you clean.
Step 2: Back Up Everything (Including Malware) — Back up files and database before making changes. You need the database (which holds your content) even though you don't want the malware.
Important: Never reinstall from your own backup if the backup is from during the infection period — it may contain malware. You need a clean backup from before the infection.
02
Reinstall WordPress Core
Download a fresh copy of WordPress from wordpress.org. Remove wp-content from the download. Upload all files to your server, overwriting existing ones.
This replaces every core file with a clean version — eliminating malware injected into core files like wp-settings.php, wp-load.php, and functions.php copies in core directories.
03
Reinstall Plugins and Themes
For every plugin: Delete its folder via FTP and reinstall from wordpress.org (or from the original purchase source for premium plugins). This guarantees clean plugin files.
For themes:
- Themes from wordpress.org: Delete and reinstall.
- Premium themes: Redownload from the original source (ThemeForest, the developer's site).
- Custom themes: Carefully review all PHP files and remove any injected code. The injections are usually at the top or bottom of files.
- Child themes: Review
functions.php and any custom PHP files thoroughly.
04
Clean the Database
Malware in the database — injected into post content, widget data, or option values — must be removed carefully.
Via phpMyAdmin — manual search:
-- Search post content for malware
SELECT ID, post_title, LEFT(post_content, 200)
FROM wp_posts
WHERE post_content REGEXP 'eval\(|base64_decode|<iframe|<script.*src=';
-- Check for malware in options
SELECT option_name, LEFT(CAST(option_value AS CHAR), 200)
FROM wp_options
WHERE option_value REGEXP 'eval\(|base64_decode|<iframe';
For any results, carefully edit the specific post or option to remove the malicious code while preserving legitimate content.
Via Wordfence: After the file cleanup, run another Wordfence scan — it will check the database for malware.
05
Remove Unknown Admin Users and Reset Passwords
-- View all users with admin role
SELECT u.user_login, u.user_email, um.meta_value AS capabilities
FROM wp_users u
JOIN wp_usermeta um ON u.ID = um.user_id
WHERE um.meta_key = 'wp_capabilities'
AND um.meta_value LIKE '%administrator%';
Delete any administrator accounts you don't recognise. Reset all remaining admin passwords to strong, unique values.
06
Remove PHP from Uploads Directory
Any PHP files in wp-content/uploads/ must be deleted — they're backdoors.
Then prevent future PHP execution in uploads by adding a .htaccess file inside the uploads folder:
<Files *.php>
deny from all
</Files>
07
Clean .htaccess
Replace your .htaccess with a clean version. Malware often inserts redirect rules that only fire for certain user agents or referrers.
Go to Settings → Permalinks → Save Changes to regenerate a clean .htaccess.
08
Verify the Cleanup
After cleaning, run through this verification checklist:
- Run a full Wordfence scan — should report no threats
- Run Sucuri SiteCheck — should report no blacklisting
- Check Google Search Console Security Issues
- Test your site in an incognito window as a first-time visitor (not logged in)
- Test with Google's Mobile-Friendly Test (which renders your page as Googlebot would, helping reveal SEO spam hidden from admins)
Preventing Reinfection
- Change all passwords — WordPress admin, hosting, FTP, database, email.
- Update everything — WordPress, all plugins, all themes.
- Delete unused plugins and themes — Even deactivated plugins can be exploited.
- Install Wordfence and configure the firewall — Active protection against future attacks.
- Set up file monitoring — Wordfence or Sucuri will alert you within minutes of any file changes.
- Block PHP execution in uploads — The
.htaccess rule above is essential.
- Enable 2FA — Makes credential-based reinfection nearly impossible.
- Regular backups — If you're ever reinfected, a clean backup means recovery in minutes.
Frequently Asked Questions
Q: My Wordfence scan shows no malware but my site is still blacklisted. Why?
A: There are a few possibilities. The malware may have been cleaned but Google's blacklist hasn't updated yet (request a review in Search Console). Or the malware is in the database rather than files. Or it's using server-side cloaking and only visible to Google's bot. Check Sucuri SiteCheck and test your site as Googlebot using a user agent switcher.
Q: How did my WordPress site get malware if I keep it updated?
A: Updates patch known vulnerabilities, but other vectors exist: brute-forced admin credentials, compromised FTP passwords, vulnerable hosting neighbours (cross-site contamination on shared hosting), or zero-day vulnerabilities in plugins before patches are available.
Q: Can malware get into my WordPress database from just file-based malware?
A: Yes. Once an attacker has PHP file execution on your server, they can read, write, and modify your database from those PHP backdoors. This is why both file and database scanning is necessary.
Q: Is it faster to just restore from a backup than clean manually?
A: If you have a verified clean backup from before the infection, yes — restoring is faster and more reliable. The challenge is confirming the backup is clean. If you're not certain when the infection started, cleaning is safer than potentially restoring an infected backup.
Final Thoughts
WordPress malware removal requires thoroughness. A partial cleanup that misses one backdoor file or one infected database record means reinfection — usually within days.
Work through the detection methods to understand the full scope of the infection. Then clean systematically: core files, plugins, themes, database, .htaccess, admin users, and passwords. Verify with multiple scanners before declaring the site clean.
If the infection is complex, persistent, or if your site handles sensitive customer data, professional malware removal is the safest option — the cost is far less than the damage of a prolonged compromise.
Contact our security team