风火轮少儿编程zip密码暴力破解教学程序

"""风火轮少儿编程zip密码暴力破解教学程序,请预先准备扩展名为zip并加了密码的压缩档案。"""

import zipfile  
import time 
 
def extract(password, file):
    """试图用password解压缩file"""
    try:
        password = str(password)
        file.extractall(path='.', pwd=password.encode('utf-8'))
        print("成功破解,它的密码是{}".format(password))
        return True
    except:
        pass
 
def load_pass_dict(filename):
    """加载密码字典,把所有字符串放在pass_list里"""
    pass_list = []
    f = open(filename)
    for line in f:
        if line.strip()!="":
          pass_list.append(line.strip())
    f.close()
    return pass_list
    
        
 
if __name__ == '__main__':

   print("欢迎来到风火轮少儿编程zip密码暴力破解教学程序.")
   
   filename = "test.zip"                # 待破解密码的zip文件

   if filename.endswith('.zip'):        # 如果是zip文件,则加载密码字典

      fp = zipfile.ZipFile(filename)

      pass_list = load_pass_dict("dict.txt")

      for password in pass_list:
                    
          if extract(password,fp) :break

      input()