
Cleaning a Site Step by Step
I’ve spent nine years un-building client sites, and if there is one thing I’ve learned, it’s that most “security experts” want to sell you a subscription to a plugin that just screams at you in red text. They treat a breach like a mysterious act of God, but it’s rarely that poetic. Usually, it’s just a series of bad, sloppy decisions—a neglected plugin here, a weak password there—that left the door wide open. If you’re looking for a magic button to fix everything, you’re in the wrong place; learning how to audit and clean a hacked site isn’t about running a shiny scanner and hoping for the best, it’s about manually tracing the intruder’s logic through your file directory.
I’m not here to sell you a monthly retainer or a bloated “all-in-one” security suite. I’m going to show you how I actually do it: by looking for the specific, messy footprints left behind in your code. We are going to strip back the layers, identify the actual entry point, and clean the mess without accidentally breaking your entire layout in the process. This is a no-nonsense roadmap for reclaiming your site, built on the reality of what happens when things actually go wrong.
Table of Contents
Identifying Malicious Code Injections in Their Mess

When I’m digging through a compromised directory, I’m not just looking for a single “bad” file; I’m looking for the logic of the intruder. Most people think a hack is a single event, but it’s usually a series of sloppy, frantic additions. To start identifying malicious code injections, you have to look for the stuff that doesn’t belong in the original architecture. I look for those weirdly named files—the ones like `wp-log-check.php` or `class-wp-cache-old.php`—that try to masquerade as legitimate system files. They usually hide in your `wp-content/uploads` folder or tucked away in a deep plugin directory, waiting for a cron job to trigger them.
You can’t just run a scanner and call it a day. A scanner tells you something is wrong, but it doesn’t tell you why the door was left open. I treat this like a server-side security audit, tracing the injection back to the specific vulnerability that allowed it. Was it an outdated plugin? A weak password? Or did someone exploit a flaw in a theme that was trying to be too clever with its own functions? You have to find the entry point, or you’re just playing a high-stakes game of Whac-A-Mole.
A Ruthless Server Side Security Audit of Their Mistakes

Once you’ve poked around the files and found the obvious injections, it’s time to look at the foundation. Most people stop at the application layer, but if you aren’t performing a proper server-side security audit, you’re just putting a fresh coat of paint on a house with a cracked foundation. I’ve seen it a dozen times: a developer cleans the WordPress directory, feels heroic, and then gets hit again forty-eight hours later because the attacker still has a backdoor sitting in a rogue cron job or a compromised `.htaccess` file. You have to look at the environment itself—the permissions, the PHP configurations, and those weird, unauthorized scripts hiding in the root directory that have nothing to do with your actual site.
This isn’t just about finding a single bad line of code; it’s a full-scale website security vulnerability assessment of your entire hosting environment. I don’t just check if the files are “clean”; I check if the server is allowing them to be dirty in the first place. If your file permissions are set to 777 because some plugin developer was too lazy to write proper code, you haven’t actually fixed anything. You’ve just waited for the next intruder to walk through the front door.
Five ways to stop playing whack-a-mole with their leftover code
- Stop trusting your file manager; if the hacker gained admin access, they’ve likely rewritten the very tools you’re using to look for them. Get in via SFTP or SSH so you’re looking at the raw reality, not the version the malware wants you to see.
- Check your wp-config.php file like it’s a crime scene. I’ve seen so many “clean” installs that still had a single, tiny line of obfuscated junk tucked between the database credentials, acting as a backdoor for the next round of attacks.
- Audit your users, and don’t just look at the names. I’ve spent way too many hours deleting “ghost” admins—accounts with names like ‘wp_support’ or ‘system_update’—that were created mid-breach to give the intruder a permanent seat at the table.
- Scrutinize your plugin directory for anything that doesn’t belong, especially things that look like legitimate plugins but have slightly off names. Hackers love to drop a “Contact Form 7” clone into your folder because you’ll likely glance right past it.
- Reset every single credential, but do it in the right order. If you change your WordPress admin password before you change your database password and your FTP keys, you’re just handing the keys back to them through a different door.
Cleaning the slate

At this point, you’ve done the heavy lifting. You’ve sifted through the injected scripts, hunted down those rogue files hiding in your directory, and audited the server to ensure the backdoor is actually shut. It’s exhausting work, but you can’t just patch the holes and hope for the best; you have to understand the logic of the breach to prevent it from happening again. If you leave one messy line of code or one poorly configured permission setting behind, you’re basically leaving the keys under the mat for the next intruder. Cleaning a site isn’t about a quick scan; it’s about reclaiming your technical sovereignty from someone who thought your code was their playground.
Moving forward, my advice is to stop treating security like a chore you do once a year and start treating it like part of your design process. A clean, lean site isn’t just faster and more professional—it’s inherently harder to break. Don’t let the stress of this cleanup make you fear the code; let it make you more intentional about every plugin you install and every theme decision you make. You’ve seen the mess, you know how it starts, and now you have the tools to build something that actually stays yours. Now, go get some coffee and start building something better.