PDA

View Full Version : Monitor a file for changes



nerdykit
04-16-2009, 11:20 AM
My site has twice been hacked by the same attacker. He changes my index.html file among other things and uses a sendmail bomber to force sending out spam, I suspect.

I have a good idea of what goes on when he's in there but my site is not a high traffic site and I'd like to be notified whenever a change to a particular file occurs (because it would very likely be him doing it).

I imagine that this is a job for cron running a cgi or pearl script. Programming in either of these environments is not in the cards for me, can anyone direct me to a possible script that will monitor a file and if it's mod date changes, the script will email me a notification.

Thanks

anonymous
04-16-2009, 09:53 PM
I'm at home and i don't have a unix terminal, but you need something like
this: copy the index.html to file1. diff index.html file1
test the result of the diff. if there is a difference, email yourself.
something like this script: (please test)

if (diff index.html file1) mail -s "index.html was changed" me@myhm.com < email.stuff

just fiddle with the code above using a unix terminal until you get it working. once you got it put it in a file and crontab the thing to run every 1 minute or so. once you get the email, turn off the crontab or you'll get an email every minute.

I hope this helps.