Created
November 30, 2016 11:00
-
-
Save dnwe/301947e2c9405d84a30322cfb0ccecb6 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
import os | |
import sys | |
import fnmatch | |
import logging | |
import zipfile | |
logging.basicConfig( | |
stream=sys.stdout, | |
level=logging.INFO, | |
format='%(levelname)-8s %(message)s') | |
def main(): | |
'''main entrypoint''' | |
if len(sys.argv) != 2: | |
sys.stderr.writelines('Usage: {} <directory>\n'.format(sys.argv[0])) | |
sys.exit(1) | |
check_dir = sys.argv[1] | |
logging.info('Checking %s for encrypted zip files', check_dir) | |
for path, subdirs, files in os.walk(check_dir): | |
for name in fnmatch.filter(files, '*.zip'): | |
archive_name = os.path.join(path, name) | |
zf = zipfile.ZipFile(archive_name) | |
for zinfo in zf.infolist(): | |
is_encrypted = zinfo.flag_bits & 0x1 | |
if is_encrypted: | |
logging.warning('%s has encrypted contents!', archive_name) | |
break | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment