日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Python.暴力破解rar密码

發布時間:2023/12/14 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python.暴力破解rar密码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
from unrar import rarfile import osimport itertools as its import timefrom concurrent.futures import ThreadPoolExecutordef get_pwd(file_path, output_path, pwd):'''判斷密碼是否正確:param file_path: 需要破解的文件路徑,這里僅對單個文件進行破解:param output_path: 解壓輸出文件路徑:param pwd: 傳入的密碼:return:'''# 傳入被解壓的文件路徑,生成待解壓文件對象file = rarfile.RarFile(file_path)# 輸出解壓后的文件路徑out_put_file_path = 'rar/{}'.format(file.namelist()[0])file.extractall(path=output_path, pwd=pwd)try:# 如果發現文件被解壓處理,移除該文件os.remove(out_put_file_path)# 說明當前密碼有效,并告知print('Find password is "{}"'.format(pwd))return Trueexcept Exception as e:# 密碼不正確print('"{}" is nor correct password!'.format(pwd))# print(e)return Falsedef get_password(min_digits, max_digits, words):"""密碼生成器:param min_digits: 密碼最小長度:param max_digits: 密碼最大長度:param words: 密碼可能涉及的字符:return: 密碼生成器"""while min_digits <= max_digits:pwds = its.product(words, repeat=min_digits)for pwd in pwds:yield ''.join(pwd)min_digits += 1file_path = 'rar/test.rar' output_path = 'rar'# 密碼范圍 # words = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' # 涉及到生成密碼的參數 words = '01a' pwds = get_password(4, 4, words) # 開始查找密碼 start = time.time() while True:pwd = next(pwds)if get_pwd(file_path, output_path, pwd=pwd):break end = time.time() print('程序耗時{}'.format(end - start))

總結

以上是生活随笔為你收集整理的Python.暴力破解rar密码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。