← All guides

Remove Malware from Hacked eCommerce Website

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 fixable. If you need to remove malware from hacked e-commerce website, follow these steps methodically. 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 daily. 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 when you attempt to clean your compromised e-commerce site.


** Emergency Stop-Gap Action:** If payments are failing or redirecting, immediately access your payment gateway dashboard (Stripe/PayPal) and temporarily suspend all API keys used by the website. This action physically severs the attacker’s ability to process fraudulent transactions while you begin diagnostics. Do NOT attempt to fix code until this step is completed.


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 crucial. 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 every 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.

How do I know my website is infected with malware?

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:

What are signs of a hack on an e-commerce site?

  • 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).

What general symptoms mean my website is compromised?

  • 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.

Related guide: Remove Google Blacklisted URL Warnings Instantly: A Technical Guide to Site Recovery

How did hackers get into my hacked website?

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.

Related guide: Restore Compromised cPanel Account from Server Backup: Expert Guide

What steps should I take to remove malware from my site?

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 and help you recover your hacked online store.

What is the first thing I need to do after a hack?

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 mandatory. 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.).
  2. 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.
  3. 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.

How do I audit my files and database for malicious changes?

To ensure thoroughness when you remove malware from hacked e-commerce website, follow these audit pillars methodically.

Audit PillarTechnical ActionsBusiness Value
Database IntegrityCheck wp_options for unrecognized keys (e.g., temp_redirect_script). Use phpMyAdmin to review system tables (core_config_data) for unauthorized changes in payment or shipping settings.Prevents persistent backdoors and ensures core site functionality remains intact after cleaning.
File System ScanConnect via SFTP/SSH. Run wildcard searches for non-standard extensions. Check hidden files using ls -al . to inspect .htaccess and .env.Locates injected payloads, malicious redirects, and exposed API keys that simple scanners miss.
Code Review (The Payload)Manually audit theme files (functions.php) for unrelated <script> tags.Identifies the actual malicious code execution points and prevents immediate reinfection.

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. 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 (e.g., RewriteRule ^(.*)$ http://badsite.com/$1 [L]).
    • Look at .env files: These environment configuration files 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 both the active and inactive themes (especially child themes). Hackers frequently inject their code right here because it’s an easy target and often gets overlooked during a standard cleanup.

What should I look for when hunting for hidden malware code?

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).

Related guide: Restore Crashed Website from Zip Backup File: Step-by-Step Guide

Are there advanced threats basic scanners miss?

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): You must update WordPress core, WooCommerce, Magento, and every 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.
  3. 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.


Frequently Asked Questions

After I've cleaned the malware and updated all plugins, should I change my database credentials again?

Yes, absolutely. Even if the attacker didn't directly steal your MySQL root password, they may have used compromised administrative access to alter user privileges or inject malicious stored procedures into the database itself. Changing the database credentials after a deep clean ensures that any lingering backdoor scripts relying on old authentication methods fail immediately.

If I find random PHP files in my theme folder, should I delete them without asking?

Only if you are 100% certain they do not belong to a legitimate plugin or core system function. If the file name is completely nonsensical (e.g., `a34b5c.php`) and it has no associated functionality in your theme's structure, deletion is usually safe. However, if you are unsure of its origin, rename it first (e.g., to `DELETED_a34b5c.php`) and then move the file outside of the web root directory before deleting it entirely. This preserves forensic evidence while removing the threat vector.

Need this fixed right now?

We clean infections, remove backdoors, and get blacklist warnings lifted. See our Malware Removal & Hack Recovery service — repairs start from $149.

Fix My Site Now