← All guides

Remove Malware from Hacked eCommerce Website: WooCommerce & Magento Recovery Guide

If you are reading this article, chances are your e-commerce site feels broken. Maybe the checkout process suddenly fails, customer payments seem to be routed incorrectly, or perhaps you just noticed bizarre chunks of code appearing in your footer. You have landed on a very scary page right now. It looks like you’ve been compromised.

. This error looks catastrophic and overwhelming, , it is one of the most common website issues we deal with - and it is . We are going to get this fixed.

I’m going to walk you through exactly what is happening on your site - what sophisticated attackers were doing there - and give you the precise, battle-tested steps that we use in professional recovery operations day. We aren’t just patching holes; we are rebuilding the entire security fortress from the ground up.

Because e-commerce sites hold real money and sensitive customer data, they attract highly sophisticated attackers. They aren’t messing around with random spam links; they are actively trying to steal credit card data (like Magecart skimming attacks) or redirect your customers entirely for their own gain. This guide is built specifically for those high-stakes platforms: WooCommerce and Magento.

We will proceed methodically, step by painful step. You do not have to panic right now. We just need to be thorough - that’s the only way we guarantee a clean slate.


Before You Start: The Golden Rules of Recovery (READ THIS FIRST)

Before you even look at touching a single file or running a command line prompt, we must first protect your ability to fix this mess and ensure that your actions don’t make the situation worse. These preliminary steps are . Treat them like triage before surgery.

  1. Do NOT Use Public Scanners: Never rely solely on a Google search result scanner or any general “malware remover” tool found online. Those tools are almost always too superficial and simplistic to detect complex, modern e-commerce attacks.
  2. The Backup Imperative (Crucial Step): You absolutely need a clean point in time to revert to. Immediately take all available backups: your entire database structure, all media files, and the full directory contents (wp-content for WordPress or core directories for Magento). If you can find one, restore a backup from before you noticed any issues, but do not run live operations on that old backup. Use it only as a safe reference copy.
  3. Isolate the Site: If your site is actively taking payments right now, immediately consider temporarily changing your payment gateway settings to “Maintenance Mode” or switching it entirely to manual order entry until we are done. You must stop the bleeding - stop any potential data loss or fraudulent transactions - before you can perform proper surgery.
  4. Document Everything: Write down step you take while working on the site - what specific file name changed, what database query ran, and exactly when it happened. This process creates an audit trail that is priceless later if we need to track back changes or confirm integrity.

Phase I: Identifying the Damage (The Symptoms)

. This initial check is crucial because before we can fix anything, we absolutely have to know exactly what damage needs cleaning up. Think of this phase like diagnosing your car engine; you need to spot the broken parts before you start replacing everything at random. Hackers leave specific forensic evidence behind when they compromise a site.

If your website is compromised - which sounds scary, but I promise we can figure it out - you might notice one or more of these symptoms:

E-commerce Specific Indicators

  • Payment Skimming: The checkout page may look perfectly normal to the customer, but when they enter their card details, the payment fails repeatedly. You also find logs showing unauthorized attempts to process transactions. This specific symptom is a major sign that JavaScript injection has occurred (this technique is often called Magecart).
  • Strange Redirects: Customers might suddenly be redirected away from your site to random parking pages or spam sites immediately after they complete an order.
  • Hidden Code/Obfuscation: If you have access to the source code - for example, by right-clicking on a page and selecting “View Page Source” - a developer will see massive blocks of nonsensical characters. You might also spot encoded strings like eval(base64_decode('...')), or JavaScript code that seems to be executing without any clear reason for it to exist there. This hidden code is often the hacker’s smoking gun.
  • Unexpected Files: You find random PHP files in directories where they absolutely should not be (for instance, finding a file named login-check.php directly in your main root folder).

General Website Indicators

  • Spam Comments/Content: Random foreign language text or excessive keyword stuffing appears on product pages or blog posts that you didn’t write.
  • Credential Changes: You find evidence that administrator usernames that you recognize are now associated with strange IP addresses, or the links used for password reset functions suddenly start failing.
  • Unusual Core Files: When checking critical directories like your wp-includes folder or core theme directories, you might discover files that were recently modified - make sure to check the file modification dates using FTP/SFTP tools.

Phase II: Understanding How They Got In (Common Causes)

