Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Creating a tripwire script that can be executed on various directories. By comparing the directory content against a static / pre - existing record, the
Creating a tripwire script that can be executed on various directories. By comparing the directory content against a staticpreexisting record, the tripwire script will determine whether files have been added, removed or altered.
Instructions
In Linux, create a test directory and add at least two different text files with your first and last name inside the content of each file.
Create a script called "tripwire.py that will take in either two arguments in order to compare the static tripwireRecord content against the current state of a directory or take in four arguments in order to create the tripwireRecord
Create a function that will simply read file content and return a hash result. There are many hash algorithms that are available. You can use the following example:
fileHash hashlib.mddatahexdigest
Read each file content as rb to read bytes and then you can run the above statement to create a hash result that you can store and use for comparison purposes.
Note: Hash algorithms are complex and the results change drastically just by changing one byte in a file. This is why they are used in many applications.
Once you have run your script and created a tripwireRecord file containing the file name and hash pair, you should be able to add more functionality. This will enable you to handle the evaluation aspect that compares the content of the tripwireRecord file against the current directory content.
Note: You will need to check various scenarios by altering the tripwireRecord file content or by changing the directory content by modifying, removing or adding a file.
With the tripwireRecord file now available, there are many different approaches to comparing the directory against the tripwireRecord content. Here is one of these approaches, as an example:
a Read the tripwireRecord to get the directory name and the filename hash pairs.
b Read the content of the current directory and for each file to check if a record exists in the tripwireRecord. If the record does exist, compare the hash values to check if the file is identical. If the file does not exist in the tripwireRecord, this means that the file has been added to the directory after the tripwireRecord file has been created. Add the results into two different buckets such as arrays
c After evaluating all of the files in the current directory, there may be some file names that have not been compared in the tripwireRecord. In this case, you can assume that those files in the current directory have been removed.
d Keep track of the file names in some data structure eg three different arrays like modified, added, removed
e Write the results to the console.
Incorporate error handling such as arguments passed in file handling, etc.
Deliverables
Submit a minute demo of you running your script in your environment. Your demo must meet the following requirements:
a Shows you verbally describing your code and what is happening at execution.
b Proves that all of the functionalities of your script work.
c Do not submit a link to YouTube or other public video sharing service. You must submit your work in DL Failure to do this will result in a grade.
Note: The demo must be no longer than minutes. Content beyond minutes will not be watched.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started