3

I had an occasion recently where our website was compromised - a link farm was added to a couple of the pages on one occasion, and on another occasion, a large and nasty aspx file was put on the server. I won't mention the host's name (Hostway), but I was pretty annoyed that someone was able to do this. No, it wasn't a leaky password - around 10 sites hosted by HW with consecutive IP addresses got trashed.

Anyway. What I need is a utility or service (preferably free) that takes a snapshot of my websites contents, and then regularly monitors the files (size and datestamp) for unauthorized changes or additions, and alerts me. I've used web services that monitor one file for changes, but I'm looking for something a bit more aggressive.

2
  • interesting question - do you have any clue HOW your server was compromised?? Sep 25, 2012 at 11:06
  • Same thing happened to me on GoDaddy several times. I don't use hosting services anymore. Too many clients on one machine means there's many users who are already through the first level of security (ie. logged in to your server). All strangers and you don't know who they share passwords with.
    – Octopus
    Sep 24, 2013 at 5:23

4 Answers 4

5

We've been using this, Monitor Hacked Files, which is a PHP script that you install on the server. It notifies you if there are any changes to your site -- sending an email with a list of changed files. This at least tells you where to look. Definitely better than Google or clients finding out before you do!

1
  • It would do the trick...but. I'm hosted on a Windows server, not Unix. I guess one could write something in ASP though.
    – rossmcm
    Feb 23, 2011 at 9:35
2

You could set up a Google Alert to search your site for probable junk. For example, you might have the alert search for "viagra site:example.com". Google alerts will email you if it ever finds the target of your search.

1
  • Thanks, I had already done this when we were link-farmed, but it didn't pick up the occasion when we got infected with the aspx.
    – rossmcm
    Feb 23, 2011 at 9:29
2

One of our sites was recently hacked and we didn't notice for a while, because nothing was broken, until we became aware of our site appearing with spammy words in Google searches. Since our site was using git, I came up with a quick and dirty solution for monitoring the site for unauthorised file changes using the git diff command.

It is a bash script (but is simple enough to be modified into a batch script for Windows environments) that runs periodically via something like cron.

#!/bin/bash

# change the following two params,
# set up a cron job and there you go!
email="[email protected]"
site="your site"

cd "$(dirname "$0")"

if [ ! -f snitch.log ]; then
    touch snitch.log
fi

# if git diff finds a difference between
# HEAD and what we have now, snitch!
if [[ -n $(git diff --name-only HEAD) ]]; then
    git diff --name-only HEAD > snitchtemp.log
    if [[ -n $(diff snitch.log snitchtemp.log) ]]; then
        git diff --name-only HEAD > snitch.log
        cat snitch.log | mail -s "snitch@$site" "$email"
    fi
else
    echo "OK"
fi

What it does is very simple. On every invocation it uses git diff to see if any files have been modified since the last commit, and if so sends an email with the list of files that have been tampered. To avoid sending the same email over and over again until you pay attention, it saves the list of files that were tampered with the last time it ran and checks against that to see if the list of files have changed, in which case it can send another email.

Note that git diff will only list modified files that git is tracking, so if the intruder creates brand new files, they won't be caught. However since they would need to tamper with at least one existing file to create the brand new file in the first place, this script should be fine.

1

Two tools that run on windows might work for you md5deep and AFICK - another file integrity checker. The allow the auditing and also become aware of new files.

AFAICK there is now web interface for them but you might want to send you the report via E-Mail right from the moment the tools flag a warning anyway.

Not the answer you're looking for? Browse other questions tagged or ask your own question.