Blog
How to Remove Malware From Your Website
A practical, step-by-step guide to finding and removing an infection and keeping it gone.
Finding malware on your website is stressful, but it is a fixable problem. The infection itself is almost never as complicated as it first looks: in most cases, a single injected file or a compromised plugin is doing the damage, and removing it is a matter of working through a short, methodical checklist. This guide walks you through the cleanup in the order that works, using free tools you can run right now.
Step 1: Take the site offline (or at least block the damage)
Before you clean anything, stop the infection from spreading and stop it from doing more harm to your visitors. If you can, put the site into maintenance mode or take it offline entirely while you work. If you are on WordPress, a maintenance plugin or a simple “site under maintenance” setting works. The point is that a hacked site can quietly deliver malware to your customers, and Google may flag it while you are still deciding what to do. Removing it from public view first protects both you and them.
Step 2: Scan with free tools
Start with a remote scanner that does not require you to log in to anything. Sucuri SiteCheck is free and will examine the public pages of your site for known malware, blacklist status, and suspicious scripts. It gives you a fast read on whether the infection is visible from the outside. Then install a deeper scanner on the server side. If you run WordPress, the free version of Wordfence is a solid choice — it compares your core files, themes, and plugins against known-good copies and flags anything that has been changed or added.
Write down everything these tools report: the file names, the paths, and the specific warnings. You will need that list for the next steps.
Step 3: Identify the infected files
Malware tends to hide in predictable places. The most common spots to check are:
- Theme files, especially functions.php, header.php, and footer.php.
- Upload directories, where attackers drop disguised scripts.
- Any recently modified file you did not change yourself.
- New administrator accounts in your user list.
Compare the files on your server against a clean copy of the same theme or plugin version. Anything different that you did not put there is a candidate for removal.
Step 4: Remove the injected code
Once you know which files are infected, remove the bad code. The safest approach is to replace the affected file with a clean copy from the original source — reinstalling a fresh version of a theme or plugin removes both the injected code and anything else hidden in that file. If you must edit a file by hand, look for long, obfuscated strings, base64-encoded blocks, and scripts loading from unfamiliar domains, and delete those sections carefully. When in doubt, replace the whole file rather than trying to surgically remove one line.
Step 5: Find and remove backdoors
A backdoor is a hidden file or account that lets the attacker walk back in after you clean up. If you remove the visible infection but leave the backdoor, the site will be reinfected within days. Look for:
- Unknown user accounts with administrator privileges.
- Strange files in your upload folders or root directory that do not belong to your site.
- Scheduled tasks or cron jobs you did not create.
Delete the accounts and files you cannot explain, and review your server’s scheduled tasks for anything unfamiliar. Backdoors hide, so this step deserves a slow, careful pass.
Step 6: Change every password
Assume the attacker has your credentials. Change the passwords for your hosting control panel, your FTP or SFTP accounts, your database, and every admin login on the site. Use a unique, strong password for each one, and enable two-factor authentication everywhere it is offered. If you reuse passwords across sites, change those too — attackers routinely try stolen credentials on other services.
Step 7: Update everything
Out-of-date software is the most common entry point for a website infection. Once the site is clean, update your content management system, your theme, and every plugin to the latest versions. Remove any plugins you are not actively using — an abandoned plugin is an open door. If a plugin has been pulled from the repository or has not been updated in years, replace it with a maintained alternative.
Step 8: Secure against reinfection
Cleaning the infection is only half the job. To keep it from coming back, put a few standing protections in place:
- Keep automatic updates turned on for your CMS, themes, and plugins.
- Run a regular malware scan, and set alerts so you hear about a problem the day it appears.
- Take and keep off-site backups, so a reinfection is a restore rather than a crisis.
- Limit login attempts and use two-factor authentication on every admin account.
- Keep the number of admin accounts small, and remove access the moment an employee leaves.
For broader protection, the same principles that apply to websites apply across your business — strong access controls, patching, and monitoring are the backbone of small-business cybersecurity. If you would rather not maintain all of this yourself, managed IT services can keep updates, monitoring, and backups running in the background so a future infection is caught and handled before it spreads.
When to call for help
A single injected file is usually a do-it-yourself job. A site that has been flagged by Google, is serving malware to visitors, or has been reinfected more than once is a different story. If the scan reports are long, if you find files you cannot confidently identify, or if your site is down and your customers are affected, it is faster and safer to have a professional finish the cleanup. At Lunar IT Solutions, we start every cleanup with a free review so you know exactly what you are dealing with before you spend anything. See how we can help with malware removal, recovery, and ongoing protection.
Prefer to do it yourself? Download our free DIY handbook
