Python网络安全里zip文件的暴力破解探索(仅供学习)

ChatGPT / Claude 官方直充代充值

Python网络安全里zip文件的暴力破解探索(仅供学习)

目录

源码在这里

https://github.com/Wist-fully/Attack/tree/cracker

需要的模块

所用到的Python模块如下:

from tqdm import tqdm
import zipfile
import pyzipper

准备一个密码本和需要破解的ZIP文件

预先准备好密码字典文件和待破解的ZIP压缩文件:

passwordfile = "PasswordFile.txt"
zip_file = "zzipp.zip"

一行一行地从密码文件中读取每个密码

逐行读取密码字典文件中的每一个密码:

n_words = len(list(open(passwordfile,"rb")))
print("总共有密码数: ",n_words)

核心部分

关键步骤是使用进度条来展示已尝试的密码数量,利用pyzipper模块尝试用读取到的密码解压ZIP文件。如果密码正确,就输出成功并显示正确密码;如果错误则继续下一个密码尝试:

with open(passwordfile,"rb") as wordlist:
    for word in tqdm(wordlist,total=n_words,unit="word"):
        pwd = str(word,'utf-8').replace('\n','')
        try:
            # 将原来的zip_file.extractall(pwd=pwd)替换为下面的代码
            with pyzipper.AESZipFile(zip_file, 'r', compression=pyzipper.ZIP_DEFLATED, encryption=pyzipper.WZ_AES) as extracted_zip:
                extracted_zip.extractall(pwd=str.encode(pwd))
        except:
            continue
        else:
            print("[+] 找到密码:",word.decode().strip())
            exit(0)
    print("[!] 未找到密码,请尝试其他密码字典")

注意,需要修改上段代码注释里的这段具有编码问题的代码:

zip_file.extractall(pwd=pwd)

文章整理自互联网,只做测试使用。发布者:Lomu,转转请注明出处:https://www.it1024doc.com/12954.html

赞 (0)
LomuLomu
上一篇 2025 年 7 月 22 日
下一篇 2025 年 7 月 23 日

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信