MSCY – IA5001 Project 1 – File Integrity Checker July 10, 2019
Linux Bash Scripting – File Integrity Checker
Build your own File Integrity Checker. Your task is to create a bash script that can compute and verify the integrity of files present on a Linux system.
The following specifications need to be fulfilled by the script:
• For simplicity, just limit the script to scan for /bin and /sbin directories only.
• Make sure you force the user to run the script with sudo permissions (otherwise throw an error).
• Use SHA-256 as the hashing algorithm.
• The script MUST run as follows:
– sudo ./integrity_checker.sh -i
Initialize the ${database_file} and store the hashes of all the files present in /bin and /sbin.
– sudo ./integrity_checker.sh -c
This should re-calculate the hashes and store them into a new ${check_file}. These should be then compared with the ones present in ${database_file}. The output should show a summary of the files modified, files added and files removed.
Note: The sample output is just to give you an idea. Your script’s output format may differ as long as it categorizes the files into the mentioned categories.
• Usage instructions, like shown below, should be displayed when the script is invoked with incorrect parameters or permissions:
• Make sure to handle the errors gracefully and try to reuse as much code as possible. Also, don’t forget to add comments to explain why your code is doing what it does.
Deliverables and grading
Submit the integrity_checker.sh with proper comments and error handling.
Note: Your script will be tested in a Linux environment. Do not submit your database or check files.
~$ sudo ./integrity_checker.sh -i
Hash database created successfully.
~$ sudo ./integrity_checker.sh -c
Integrity check completed successfully.
Following files have been modified: /bin/test_file
Following files have been added: /bin/new_file, /sbin/new_file2
Following files have been removed: /sbin/old_file
~$ ./integrity_checker.sh
ERROR: Please run the script with sudo permissions.
~$ sudo ./integrity_checker.sh
Usage: INITIALIZE –> sudo ./integrity_checker.sh -i
CHECK –> sudo ./integrity_cheker.sh -c
Requirement
use SHA-256 hashing algorithm
correct syntax for initialization and verification error check for superuser privileges
usage instructions
meaningful comments and readable code valid output
TOTAL
Weight (points)
5
15
10
20
25
35
110
Cyberspace Technology and Applications
1
Khoury College of Computer Sciences