51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

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))

赞(1)
未经允许不得转载:工具盒子 » ZIP压缩包解压密码爆破Python脚本