Accepting projects ·CZ Get in touch →

Unknown files on the server: how to tell an attacker is abusing your website

During an audit of an older e-shop we found unknown files on the server, including a spam mailer. How to recognise them and what to do first.

The website works and orders keep coming in. Yet code is running on the server that none of you put there. Typically a tool for sending spam. We describe what we found during an audit of an older e-shop and how to check your own website.

What we found

At the end of March we audited an e-shop that has run for many years on its own PHP code without updates. Among other things, the server held four files that didn't belong to the e-shop's code:

  • two copies of an off-the-shelf mass-mailing tool that attackers use to spread spam and that also serves them as a backdoor
  • two small scripts that download more malicious code from the internet on command

Their names were inconspicuous, two of them just a random combination of letters. The owner didn't know about them and the e-shop kept running with no visible change. An attacker can fake file modification dates, so they can't reliably tell when the compromise began.

We found the unknown files on the old server and also on the new one the e-shop was just moving to. So the move alone would not have solved the problem.

Lukáš Hrubý Managing director, HRUBY Software

How they got there

Old code usually has more than one way in, and the audit found a whole range of them. A publicly accessible database management tool. A file upload form that didn't check all dangerous file extensions. An old text editor with known vulnerabilities. On top of that, customer passwords stored in readable form, so an attacker with access to the database would get all of them. Code that hasn't had a security update in over ten years can't be secured with a single fix.

What matters for the owner is this: the attacker doesn't need to take the e-shop down. It pays them better to use the server quietly. They send spam from it, and when the domain and IP address end up on a blacklist, customers stop receiving even order confirmations.

Symptoms you may notice

  • bounce messages arrive in your inbox for emails you didn't send
  • customers report they didn't receive an order confirmation
  • your hosting provider sends warnings about the volume of outgoing mail or server load
  • the website folders contain files with random names, or with modification dates when nobody was working on the website

What to do if you suspect something

  1. Don't delete everything right away. First download a copy of the whole website and database. Without it you won't be able to find out later how the attacker got in and what else they changed.
  2. Find recently changed files. On a server with SSH access, find . -name "*.php" -mtime -90 is enough. On an old website where the code hasn't changed for years, every new file stands out.
  3. Change all passwords: FTP, database, admin, hosting control panel. Do it only after removing the unknown files, otherwise the attacker may read the new passwords.
  4. Remove tools that don't belong in production, such as a database manager or test scripts.
  5. Before you move the website, check what you are moving. Otherwise you'll take the compromise with you to the new server.

Removing the files doesn't end the job. If the way the attacker came in stays open, they will come back. For a website that hasn't had updates for a long time, the long-term solution is therefore to replace or rewrite the platform, not another patch.

When to bring in an expert

If you find a single suspicious file, treat the website as compromised. A security audit shows what else is on the server, how the attacker got in and what to fix first. The output is a list of findings sorted by severity and concrete steps for the first week. From it, the owner can see what takes one afternoon to solve and what needs a bigger decision.

Written by Ing. Lukáš Hrubý, HRUBY Software · ← All articles

Dealing with the same thing?

We'll look at it with you. The first consultation is free. More about the service: Security Audits.

Book a consultation →
// Contact

Get in touch.

Tell us what you need, or just call. We reply within one business day.

// Encrypted in transit · privacy policy