Back to the blog

Virus on your website: how to spot it and what to do first

· 5 min read

A “virus on a website” is usually malware: malicious code that someone planted through an outdated extension, a weak password or vulnerable server software. It can redirect your visitors, send spam from your server, steal card details or add hidden pages that ruin your search ranking. Most infections can be found and cleaned within a day if you act in the right order.

Signs that your site may be infected

  • Visitors, often only on phones, land on a site you do not recognise.
  • Chrome or Google show a security warning, or Search Console lists a problem in its Security issues report.
  • Your domain suddenly has strange pages in search results: pills, casinos, text in a language you do not use.
  • There are admin users you did not create.
  • The server is slow for no clear reason, or your hosting provider writes about spam sent from your account.
  • Files changed on dates when nobody worked on the site.

None of these signs proves an infection on its own, because bots and ordinary faults can look similar. Two or more together mean: check now.

What to do in the first hour

  1. Do not delete things in a panic. Make a full copy of the files and the database as they are now. You need it to find out how the attacker got in.
  2. Change every password and key from a clean computer: hosting, FTP or SSH, database, admin panel, and the keys of your payment and email services.
  3. Update everything: the CMS, all extensions and the PHP version. Remove extensions you do not use.
  4. Find and remove the malicious code. Look in recently changed files, scheduled tasks (cron), the web server configuration and the database (injected scripts in texts and settings).
  5. Restore a clean backup if you have one from before the infection, then apply the updates and the new passwords again.
  6. Ask Google to re-check the site in Search Console if it was flagged.

If a store takes card payments or collects customer data, tell your payment provider and ask a lawyer what you must report to customers and to the data protection authority.

For your developer: first checks on the server

Replace /var/www/site with your site folder. These commands only read files; they change nothing.

find /var/www/site -type f -name "*.php" -mtime -7

Lists PHP files changed in the last 7 days. Compare them with the dates of your own updates.

find /var/www/site/image -type f -name "*.php"

In an OpenCart store the image folder holds pictures, so it should contain no PHP files at all.

grep -rlE "eval\(base64_decode|gzinflate\(base64_decode|str_rot13" /var/www/site --include=*.php

Finds files that use common code-hiding tricks. A hit is a lead, not proof: a few legitimate extensions use the same functions, so open each file before deleting it.

How to keep it from coming back

  • Update the CMS, extensions and PHP regularly, and delete what you do not use.
  • Use long, unique passwords and two-factor login where it exists.
  • Forbid running PHP in upload folders (in OpenCart, the image folder), so an uploaded file cannot start.
  • Put a web application firewall in front of the site, for example Cloudflare, and watch the bot traffic.
  • Keep backups outside the server and test that they restore.
  • Watch for file changes and new admin users.

When to call a specialist

Call one if card data or customer data may be involved, if the virus comes back after cleaning, or if you cannot tell what is safe to delete. I offer a virus and malware check: a scan of the files, database and scheduled tasks and a written report in plain language with the cleanup steps. Cleanup itself is quoted after the check, because the work depends on what is found.