WordPress index hacked page recovery
Introduction
A hacked WordPress website can be a frustrating experience for any website owner. One of the most common signs of a compromise is when hackers modify the index.php file to display their own messages, logos, advertisements, or defacement pages instead of your website content. In some cases, attackers may also delete administrator accounts, preventing you from accessing the WordPress dashboard.
While restoring the affected files can quickly bring your website back online, it is important to understand that file replacement alone does not remove the vulnerability that allowed the attack. This guide explains how to restore compromised WordPress index files, recover a deleted administrator account, and take additional security measures to prevent future attacks.
Step 1: Access File Manager
- Log in to your cPanel account.
- Open File Manager.
- Navigate to your WordPress document root:
- Primary domain:
public_html - Addon domain: The corresponding folder inside
public_html.
- Primary domain:
Step 2: Restore the Main Website Index File
- Locate the
index.phpfile in the WordPress root directory. - Right-click the file and select Edit or Code Editor.
- Remove all existing contents.
- Replace them with the default WordPress
index.phpcode:
- Save the file.
Step 3: Restore the WordPress Admin Index File
- Open the
wp-admindirectory. - Locate the
index.phpfile. - Edit the file and remove all existing content.
- Replace it with the default WordPress admin index code:
- Save the file.
Step 4: Verify Website Access
- Refresh your website homepage.
- Clear your browser cache if necessary.
- Confirm that both the website and WordPress admin panel are loading correctly.
Alternative Fix: Upload Original Theme Files
In some situations, attackers modify theme files rather than WordPress core files. If your website continues to display unauthorized content after restoring the index files:
- Download a clean copy of your active theme.
- Upload the original theme files to your server.
- Overwrite the compromised files.
- Verify that the theme’s
index.phpand other template files have not been modified.
This method can help restore the website if the infection is limited to the theme directory.
Recovering a Deleted Administrator Account
Some attackers remove administrator accounts from the database, making it impossible to log in to the WordPress dashboard.
Using phpMyAdmin
- Log in to cPanel.
- Open phpMyAdmin.
- Select your WordPress database.
- Open the
wp_userstable. - Click Browse.
If the primary administrator account is missing:
- Select another administrator account (for example, ID 2 or ID 3).
- Click Edit.
- Update the following values:
| Field | Value |
|---|---|
| ID | 1 |
| user_login | Your preferred username |
| user_pass | Set Function = MD5, Value = Your password |
| user_nicename | Your username |
| display_name | Your username |
- Click Go to save the changes.
You should now be able to access the WordPress admin dashboard using the updated credentials.
Additional Security Checks
After regaining access to your website, perform the following checks:
Scan for Malware
Use a reputable WordPress security plugin or malware scanner to identify malicious files, hidden backdoors, and unauthorized code injections.
Review Installed Plugins
- Remove unused plugins.
- Update all active plugins to their latest versions.
- Replace abandoned or unsupported plugins.
Update WordPress Core and Themes
Running outdated software is one of the leading causes of WordPress compromises. Ensure that WordPress core, themes, and plugins are fully updated.
Change All Passwords
Immediately change:
- WordPress administrator passwords
- cPanel passwords
- FTP/SFTP passwords
- Database passwords
- Email account passwords associated with the website
Check User Accounts
Review all WordPress users and remove any suspicious administrator accounts created by attackers.
Enable Security Protection
Consider implementing:
- Two-factor authentication (2FA)
- Login attempt limits
- Web Application Firewall (WAF)
- Regular malware scanning
- Automated backups
Conclusion
A hacked WordPress index page can disrupt your website and impact your visitors’ trust. Restoring the default index.php files and recovering deleted administrator accounts can help bring your website back online quickly. However, these actions only address the visible damage. To fully secure your website, you must identify the source of the compromise, remove any malware or backdoors, update all software components, and strengthen your security practices.
Regular backups, timely updates, strong passwords, and proactive security monitoring are essential for protecting your WordPress website against future attacks. By following the recovery and security recommendations outlined in this guide, you can restore your website and significantly reduce the risk of another compromise.
