当前位置:   article > 正文

【脚本工具】Python暴力破解ZIP文件_脚本破译工具

脚本破译工具
# -*-coding:utf-8-*-
import itertools
import time
import zipfile

filepath = "文件路径"
uncompress_path = "解压路径"
# 密码位数
pwd_num_list = [3,4,5]
# 暴力破解全排列的字典
# pwd_dic = "abcdefghijklmnopqrstuvwxyz"
pwd_dic = "abcdefghijklmnopqrstuvwxyz0123456789"
# pwd_dic = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
# pwd_dic = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
# pwd_dic = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#$%^&*()_+-=<>."

def uncompress(filepath,password):
    try:
        with zipfile.ZipFile(filepath) as zFile:
            zFile.extractall(uncompress_path,pwd=password.encode("utf-8"))
        return True
        # if password=="1234":
        #     return True
    except:
        return False

count = 0
start_time = time.time()
for pwd_num in pwd_num_list:
    for c in itertools.permutations(pwd_dic, pwd_num):
        count += 1
        password = "".join(c)
        # print(password)
        if count % 10000 == 0:
            print("已尝试破解", count, "次")
        result = uncompress(filepath, password)
        if result:
            print("用时:", (time.time() - start_time), "秒")
            print("一共尝试了", count, "次")
            print("解压成功,密码是:", password)
            break
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/746318
推荐阅读
相关标签
  

闽ICP备14008679号