I am trying to create a program that can open zip, rar, and 7z archives that are password encrypted.
The program generates a text file of n number of possible passwords and adds the correct password to the end of the text file. The purpose is to see how long it takes to get the right password based on n attempts.
Here is a snippet of my current code which works correctly to handle .zip and .rar archives, I just haven't found a module that will allow me to do something similar for .7z
def zip_hacker(file_path):
passwords = open('pwds.txt', 'r')
with pyzipper.AESZipFile(file_path) as file:
for line in passwords:
try:
file.pwd = line
file.extractall()
except RuntimeError:
pass
def rar_hacker(file_path):
passwords = open('pwds.txt', 'r')
rarfile.UNRAR_TOOL = 'unrar'
file = rarfile.RarFile(file_path)
for line in passwords:
try:
file.pwd = line
file.extractall(pwd=str(line))
except RuntimeError:
pass