A cross-platform file integrity monitoring tool that detects file changes using SHA-256 hashes.
Build the project:
go build -o hash-watcher cmd/main.goThe binary should be generated from the project's root directory.
HashWatcher monitors files by calculating their SHA-256 hashes.
Whenever a monitored file changes (even by a single byte) the generated hash changes as well. By comparing the current hash with a previously trusted hash, HashWatcher detects modifications and can optionally send Slack notifications.
Note: HashWatcher detects file modifications by comparing SHA-256 hashes. While this is an effective way to identify changes in file contents, it is not a complete file integrity or security solution. For example, if both a file and its trusted reference hash are modified by an attacker, the change cannot be detected. HashWatcher should therefore be used as one layer within a broader monitoring strategy.
Create a JSON configuration file for each directory you want to monitor.
Example:
{
"directoryPath": "/full/path/to/directory/",
"fileNames": [],
"checkFrequencyInSeconds": 60
}To monitor only specific files:
{
"directoryPath": "/full/path/to/directory/",
"fileNames": [
"file-1.txt",
"file-2.txt"
],
"checkFrequencyInSeconds": 60
}To enable Slack notifications:
{
"directoryPath": "/full/path/to/directory/",
"fileNames": [
"file-1.txt",
"file-2.txt"
],
"checkFrequencyInSeconds": 60,
"notification": {
"endpoint": "CXXXXXXXXXX",
"token": "xoxb-xxxxxxxxxxxxxxxxxxxxxxxx"
}
}Run HashWatcher by passing the configuration file:
./hash-watcher /full/path/to/configuration/settings.jsonExample output:
2024/07/09 11:44:43 => Watching...
2024/07/09 11:45:43 => file-1.txt was modified!
- Before: e6de32585e70330a8de848b7b7859911e1e108e00dd6527391533853dd7c9409
- Now: ea6fcfe57703205da4d1b74ec99a8c67f721b2ab2e9c31d2222da066606d5d44
HashWatcher can send notifications to Slack using a Slack App.
For more information about Slack manifests, see:
https://api.slack.com/reference/manifests
- Go to https://api.slack.com/apps and click Create New App.
- Choose From an app manifest and select your workspace.
- Copy the manifest located at:
doc/slack/slack_app_manifest.yml
Paste it into Slack.
- Review the configuration and create the app.
- Open Settings β Basic Information and optionally set the project logo (
doc/slack/logo.png) as the app icon.
- Go to Features β OAuth & Permissions and copy the generated Bot User OAuth Token.
- Finally, add the app to the desired Slack channel and use the channel ID (
endpoint) together with the OAuth token in your HashWatcher configuration.
- Monitor subdirectories
- Custom monitoring schedules
- Unit tests
- Functional tests
If you like this project or find it useful, please give it a star! It helps increase its visibility and supports future development.
Distributed under the MIT License. See LICENSE for more information.






