File System Monitor

Today at work I overheard some of the IT folks talking about file monitors for various systems and remembered that I had written one of these a few years ago …so here it is!

This app will run through a list of directories and email you a report of which files have been added or updated. I use it on my web server so that I can keep an eye on malicious files that someone may have uploaded (although that has never happened).
In the config file there are a number of settings you need to update with your SMTP credentials. There is also a template.csrzr file which is the template for the email that is sent. It is C# with Razor syntax that generates HTML for the email content. If you feel comfortable with editing that go at it.
There is also a -test.cmd file that will run the application with the -test parameter. The only thing this does different is that it doesn’t update the LastRunTime setting in the config file once it’s finished.
I have this setup on my server to run once a day using Windows Task Scheduler but you can run it as often or as little as you like using the same method.
Here is a list of all the settings in the config file. The download is below.
Setting NameDescription
PathsA | (pipe) seperated list of paths to be monitored.
LastRunTimeThe value is used to determine when the last time the program was run and as the time to compare new/updated files to. After sending a report the program will update this value. You do not need to change this value.
InstanceNameThe instance name to be used in the reporting template. If the instance name is blank then the name given to the machine will be used.
FromAddressEmail address the report will come from.
SubjectSubject of the email. Replaces {0} with the InstanceName. For example if the InstanceName is “WEB01” and the Subject is “File Report for {0}” then the subject of the email will be “File Report for WEB01”.
ToAddressesA , (comma) seperated list of email addresses the report will be sent to.
SmtpHostThe SMTP host address.
SmtpSsl“true” or “false” value that will determine if the email is sent using SSL.
SmtpPortThe SMTP port number.
SmtpTimeoutThe number of milliseconds to wait for the email to be sent before timing out.
SmtpUserThe SMTP user name.
SmtpPassThe SMTP password.
[sdm_download id=”4551″ fancy=”0″] * 92KB

Rush Frisby

Rush is a software architect who loves solving problems. You'll usually find him writing about security concepts and sharing solutions to problems he's faced.