密码破解—-zip文件密码字典、暴力破解

下边代码包含了暴力破解,使用字典破解zip的密码

from zipfile import ZipFile
import os
from tqdm import tqdm
def passwd(path, pwd):
    # 获取文件的后缀名
    suffix_name = os.path.splitext(path)[-1][1:]
    # print(suffix_name)
    # 如果是zip文件
    if suffix_name == 'zip':
        # 开始读zip文件
        with ZipFile(path, 'r') as zip:
            # print("当前尝试的密码是:%s"%(pwd))
            # 解压到指定文件目录下
            try:
                # print(pwd.encode('utf-8'))
                zip.extractall("./target", pwd=pwd.encode('utf-8'))
                print("解压成功,密码是:%s"%(pwd))
                return True
            except Exception as e: # 添加一个异常处理
                pass

def create_pwd(words,i):
    # 通过导入这包来设置枚举序列
    import itertools as its
    # 设置基础需要枚举的字符集

    # 这个base的意思就是把words集合的字符取repeat次组合
    # 打印出来
    base = its.product(words, repeat=i)

    # 一般需要把这个打印函数注释 因为这个函数运行很消耗时间的
    for i in base:
        # print(''.join(i))
        yield ''.join(i) # 把这个函数制作成一个迭代器

if __name__ == '__main__':
    dir = "./20.zip"
    words = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+."
    #使用暴力破解,最高9位数密码
    for i in range(1, 9):
        pwd = create_pwd(words, i)
        for p in pwd:
            flag = passwd(dir, p)
            if flag == True:
                break
    #使用字典
    # with open("1.txt", "r") as f:
    #     for line in tqdm(f):
    #         line = line.strip()
    #         flag = passwd(dir, line)
    #         if flag == True:
    #             break
如果觉得本文对您有所帮助,可以支持下博主,—分也是缘。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇

超多性价比流量卡,扫码查看

这将关闭于 20