最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python如何破解壓縮包密碼

 更新時間:2022年05月21日 09:29:05   作者:平底鍋鍋鍋  
破解rar和zip壓縮包。Windows下使用PyCharm軟件,本文給大家詳細(xì)介紹Python如何破解壓縮包密碼,感興趣的朋友一起看看吧

簡介:

破解rar和zip壓縮包。Windows下使用PyCharm軟件。

1.步驟

1.環(huán)境

  • 指令pip install 安裝。
  • 如果是rar文件需要把rar安裝包下的Rar.exe和UnRar.exe,放在對應(yīng)項目\venv\Scripts的路徑下。
  • import失敗時,需要在File->Settings->Project Interpreter添加對應(yīng)的模塊。

2.判斷文件格式

 type = os.path.splitext(path)[-1][1:]
if type == "zip":
elif type == "rar":

3.判斷是否有密碼

 type = os.path.splitext(path)[-1][1:]
        if type == "zip":
                fileGet = zipfile.ZipFile(path)
                with fileGet as z:
                    for l in z.infolist():
                        is_encrypted = l.flag_bits & 0x1
                        if is_encrypted:
                            print("have password ")
                            break
                        else:
                            pass
 
        elif type == "rar":
            fileGet = rarfile.RarFile(path)
            with fileGet as z:
                if z.needs_password():
                    print("have password ")
                else:
                    print("no password")
                    return

4.密碼字典 自己寫或者下載相應(yīng)的軟件生成。

5.解壓文件

1.zip和rar

fileGet = zipfile.ZipFile(path)
fileGet = rarfile.RarFile(path)

2.解壓

 fileExtr.extractall(pwd=password)

2.代碼

import sys
import zipfile
import rarfile
import threading
import datetime
import os
import subprocess
import  getopt
i = 0
fileGet = ""
class MyThread(threading.Thread):
    def __init__(self, func, args, name=''):
        threading.Thread.__init__(self)
        self.name = name
        self.func = func
        self.args = args
        self.result = self.func(*self.args)
    def get_result(self):
        try:
            return self.result
        except Exception:
            return None
def extractFile(fileExtr, password, fileType):
    try:
        encodestr = str.encode(password)
        if (fileType == "zip"):
           fileExtr.extractall(pwd=str.encode(password))
        else:
            fileExtr.extractall(pwd=password)
        global i
        i = i + 1
        print("search count : %d,real password is : %s" % (i, password))
        return password
    except:
        i = i + 1
        print("search count : %d,test password : %s, err:%s" % (i, password, sys.exc_info()[0]))
        pass
def mainStep():
    path = input("please input path:")
    try:
        if os.path.exists(path) == False:
            print("%s : path error!"%(path))
            return
        type = os.path.splitext(path)[-1][1:]
        if type == "zip":
                fileGet = zipfile.ZipFile(path)
                with fileGet as z:
                    for l in z.infolist():
                        is_encrypted = l.flag_bits & 0x1
                        if is_encrypted:
                            print("have password ")
                            break
                        else:
                            pass
                fileGet = zipfile.ZipFile(path)
        elif type == "rar":
            fileGet = rarfile.RarFile(path)
            with fileGet as z:
                if z.needs_password():
                    print("have password ")
                else:
                    print("no password")
                    return
        else:
            print("file not right")
            return
        pwdLists = open("D:\Python工程\mutou.txt")
        startTime = datetime.datetime.now()
        for line in pwdLists.readlines():
            Pwd = line.strip('\n')
            t = MyThread(extractFile, (fileGet, Pwd, type))
            t.start()
            if (t.get_result() is Pwd):
                break
        endTime = datetime.datetime.now()
        timeSpan = endTime - startTime
        print("search time:%ss" % (timeSpan.total_seconds()))
    except:
       print("err:%s" % sys.exc_info()[0])
if __name__ == '__main__':
    mainStep()

1.在線調(diào)試

2.腳本運行

  • cmd 窗口打開方式:右鍵開始菜單,選擇‘命令提示符(管理員)’即可?;蛘邚拈_始菜單->運行->輸入cmd,回車。
  • 關(guān)于 cd 命令:用于改變當(dāng)前目錄路徑。使用方式:cd[空格][路徑]。例如 cd d:/Python27/Mytest 轉(zhuǎn)到該路徑下。
  • 注意:如果當(dāng)前盤符不是 D 盤,需要先轉(zhuǎn)到 D 盤,輸入 d: 回車即可。然后才可以使用 cd d:/Python27/Mytest 。
  • 輸入python test.py。test.py是對應(yīng)的文件名。

