Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Session 03 - Python for Forensics

The code here is to support the Session 03 lecture.

passwordCrackZipSimple.py

import zipfile
from threading import Thread

def extract_zip(zFile, password):
    try:
        zFile.extractall(pwd=password.encode('utf-8'))
        print("[+] Password Found: " + password + "\n")
    except Exception as e:
        pass

def main():
    zFilename = 'Images.zip'
    dictionary = 'dictionary.txt'

    zFile = zipfile.ZipFile(zFilename)
    with open(dictionary, 'r') as f:
        for line in f.readlines():
            password = line.strip('\n')
            try:
                zFile.extractall(pwd=password.encode('utf-8'))
                print('Password Found: %s' % password)
            except Exception as e:
                pass

if __name__ == '__main__':
    main()
[ Last updated: Tuesday 13 February 2024 @ 11:22:49 +0000 // branch: master // commit: bd41815 ]