. When you look at these attack methods, it sounds incredibly scary, but let me tell you something critical: most people assume they need some complicated zero-day exploit to get hacked. That is simply not true. The reality is far simpler and frankly, much more human. Hackers are opportunistic; they don’t need genius-level exploits - they just take the lowest hanging fruit they can find.

Here are the three most common ways e-commerce sites like yours get compromised, listed here in order of how often we see it:

  1. Outdated Software (The #1 Cause): Honestly, this is by far the biggest vulnerability I see all the time. If your WordPress core, WooCommerce plugin, or Magento theme has not received a security update for months - or worse, years - it almost certainly contains a known, public exploit that hackers can use easily. It’s like leaving the back door unlocked just because you forgot to change the lock on an old cabinet key.

  2. Weak Credentials & Brute Force: This is when basic human habits come into play. Using predictable login details like “admin/password” on an old site, or worse, reusing passwords across multiple services (like using your personal email password for FTP access), makes you a prime target for automated bot attacks. These bots aren’t clever; they are just guessing until they get lucky.

  3. Vulnerable Third-Party Plugins/Extensions: Sometimes the threat isn’t even obvious. A single, poorly coded plugin - even one that seems completely harmless and adds minor functionality - can introduce a massive security hole into the entire architecture of your site. They create entry points we didn’t know existed.

Phase III: The Definitive Fix - Step-by-Step Malware Removal

Please . I know this whole process looks overwhelming, but we are going through this methodically. We are going to work from the outermost layer - the server - inward, checking dependency piece by piece. This requires focus and patience, but following these steps will get us back online safely.

Step 1: Containment & Credentials Reset (Immediate Action)

Do these steps before you try to scan anything else. Why? Because the hacker might still have active access via a forgotten or un-reset credential. We need to lock them out first.

  1. Change ALL Passwords: This is . You must change:
  • WordPress Admin Password.
  • FTP/SFTP User and Password.
  • Database (MySQL/MariaDB) User and Password.
  • Hosting Control Panel Credentials (cPanel, Plesk).
  • Payment Gateway Credentials (PayPal, Stripe, etc.).
  1. Enable Two-Factor Authentication (2FA): Implement 2FA on the admin account immediately. Honestly, this is your single most important barrier against any future attacks, and it gives us peace of mind.
  2. Check Server Logs: Access your hosting control panel and look closely at Access Logs and Error Logs. Are you seeing multiple failed login attempts coming from strange or unexpected countries? Is there a sudden spike in errors related to specific files that seem random? These logs are digital footprints; they tell us who was knocking on the door, even if we successfully kicked them out.

Step 2: Auditing the Database (The Hidden Backdoor)

Here is where it gets tricky - hackers rarely just mess with visible files on your site. They inject persistent backdoors directly into your database tables, making them incredibly hard to spot and keeping their access active even after you delete a file.

For WordPress Users (WooCommerce):

  1. Check wp_options: This table is basically the brain of your site; it holds all core configuration settings. Hackers often insert malicious code or change crucial defaults, like the administrator’s primary email address, right here. Use a tool like phpMyAdmin to view this.
  • Look for any entries under option_name that seem completely unrelated to the normal function of your site (for instance, keys like temp_redirect_script or anything with long, random character strings). If you do not recognize what it is and cannot confidently explain its purpose, please delete it.
  1. Check User Roles: Go into the database structure and ensure there are no “ghost” user accounts in the wp_users table that you did not create or authorize. Delete them immediately, and then reset passwords for all remaining legitimate administrators to be safe.

For Magento Users:

  1. Magento relies heavily on its complex setup tables (you will often find critical data within structures like core_config_data or related system tables). Review these records extremely carefully for any changes regarding payment methods, shipping rates, or system emails that you did not authorize yourself.

Step 3: The File Audit (Finding the Payload)

This is where we become digital detectives and hunt down all the malicious code and backdoors. We are specifically looking for anomalies - files that were recently modified without explanation, or files placed in folders where they absolutely do not belong.

A. Technical Users (FTP/CLI Access):

  1. The Wildcard Search: Connect via SFTP/SSH and perform a search across your entire root directory (wp-content, includes, etc.). We are looking for file extensions that are not standard PHP, CSS, JS, or image formats. Pay special attention to any .php files that lack proper naming conventions or have been placed in non-standard, empty folders.
  2. Checking the Dot Files: Use SSH to list hidden configuration files by running the command: ls -al .
  • Look at .htaccess: This file is critical because it controls your entire URL rewriting rules for WordPress. Hackers love inserting malicious redirection rules here, forcing traffic through their spam sites or executing page-skimming attacks. You must compare this file against a known good backup copy immediately. Remove any line that looks like an unexpected redirect to an unknown domain (it will look something like RewriteRule ^(.*)$ http://badsite.com/$1 [L]).
  • Look at .env files: These environment configuration files - which are common in modern frameworks - are frequently dumped by hackers. They often reveal highly sensitive data, such as secret API keys or database credentials. You must delete any .env file that you did not personally create and manage.

B. Non-Technical Users (Using the Control Panel):

  1. Use your hosting provider’s File Manager tool to manually check for hidden directories and files that are named after random strings of letters or numbers. If you find a folder name that makes absolutely no sense in context, delete it immediately.
  2. Check Themes: Manually audit the functions.php file in ** theme that is currently active or even inactive (especially child themes). Hackers frequently inject their code right here because it’s an easy target and often gets overlooked during a standard cleanup.

Step 4: Code Deep Dive - The Obfuscation Hunt

If your site has been compromised, you should assume the malware is hidden using advanced techniques specifically designed to prevent simple searches from finding them. This final step is about looking for the “smell” of malicious code.

What We Are Looking For:

  • eval(base64_decode('...'): When you see this, stop and pay attention. This is a classic sign of highly obfuscated code. The hacker has encoded their dangerous PHP payload (which could be stolen JavaScript or a database query) into Base64 format, and then wrapped the whole thing in eval(). If you find this anywhere that doesn’t belong to a trusted security plugin or core system function, delete the entire line of code.
  • Inline Script Tags: Look for <script> tags placed directly within files like footer.php or various theme templates that contain JavaScript code unrelated to your site’s actual functionality (for example, tracking pixels pointing toward an unknown endpoint).

Advanced Recovery: What Experts See That You Missed (Battle Scars)

. I know looking at these error messages feels overwhelming, but please understand that what we are dealing with here is often not just simple file deletion; it’s finding the attacker’s hidden escape routes - what we call backdoors. I’ve seen sites fail even after basic cleaning steps, only to be reinfected a week later. Why? Because the attacker left behind a persistent mechanism. Here are three high-level checks that often save the day when simple scans just can’t get deep enough:

1. The Cron Job Audit

Hackers understand that scheduled tasks (cron jobs) are extremely valuable to them. They allow malware or malicious scripts to re-download themselves, maintain persistence, or execute code even after you clean up all the visible files. This is a critical point of failure if we ignore it.

  • Action: You need to check your server’s crontab settings - this is usually done via cPanel or directly through your hosting dashboard. Look meticulously for any scheduled PHP scripts that are set to execute frequently, especially those whose purpose you do not recognize. If something looks suspicious, disable it immediately until we can fully stabilize the site and audit what that script was doing.

2. The CDN/WAF Misdirection

If your site is using a Content Delivery Network (CDN) or a Web Application Firewall (WAF), sometimes these systems aren’t protecting you from all angles. In fact, sophisticated hackers may exploit the very rules of those protective systems - they don’t attack the code directly; they trick the firewall into thinking their traffic is legitimate.

  • Action: If you suspect that malicious traffic is slipping through your defenses, we need to act defensively. Temporarily increase your WAF’s strictness settings (this might cause minor functional issues, so proceed with caution). Crucially, then review its blocked logs very closely to see if there are patterns of attack that correlate directly with the strange site behavior you’ve been seeing.

3. The Payment Intent Audit (The True Goal)

Always remember the primary objective: data theft. When we are auditing any JavaScript file - especially those injected into a critical workflow like the checkout page - don’t just look for random, suspicious code blocks floating around. You must look specifically for API endpoints. Is a script correctly calling stripe.js to process payment details? That is expected. But is it also making an AJAX call to a secondary, unusual endpoint, perhaps something like http://my-hacker-server.com/stealdata.php, immediately right after the customer enters their payment data? That secondary, suspicious endpoint call - that’s your smoking gun. It tells us exactly where they are sending the stolen information.

Phase IV: Hardening and Prevention (Closing the Loop)

. We’ve cleaned up the mess, but if we just leave things as they are, another attacker could walk back in immediately. This final phase - hardening your site - is like putting all the locks on window, door, and safe deposit box. It stops reinfection before it can even start.

Once the site is absolutely clean - and only then should you proceed - you must harden it thoroughly to prevent immediate reinfection. Do not skip any of these steps.

  1. Update Everything (The Core Defense): This is . You must update WordPress core, WooCommerce, Magento, and plugin and theme that is currently running. Please do not skip even one item on the list. Updates patch known security holes that attackers love to exploit.
  2. Change File Permissions (The 755 Rule): This step teaches your server how to enforce boundaries. We need to set specific, restrictive permissions so that a basic attacker can’t just upload an executable file into a directory where they shouldn’t have write access.
  • Directories should almost always be set to 755.
  • PHP files and assets should usually be set to 644.
  1. Principle of Least Privilege (User Control): Think about who actually needs to do what on your site. Only give the absolute minimum level of access required for a job. For example, if your blog author doesn’t need administrator rights to write an article, you must downgrade their user role. Never use “Admin” for routine tasks; it gives far too much power and is unnecessary risk.

Common Mistakes That Make Malware Worse

When you’ve just dealt with a major infection, it feels like the end of your website. I know this is stressful. But based on years of recovering broken sites - the kind that look impossible to save - I can tell you exactly where owners often trip up and make the damage worse. These are mistakes that even experienced users sometimes repeat:

  • Mistake 1: The Quick Restore: This is perhaps the most common mistake I see. Owners panic and restore a full backup from, say, two months ago. They think they are wiping the slate clean, but you are simply rolling back everything, including every malicious file and backdoor that was installed during those past two months. Think of it this way: restoring the site is like taking a photo of your infected system; it doesn’t sanitize it. You must always manually scrub out the threat vectors and clean the infection before you ever think about bringing up an old backup copy.
  • Mistake 2: Ignoring Child Themes: Many people assume that if they update their main theme (the parent), everything will automatically be secure. This is a dangerous assumption. Hackers know this workflow, and they specifically target child themes. Why? Because the code in a child theme is often loaded every time the page loads, but it gets significantly less scrutiny during routine security audits than the core files. It’s an easy place for them to inject persistent backdoors that survive parent updates.
  • Mistake 3: Trusting One Scan: You might run five different paid scanners or install a dozen anti-malware plugins, and you’ll feel safe. But malware is not just one thing; it operates in layers - it lives in the database, it modifies files on the server, and sometimes it communicates over your network traffic. If you only rely on a single tool (even an excellent paid one), you are looking at only one slice of the problem. A truly holistic recovery requires combining deep dives into three separate areas: analyzing server access logs for unusual IP activity, conducting thorough database audits for strange tables or user entries, and performing line-by-line code inspection across your file system.

When to Call an Expert Recovery Specialist

I gave you these steps because I want you to feel empowered and capable of fixing this yourself. Truly, we want you to be resourceful! However, let’s be completely honest with each other: sometimes compromises are incredibly deep, complex, or they require specialized institutional knowledge that is nearly impossible to replicate just by reading an article.

You should immediately call a professional if:

  1. The Site is Critical/High Revenue: If your business absolutely cannot afford even 24 hours of downtime - if every minute costs you real money - then speed and guaranteed, expert expertise will always outweigh the risk of doing it yourself (DIY).
  2. Database Corruption is Suspected: This is a major red flag. If you find any evidence that the database structure itself has been fundamentally tampered with, rather than just some random data points being changed, stop immediately.
  3. The Compromise was Advanced/State-Level: When an attack involved highly sophisticated techniques - things like rootkit installation, compromised cloud credentials, or deep server backdoors - you are dealing with a problem that requires dedicated forensic tools and specialized knowledge far beyond what you can find in a typical hosting control panel.

Listen, we aren’t going to pressure you into buying our service just to make money. We pitch this expertise because your revenue depends entirely on having clean code and a stable foundation. Sometimes, though, you simply need an entire specialist team - a crew with decades of “battle scars” in cyber forensics - to guide you through the deepest muck without making things worse. Your business continuity is worth that expert peace of mind.

Need this fixed right now?

Our web developers can resolve this for you — starting from $149.

Fix My Site Now