[python]破解压缩包密码

import zipfile
import rarfile

#file = zipfile.ZipFile("1.zip", 'r')
file = rarfile.RarFile('2.rar','r')
flag = True

for i in range(1000, 9999):
    if flag is True:
        try:
            i = str(i)
            print(i)
            file.extractall(path='.', pwd=i.encode('utf-8'))
            print("the password is {}".format(i))
            flag = False
        except Exception as e:
            print(e)
import pyzipper

flag = True
for i in range(100000, 999999):
    if flag is True:
        try:
            url = ''
            password=url+str(i)
            print(password)
            with pyzipper.AESZipFile('a.zip', 'r', compression=pyzipper.ZIP_DEFLATED, encryption=pyzipper.WZ_AES) as extracted_zip:
                extracted_zip.extractall(pwd=str.encode(password))
            #print("the password is {}".format(i))
            flag = False
        except Exception as e:
            #print(e)
            pass