This repository contains a PowerShell script for automated File Integrity Monitoring (FIM). It monitors specified files for unauthorized changes, providing alerts.
- Automated Monitoring: Continuously monitors files within a designated directory.
- Baseline Creation: Generates a baseline of file hashes for comparison.
- Change Detection: Detects file modifications, additions, and deletions.
- Real-time Alerts: Notifies the user of changes via console output.
- Windows with PowerShell 5.1 or later.
- Administrator privileges (for monitoring protected files).
-
Clone the repository:
git clone https://github.com/SilentAshes/FIM.git
-
Place Files to Monitor: Place the files you wish to monitor inside the
filesdirectory within the cloned repository. -
Run the Script: Open PowerShell and navigate to the directory where you cloned the repository. Execute the
FIM.ps1script. -
Choose an Action:
- A) Collect New Baseline: This option calculates the SHA512 hash of each file in the
filesdirectory and stores them inbaseline.txt. This is your initial reference point. - B) Begin Monitoring Files with Saved Baseline: This option continuously monitors the files against the saved
baseline.txt. It will alert you if any file is modified, added, or deleted.
.\FIM.ps1
- A) Collect New Baseline: This option calculates the SHA512 hash of each file in the
-
Monitoring: If you choose option B, the script will continuously monitor the files. Changes will be displayed in the PowerShell console.
calculate-file-hash($filepath): This function calculates the SHA512 hash of a given file.Erase-Baseline-IF-Exists(): This function checks ifbaseline.txtexists and deletes it if it does.- Baseline Creation (Option A):
- Deletes the existing
baseline.txt(if any). - Recursively gets all files from the
filesdirectory. - Calculates the SHA512 hash of each file.
- Stores the file path and hash in
baseline.txt(e.g.,filepath|hash).
- Deletes the existing
- Monitoring (Option B):
- Loads the file paths and hashes from
baseline.txtinto a dictionary ($fileHashDicti). - Continuously monitors the
filesdirectory (every 1 second). - Calculates the SHA512 hash of each file.
- Compares the current hash with the baseline hash.
- Alerts the user if a file is modified, added, or deleted.
- Alerts user if a file from the baseline has been deleted.
- Loads the file paths and hashes from
- The script uses SHA512 hashing for file integrity checks.
- Alerts are displayed in the PowerShell console.
- The script monitors all files within the
filesdirectory recursively. - The monitoring loop runs indefinitely until manually stopped (Ctrl+C).
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License.