到此這篇關(guān)于Python如何破解壓縮包密碼的文章就介紹到這了,更多相關(guān)Python破解壓縮包密碼內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 基于Python2、Python3中reload()的不同用法介紹

    基于Python2、Python3中reload()的不同用法介紹

    今天小編就為大家分享一篇基于Python2、Python3中reload()的不同用法介紹,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-08-08
  • Python中str.format()詳解

    Python中str.format()詳解

    本文主要給大家詳細(xì)介紹的是python編程中str.format()的基本語法和高級用法,非常的詳細(xì),并附有示例,希望大家能夠喜歡
    2017-03-03
  • 基于Python和openCV實現(xiàn)圖像的全景拼接詳細(xì)步驟

    基于Python和openCV實現(xiàn)圖像的全景拼接詳細(xì)步驟

    這篇文章主要介紹了基于Python和openCV實現(xiàn)圖像的全景拼接,本文分步驟通過實例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2021-10-10
  • Python日志logging模塊功能與用法詳解

    Python日志logging模塊功能與用法詳解

    這篇文章主要介紹了Python日志logging模塊功能與用法,結(jié)合實例形式詳細(xì)分析了Python日志logging模塊的基本功能、原理、用法及操作注意事項,需要的朋友可以參考下
    2020-04-04
  • python3 實現(xiàn)除法結(jié)果為整數(shù)

    python3 實現(xiàn)除法結(jié)果為整數(shù)

    這篇文章主要介紹了python3 實現(xiàn)除法結(jié)果為整數(shù),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-03-03
  • Python中的?Numpy?數(shù)組形狀改變及索引切片

    Python中的?Numpy?數(shù)組形狀改變及索引切片

    這篇文章主要介紹了Python中的?Numpy?數(shù)組形狀改變及索引切片,Numpy提供了一個reshape()方法,它可以改變數(shù)組的形狀,返回一個新的數(shù)組,更多相關(guān)內(nèi)容需要的小伙伴可以參考下面文章
    2022-05-05
  • python?format格式化和數(shù)字格式化

    python?format格式化和數(shù)字格式化

    這篇文章主要介紹了python?format格式化和數(shù)字格式化,格式化字符串的函數(shù)?str.format(),它增強了字符串格式化的功能,基本語法是通過{}?和?:?來代替以前的?%?,下面內(nèi)容介紹,需要的朋友可以參考一下
    2022-02-02
  • Python中six模塊基礎(chǔ)用法

    Python中six模塊基礎(chǔ)用法

    在本篇文章里小編給大家分享的是關(guān)于Python中six模塊基礎(chǔ)用法以及相關(guān)知識點,需要的朋友們學(xué)習(xí)下。
    2019-12-12
  • python 怎樣進(jìn)行內(nèi)存管理

    python 怎樣進(jìn)行內(nèi)存管理

    這篇文章主要介紹了python 是如何進(jìn)行內(nèi)存管理的,幫助大家更好的理解和學(xué)習(xí)python,感興趣的朋友可以了解下
    2020-11-11
  • python語言變量和數(shù)據(jù)類型基礎(chǔ)學(xué)習(xí)

    python語言變量和數(shù)據(jù)類型基礎(chǔ)學(xué)習(xí)

    這篇文章主要為大家介紹了python語言變量和數(shù)據(jù)類型基礎(chǔ)學(xué)習(xí),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10

最新評論

南川市| 东乡族自治县| 缙云县| 遂平县| 鹤庆县| 南开区| 大同县| 浏阳市| 平阴县| 巴青县| 华阴市| 兴仁县| 绥江县| 抚宁县| 门头沟区| 托里县| 陵水| 肃北| 新巴尔虎右旗| 吉木乃县| 乌兰察布市| 体育| 醴陵市| 稷山县| 大渡口区| 虎林市| 斗六市| 炎陵县| 台湾省| 凉山| 闽侯县| 华池县| 池州市| 年辖:市辖区| 上思县| 屏东县| 鹿泉市| 南昌县| 咸宁市| 日土县| 临洮县|