Discovering that your WordPress site has been hacked is a stressful experience. You might see a red "Deceptive site ahead" warning from Google, find strange spam links in your footer, or notice a massive spike in server CPU usage due to crypto-mining malware.
This ultimate malware removal guide provides a precise, technical incident response plan. We will cover how to identify the infection, safely quarantine your environment, manually clean the database and core files, and implement post-incident hardening to ensure the hackers cannot return.
Need immediate help?
If your site is currently hacked or showing warnings, our incident response team can help right now.
1. Incident Response: Containment
The moment you suspect a breach, you must act to contain the damage. A hacked site can actively spread malware to your visitors or be used to launch DDoS attacks against other servers.
Take the Site Offline (Maintenance Mode)
Do not allow visitors to access the infected site. You can force maintenance mode by creating a .maintenance file in your WordPress root directory containing the following PHP code:
Upgrade to Nexura Pro
Get enterprise-grade protection. Block zero-day exploits, advanced malware, and brute-force attacks instantly.
LIMITED TIME LAUNCH OFFER
<?php $upgrading = time(); ?>
Change ALL Passwords
Assume all credentials are compromised. Immediately change the passwords for:
- Your hosting control panel (cPanel, Plesk)
- SSH/SFTP accounts
- The MySQL database user
- All WordPress administrator accounts
2. Backing Up the Infected State
It sounds counterintuitive, but you must back up the hacked site before touching anything. If you make a mistake during the manual cleanup and break the site entirely, you need a restore point. A forensic backup also allows security professionals to analyze how the breach occurred later.
Use SSH or your hosting file manager to create a `.tar.gz` archive of the `public_html` directory and export the database via `mysqldump`.
3. Manual Core File Replacement
Hackers frequently modify WordPress core files (like wp-includes/functions.php or wp-settings.php) to hide their backdoors. Finding these modifications manually is nearly impossible.
The fastest and safest way to clean the core is to replace it entirely:
- Download a fresh copy of WordPress from WordPress.org.
- Delete the
wp-adminandwp-includesdirectories from your server. - Upload the fresh
wp-adminandwp-includesdirectories. - Upload the core files in the root directory (like
wp-login.php), overwriting the old ones. - CRITICAL: Do not overwrite
wp-config.phpor thewp-contentfolder!
4. Cleaning the wp-content Directory
The wp-content directory contains your themes, plugins, and uploads. This is where 99% of malware resides.
Purging the Uploads Folder
The wp-content/uploads folder should only contain media (JPG, PNG, PDF, etc.). It should never contain PHP files. Hackers use vulnerable file upload forms to drop "web shells" (e.g., b374k.php or wso.php) here.
Run a search via SSH to find and delete all PHP files in the uploads directory:
find wp-content/uploads -type f -name "*.php" -delete
Reinstalling Plugins and Themes
Similar to the core files, do not try to manually clean infected plugins. Delete the plugin folder entirely via FTP/SSH and reinstall a fresh copy from the WordPress repository or the premium developer's website. If you manually modified a theme, you must compare it against a clean backup using a diff tool.
5. Cleaning the Database
Malware isn't just in files; it lives in the database. Attackers inject spam links, create rogue admin users, or insert malicious JavaScript into the wp_options or wp_posts tables (Stored XSS).
- Check Users: Go to the
wp_userstable in phpMyAdmin. Delete any administrators you do not recognize. - Check Options: Hackers often change the
siteurlorhomeoptions inwp_optionsto redirect your traffic. Verify these values are correct. - Check Posts: Search the
wp_poststable for common malware strings like<script src="http://evil...or base64 encoded payloads.
6. Automated Malware Cleanup with Nexura Security
Manual cleanup requires significant technical expertise and takes hours. Furthermore, if you miss a single backdoor, the hacker will reinfect the site the very next day.
Nexura Security Pro completely automates this process:
- Tokenizer-Based Scanner: Nexura uses PHP's AST engine to deeply analyze code structure, finding heavily obfuscated malware that regex scanners miss.
- One-Click Auto-Fix: If malware is found in a core file or recognized plugin, Nexura can automatically download a clean version and replace the infected file.
- AI Deep Scan: Suspicious files are sent to Cloudflare/OpenAI for deep AI analysis, generating instant patches for zero-day injections.
7. Post-Incident Hardening
Once the site is clean, you must ensure it stays clean. Implement these mandatory steps:
- Regenerate your WordPress SALT keys in
wp-config.phpto force all users to log in again. - Update all plugins, themes, and WordPress core to their latest versions.
- Install a Web Application Firewall (WAF) to block the vulnerability that caused the breach in the first place.
- Submit your site to Google Search Console for a malware review to remove the "Deceptive site ahead" warning.
