Last active
July 5, 2019 18:04
-
-
Save K0G0/45e76f0c60a8438ac8d6 to your computer and use it in GitHub Desktop.
Basic File Integrity Monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os,hashlib | |
| for file in [item for item in os.listdir('.') if os.path.isfile(item)]: | |
| hash = hashlib.md5() | |
| with open(file) as f: | |
| for chunk in iter(lambda: f.read(2048), ""): | |
| hash.update(chunk) | |
| md5 = hash.hexdigest() | |
| print file,md5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os,hashlib,time | |
| files={} | |
| while True: | |
| for file in [item for item in os.listdir('.') if os.path.isfile(item)]: | |
| hash = hashlib.md5() | |
| with open(file) as f: | |
| for chunk in iter(lambda: f.read(2048), ""): | |
| hash.update(chunk) | |
| md5 = hash.hexdigest() | |
| if file in files and md5 <> files[file]: | |
| print '%s\t%s has been changed!'%(time.strftime("%Y-%m-%d %H:%M:%S") , file) | |
| files[file]=md5 | |
| time.sleep(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os,hashlib,time | |
| files={} | |
| for file in [item for item in os.listdir('.') if os.path.isfile(item)]: | |
| hash = hashlib.md5() | |
| with open(file) as f: | |
| for chunk in iter(lambda: f.read(2048), ""): | |
| hash.update(chunk) | |
| md5 = hash.hexdigest() | |
| if file in files and md5 <> files[file]: | |
| print '%s\t%s has been changed!'%(time.strftime("%Y-%m-%d %H:%M:%S") , file) | |
| files[file]=md5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| for file in [item for item in os.listdir('.') if os.path.isfile(item)]: | |
| print file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os,hashlib,time | |
| files={} | |
| for file in [item for item in os.listdir('.') if os.path.isfile(item)]: | |
| hash = hashlib.md5() | |
| with open(file) as f: | |
| for chunk in iter(lambda: f.read(2048), ""): | |
| hash.update(chunk) | |
| md5 = hash.hexdigest() | |
| print '%s\t%s has been changed!'%(time.strftime("%Y-%m-%d %H:%M:%S") , file) | |
| files[file]=md5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os,hashlib | |
| files={} | |
| for file in [item for item in os.listdir('.') if os.path.isfile(item)]: | |
| hash = hashlib.md5() | |
| with open(file) as f: | |
| for chunk in iter(lambda: f.read(2048), ""): | |
| hash.update(chunk) | |
| md5 = hash.hexdigest() | |
| files[file]=md5 | |
| print files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment