WordPress is a powerful open-source platform, but if not properly maintained, it is a common target for hackers. This guide covers everything: detection, cleanup, core file verification, plugin checks, and future prevention.
1. Why WordPress Sites Get Hacked
Common reasons include:
-
Outdated WordPress core, themes, or plugins
-
Nulled, unofficial, or pirated plugins/themes
-
Weak admin, FTP, or database passwords
-
Disabled auto-updates
-
Malware injected via uploads or modified files
Prevention is always easier than cleanup.
2. Prerequisites
Before attempting a cleanup, ensure:
-
Backups: Make a full backup of the website (files + database).
-
cPanel Access: Ensure you can access File Manager, phpMyAdmin, and WordPress Manager.
-
Passwords: Prepare to reset all admin, FTP, and database passwords.
-
Plugins: Only keep official plugins/themes from WordPress.org or trusted developers.
3. Enable Automatic Updates
Why: Regular updates reduce the chance of hacks.
From WordPress Dashboard
-
Dashboard → Updates → Enable auto-updates for WordPress core, plugins, and themes
From cPanel
-
Softaculous/WordPress Manager → Enable automatic updates for:
-
Core files
-
Plugins
-
Themes
-
4. Detect Hacked Files
Step 1: Check Last Modified Files
-
cPanel → File Manager → Navigate to WordPress root
-
Sort by Last Modified
-
Red flags: recently modified files without your knowledge
Step 2: Standard WordPress Architecture Check
Root Folders:
-
wp-admin/ -
wp-content/ -
wp-includes/
Important Files:
-
index.php
<?php
define( 'WP_USE_THEMES', true );
require __DIR__ . '/wp-blog-header.php';
-
.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
-
Any deviation, encoded text, or extra PHP code in these files is a malware indicator.
Step 3: Check for Malicious Files
-
Look for:
-
base64_decode,eval(),gzinflate -
Random files like
wp-vcd.php,class.wp.php -
.phpfiles inwp-content/uploads/
-
5. Verify Plugins & Themes
-
Only official plugins from WordPress.org
-
Delete unused, nulled, or unverified plugins
-
Check recently modified plugin files
6. Reinstall WordPress Core
Why: Ensures no malware in core files.
Steps:
-
Download fresh WordPress from wordpress.org
-
Replace
wp-admin/andwp-includes/folders -
Do NOT replace
wp-content/(you’ll lose your themes/plugins) -
Verify
index.phpand.htaccessare standard
7. Reset All Passwords
Immediately reset:
-
WordPress admin users
-
cPanel / FTP accounts
-
Database users
8. Scan & Monitor
-
Install security plugins:
-
Wordfence
-
Sucuri Security
-
-
Enable real-time file change monitoring
-
Schedule regular scans
9. Prevention Best Practices
-
Keep WordPress, themes, and plugins updated
-
Use strong passwords for all accounts
-
Enable auto-updates
-
Remove unused plugins/themes
-
Regular backups via cPanel or plugins
-
Check last modified files periodically
-
Monitor uploads folder for PHP files
10. When to Contact Support
Contact our hosting support if:
-
Malware persists after following the steps
-
You need ORG enablement or server-level malware scan
-
Files are being re-infected repeatedly