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:UsersadminDesktop123.zip" # 替换为实际的ZIP文件路径 await generate_and_try_passwords(zip_file, password_length) if __name__ == "__main__": for x in range(5,7): asyncio.run(main(x))
ZIP压缩包解压密码爆破Python脚本
转载原创文章请注明,转载自: Pikachu Hacker » ZIP压缩包解压密码爆破Python脚本