用python破解ZIP密码加强版,然而效率还是比不上用专门的工具破解

用python破解密码加强版,增加并行处理的数量,以便更快地从字典中找出密码,由于显示进度会导致覆盖输出的密码,所以没有设置进度显示的功能,功能比较简单,逻辑也简单,所以只写了11行。参考论坛大佬的代码:https://www.iculture.cc/forum-post/5041

import zipfile
from concurrent.futures import ProcessPoolExecutor
def fund(pwd):  #定义破解的函数
    zfile = zipfile.ZipFile('./test.zip')  # 填入压缩文件名,这里是test.zip
    zfile.extractall('./', pwd=pwd.encode())
    print('破解成功,密码为{}'.format(pwd))
if __name__ == '__main__':  #这里打个main就好
    pool=ProcessPoolExecutor(max_workers=32)   #设置并发进程数,此处设置为32,最大值是61
    with open('password.txt', 'r', encoding='utf-8') as passwordFile:   # 打开password.txt进行读取,编码'utf-8'
        for line in passwordFile:
            pool.submit(fund, line.strip())    #按行读取密码,并丢进进程池处理
请登录后发表评论