Say you log in on a Monday and your site is redirecting visitors to a sketchy pharmacy or throwing a strange database error. Finding out your site has been compromised is stressful, but acting quickly and methodically makes all the difference in getting things back to normal.
How Do I Know If My WordPress Site Was Hacked?
Most site owners discover a breach through visitor complaints, warning screens in browsers, or unexpected emails from their hosting provider. You might notice new administrative users you never created, or your search engine results pages might display unrelated product titles and spam links.
Sometimes the clues are more subtle. Your server resource usage might spike overnight, or your site speed might drop sharply due to unauthorized background scripts running on your server.
What Are the First Steps After Finding Malware on WordPress?
Take your site offline or put up a maintenance page immediately so visitors stop interacting with compromised content. Do not delete any files yet, because you need them later to understand how the attackers got in and what they changed.
Put the Site Into Maintenance Mode
Create a simple maintenance.php file in your root directory or use a server-level block to keep traffic away. This stops the malware from serving malicious payloads to customers or search engines while you work.
Notify Your Host
Contact your hosting support team right away to let them know you suspect a security incident. They can often check server error logs, isolate the account to prevent lateral movement, and tell you if other sites on your server were affected.
How to Run a Thorough Malware Scan
You need to scan every file on your server, not just the database or the wp-admin directory. Attackers often hide scripts inside upload folders, cache directories, or even core WordPress files where automated tools might miss them if signatures are outdated.
Use a trusted security plugin or a command-line scanner to check for unauthorized modifications. If your scanner flags modified core files, do not just edit them. You will need to replace them entirely with fresh copies from the official repository.
How to Find and Remove a Hidden Administrator User in WordPress?
Attackers almost always create a persistent backdoor admin account so they can regain entry even if you change your own password. Check your users list immediately and look for unfamiliar accounts holding administrator roles.
Sometimes malicious users are hidden from the standard dashboard interface through database manipulation or custom code snippets. If you suspect this, check your database directly using phpMyAdmin or a database management tool.
Inspect the wp_users Table
Open your database and look inside the wp_users and wp_usermeta tables for accounts you do not recognize. Delete the unauthorized rows, and make sure you check the capabilities meta field to ensure no other accounts were secretly granted administrator privileges.
For a deeper dive into hunting down these stealthy accounts, read our guide on Finding and Removing a Hidden WordPress Admin User before you close your database tab.
How Do I Clean Hacked WordPress Site Files?
Cleaning an infected site manually requires replacing every single core file and folder with a fresh download from WordPress.org. Do not attempt to open and edit core files to remove malicious code, as you might miss obfuscated lines or leave structural vulnerabilities behind.
Delete the wp-admin and wp-includes directories entirely via SFTP or SSH. Upload fresh copies of these folders from a verified source to guarantee no altered code remains in your core installation.
How to Inspect Themes and Plugins for Backdoors
Your plugins and themes require individual inspection because attackers frequently inject malicious code into existing files or create fake plugin folders. Delete any plugins or themes that are no longer actively maintained or that you do not recognize.
Reinstall every active plugin and theme by downloading fresh zip files from the official repository or your developer account. Check your wp-content/uploads folder carefully, as attackers love to hide executable PHP scripts inside image directories where security scans sometimes ignore them.
How to Check and Secure Your wp-config.php File
The main configuration file is a primary target for code injection because it holds your database credentials and security keys. Open wp-config.php and look for unexpected base64 encoded strings, eval statements, or remote inclusion calls.
Regenerate your WordPress security keys and salts immediately through the official online generator API. This invalidates all existing user cookie sessions across the entire site, forcing every logged-in user to authenticate again.
How Do I Fix Compromised WordPress Website Permissions?
Loose file permissions make it easy for malicious scripts to write themselves into your file system. Set your directories to 755 and your files to 644 across the entire WordPress installation to block unauthorized writing.
Your wp-config.php file should be locked down even tighter with 440 or 400 permissions if your server environment allows it. Speak with your host if you are unsure whether your server runs PHP as the file owner, as incorrect ownership settings can break your site when you tighten permissions.
Emergency WordPress Support: When to Bring in Professionals
Some security incidents run deeper than a simple script injection, involving root server compromises, complex database corruptions, or persistent re-infections that return hours after you clean them. If your site keeps breaking or you run an active e-commerce store losing revenue by the minute, handling it alone becomes too risky.
Professional recovery teams analyze server access logs, trace attack vectors, and patch the root vulnerabilities that caused the breach in the first place. You can learn more about managing these critical situations by reading WordPress Emergency Support: When to Call for Help to understand what professional intervention involves.
Quick Answers (FAQ)
Will my security plugin protect me?
Usually not if it was installed after the compromise occurred, or if the configuration relied entirely on default settings. Security plugins prevent many attacks, but a pre-existing infection often requires manual forensic cleaning.
Should I restore from a backup or try to clean the site?
It depends on how long the site has been infected, because backups taken after the hack occurred will only reintroduce the malware. If you have a clean backup from before the attack date, restoring it is often faster than manual cleaning.
How do attackers get into WordPress sites?
Most compromises happen through outdated plugins, vulnerable themes, reused passwords, or compromised developer FTP credentials. Keeping your software updated and enforcing strong authentication stops the vast majority of automated break-ins.
Can I check if my database was modified?
Yes, by reviewing database tables for unfamiliar administrator users, injected spam posts, or unauthorized options in the wp_options table. Exporting your database and running a text search for suspicious base64 strings is a reliable way to spot hidden payloads.
What should I do after cleaning the site?
Change all administrative passwords, rotate SFTP and database credentials, and implement two-factor authentication for every user role. Setting up a reliable schedule for the 3-2-1 Backup Rule: A Bulletproof WordPress Backup Strategy ensures you are never caught unprepared again.
The short version
- Put your site into maintenance mode and notify your hosting provider about the suspected breach.
- Scan and clean your file system, replacing all core files and compromised plugins with fresh copies.
- Remove hidden administrator accounts, rotate all passwords, and reset your database security keys.
- Tighten file permissions, remove unused software, and set up ongoing monitoring.
If you prefer to leave the recovery process to experienced professionals, our WordPress Hacked-Site Recovery team can clean your files, eliminate backdoors, and harden your setup securely.
Get a free audit covering security, updates, backups, and performance gaps. Takes 60 seconds to request and costs nothing.
