zoukankan      html  css  js  c++  java
  • 【pyhon】黑客用字典暴力破解Zip文件密码原理性展示

    基本原理:用程序把字典文件里拟定好的密码一个个提取出来,去测试zip能否打开

    字典文件pass.txt内容:

    1224
    2121
    asdf
    abcd1234
    dwsdsd
    dssds

    程序代码:

    # zip文件
    import zipfile
    import os
    
    
    # 对zip文件进行密码测试,成功返回True,失败返回False
    def testZip(filePathname,password):
        # 判断目录是否存在
        if os.path.exists(filePathname)==False:
            print("文件"+filePathname+"不存在")
            return False
    
        zfile=zipfile.ZipFile(filePathname)
    
        try:
            zfile.extractall(pwd=password.encode('utf-8'))
            return True
        except Exception as e:
            #print(e)
            return False
    
    # 入口函数
    def main():
        passFile=open('pass.txt')
    
        for line in passFile.readlines():
            password=line.strip()
    
            if testZip('test.zip',password)==True:
                print('The password is '+password)
    
    # Kickoff Start
    main()

    输出:

    C:Usershorn1Desktoppython10>python zip.py
    The password is abcd1234

    原理和程序都简单,就是字典文件不好弄,程序耗时长,如果密码复杂还不好猜。所以只能玩玩。

  • 相关阅读:
    [包计划] date-fns
    [包计划] create-react-app
    [包计划] js-cookie
    [包计划] cheerio
    [包计划] 30-seconds-of-code
    new
    [源计划] array-first
    [源计划] is-sorted
    [源计划] array-flatten
    images
  • 原文地址:https://www.cnblogs.com/heyang78/p/8675557.html
Copyright © 2011-2022 走看看