Blog
How to Remove Malware from Your Website (Without Losing Everything)

Key Takeaways
- Don’t delete everything. Back up your infected site first — you may need those files for forensic analysis or to recover content.
- Clean systematically. Replace core CMS files, manually review custom files, and check your database for injected code.
- Remove backdoors, not just symptoms. Hackers almost always leave hidden access points. If you skip this step, they’ll be back.
- Update and harden after cleanup. Patching vulnerabilities and changing every password is non-negotiable.
- Monitor for 30+ days. Reinfection often happens within the first few weeks if a backdoor was missed.
Step 1: Take Your Site Offline (Maintenance Mode)
The first thing you should do when you discover malware is limit the damage. Every minute your infected site stays live, it’s potentially:- Infecting your visitors’ devices
- Sending spam emails from your server
- Getting your domain blacklisted by Google and browsers
- Damaging your brand reputation
Step 2: Back Up Everything — Even the Infected Files
This sounds counterintuitive, but back up your entire site before you touch anything — malware and all. Why? Because:- You might accidentally delete legitimate files during cleanup
- You may need the infected files to identify how the hack happened
- Some malware hides in unexpected places, and you might need to compare file versions later
Step 3: Identify the Infection
Before you start deleting files, you need to understand what you’re dealing with. Website malware comes in many forms:- SEO spam injection — hidden links or pages stuffed with keywords for pharma or gambling sites
- Redirect malware — visitors get sent to malicious domains
- Backdoor shells — scripts that give attackers remote access to your server
- Cryptominers — code that uses your visitors’ browsers to mine cryptocurrency
- Phishing pages — fake login pages hosted on your domain without your knowledge
Scanning Tools
Use one or more of these to scan your site:- Sucuri SiteCheck (free) — scans for known malware, blacklist status, and errors
- Wordfence (WordPress) — deep server-side scanning with file integrity checks
- MalCare — automated scanning and one-click removal for WordPress
- Google Search Console — check “Security Issues” for any Google-detected problems
Step 4: Clean Infected Files (Core vs. Custom)
This is where the real website malware removal work begins. The approach differs depending on the type of file:Core CMS Files
If you’re running WordPress, Joomla, Drupal, or another CMS, the easiest way to clean core files is to replace them entirely with fresh copies from the official source. For WordPress malware removal specifically:- Download a fresh copy of WordPress from wordpress.org
- Delete the wp-admin/ and wp-includes/ directories on your server
- Upload the clean versions from the fresh download
- Do NOT delete wp-content/ — that’s where your themes, plugins, and uploads live
Custom Files (Themes, Plugins, Uploads)
Custom files require manual review. Look for:- PHP files in your /uploads/ directory (there should be almost none — uploads are typically images and documents)
- Recently modified files that you didn’t change
- Files with obfuscated code — long strings of base64_decode, eval(), str_rot13, or gzinflate calls
- Files with names designed to look legitimate like wp-settings-tmp.php or class-db.php in unusual directories
Step 5: Check Your Database for Injected Content
Malware doesn’t just hide in files. Attackers frequently inject malicious code directly into your database — especially in:- Post and page content — hidden iframes, JavaScript redirects, or spam links
- Widget areas — injected scripts in sidebar or footer widgets
- User tables — rogue admin accounts you didn’t create
- Options table — modified siteurl, home, or custom option values
Step 6: Remove Backdoors
Here’s the step most people skip — and exactly why they get hacked again a week later. Backdoors are hidden scripts that give attackers a way back into your site, even after you’ve cleaned the visible malware. They’re often:- Disguised as legitimate WordPress files (e.g., wp-page.php in the root directory)
- Hidden inside theme php files
- Embedded within image files using steganography techniques
- Placed in obscure directories like /assets/wp-content/languages/ or /assets/wp-includes/fonts/
| Pattern | Why It’s Suspicious |
| eval(base64_decode(...)) | Executes hidden encoded commands |
| preg_replace with /e modifier | Allows code execution via regex |
| assert() used with variables | Can execute arbitrary PHP |
| $_POST['cmd'] or $_GET['cmd'] | Accepts remote commands |
| file_put_contents + $_REQUEST | Writes attacker-controlled content to files |
Get a FREE Audit
We'll perform a comprehensive SEO, AEO, GEO & CRO audit of your website — completely free — and show you exactly how to outrank your competitors.
Don't have a site yet? Get in touch →
Step 7: Update Everything
Once your site is clean, update every piece of software immediately:- CMS core — update to the latest stable version
- Plugins — update all of them; delete any you’re not actively using
- Themes — update your active theme; delete inactive themes entirely
- PHP version — if your host supports it, upgrade to the latest stable PHP version
- Server software — ask your hosting provider about Apache/Nginx and MySQL updates
Step 8: Change All Passwords and Keys
Assume every credential associated with your site has been compromised. Change all of the following:- WordPress admin passwords (for every user, not just yours)
- Database password (update it in wp-config.php too)
- FTP/SFTP passwords
- Hosting control panel password
- SSH keys if applicable
- WordPress security keys and salts (use the WordPress salt generator to get fresh ones)
Step 9: Request a Google Review (If Blacklisted)
If Google flagged your site with a “This site may be hacked” or “Deceptive site ahead” warning, you’ll need to request a manual review after cleanup. Here’s how:- Log into Google Search Console
- Navigate to Security Issues
- Review the listed issues and confirm you’ve resolved them
- Click Request a Review
- Describe the cleanup steps you took in detail
Step 10: Monitor for Reinfection
You’re not done yet. The first 30 days after cleanup are critical. Set up ongoing monitoring to catch any reinfection early:- Install a security plugin like Wordfence or Sucuri with real-time file monitoring enabled
- Set up Google Search Console alerts for security issues
- Check your site weekly for unfamiliar files, new user accounts, or unexpected redirects
- Review server access logs for suspicious IP addresses or unusual request patterns
- Schedule regular backups so you always have a clean restore point
DIY vs. Professional Website Malware Removal
Not every hack requires a professional, but some definitely do. Here’s how to decide:| Factor | DIY Cleanup | Professional Removal |
| Best for | Simple infections, single-site owners with technical skills | Complex hacks, e-commerce sites, or repeated infections |
| Cost | Free (your time) | $150–$500+ depending on severity |
| Time | 4–12 hours depending on experience | Usually 24–48 hours |
| Thoroughness | Risk of missing backdoors or database injections | Comprehensive scan, cleanup, and hardening |
| Ongoing protection | You manage monitoring yourself | Often includes monitoring and a firewall |
| Risk | Possible data loss if mistakes are made | Minimal — professionals back up and verify |
How to Prevent Future Hacks
Once you’ve cleaned your site, take these steps to reduce the risk of it happening again:- Keep everything updated — CMS, plugins, themes, PHP
- Use a web application firewall (WAF) — Sucuri or Cloudflare can block malicious traffic before it reaches your server
- Limit login attempts — block IPs after repeated failed login attempts
- Disable file editing — add define('DISALLOW_FILE_EDIT', true); to your wp-config.php
- Use SFTP instead of FTP — encrypted file transfers prevent credential sniffing
- Choose quality hosting — hosts with proactive security monitoring catch infections faster
- Remove unused plugins and themes — every piece of inactive software is a potential attack surface
Frequently Asked Questions
How long does it take to remove malware from a website?
Will removing malware fix my Google rankings?
Can I just restore a backup instead of cleaning the infection?
How much does professional website malware removal cost?
Put this into action with eSEOspace
We help businesses grow with maintenance & support that actually performs. Explore the services behind this guide:
Get a FREE GEO/AEO/SEO Audit
We'll analyze your site's SEO, GEO, AEO & CRO — completely free — and show you exactly how to get found across Google and AI answers.
Don't have a site yet? Get in touch →
Great — your audit is on the way!
We'll send your free SEO/GEO/AEO/CRO audit within the next few hours. Where should we send it?
You're all set! ✓
Your free audit is being prepared — check your inbox in the next few hours. Talk soon!
On this page
- Key Takeaways
- Step 1: Take Your Site Offline (Maintenance Mode)
- Step 2: Back Up Everything — Even the Infected Files
- Step 3: Identify the Infection
- Step 4: Clean Infected Files (Core vs. Custom)
- Step 5: Check Your Database for Injected Content
- Step 6: Remove Backdoors
- Step 7: Update Everything
- Step 8: Change All Passwords and Keys
- Step 9: Request a Google Review (If Blacklisted)
- Step 10: Monitor for Reinfection
- DIY vs. Professional Website Malware Removal
- How to Prevent Future Hacks
- Frequently Asked Questions





