ZIP压缩包解压密码爆破Python脚本

import itertools
import string
import zipfile
import asyncio
 
def save(name,data):
    with open(f'{name}.txt', 'a', encoding='utf-8') as f:
        f.write(data + '\n')
 
async def try_extract_zip_async(zip_file, password):
    try:
        with zipfile.ZipFile(zip_file, 'r') as zip_file:
            zip_file.extractall(pwd=password.encode())
            save('password',password)
            exit(f"解压成功,密码为: {password}")
    except:
        return None
 
async def generate_and_try_passwords(zip_file, length):
    characters = string.ascii_letters + string.digits
    passwords = itertools.product(characters, repeat=length)
    
    for password in passwords:
        password_str = ''.join(password)
        result = await try_extract_zip_async(zip_file, password_str)
        if result is not None:
            return result
        
        print(f"尝试密码 '{password_str}' 不正确。")
 
async def main(password_length):
    zip_file = r"C:\Users\admin\Desktop\123.zip"  # 替换为实际的ZIP文件路径
    
    await generate_and_try_passwords(zip_file, password_length)
 
if __name__ == "__main__":
	for x in range(5,7):
		asyncio.run(main(x))
© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容