Skip to main content

Useful Snippets - Security

Integrity Files Checker (bash)

# Generate MD5 hash list for all files in a directory and save it to a file.
sudo find . -type f | while read file; do sudo md5sum "${file}" >> ~/md5check.log; done
# Check current list of MD5 with a file already generated.
sudo md5sum -c ~/md5check.log | grep FAILED

Generate Random Passwords with Python

def generate_password(length = 32):
chars = string.ascii_letters + string.digits
generated_password = ''
for i in range(length):
index = random.randrange(len(chars))
generated_password += chars[index]
return generated_password