資源簡介
需要自行準備密碼字典 dictionary.txt (每行一個密碼即可),弱口令可參考這里 https://www.haolizi.net/example/view_28583.html
代碼片段和文件信息
import?PyPDF2
import?sys
pdfReader?=?PyPDF2.PdfFileReader(open(‘6363.pdf‘‘rb‘))
if?pdfReader.isEncrypted:
????#開始破解密碼
????print(‘嘗試破解密碼...‘)
????#獲取密碼字典
????File?=?open(‘dictionary.txt‘)
????sfile?=?File.read()
????dic?=?sfile.split(‘\n‘)
????num?=?len(dic)
????for?i?in?range(num):
????????print(‘第?‘+str(i)?+‘?次嘗試...?????‘end=‘?‘)
????????if?pdfReader.decrypt(dic[i]):
????????????print(‘破解成功,密碼是?‘?+?dic[i]?+?‘...‘)
????????????#進入PDF
????????????print(‘PDF有?‘+?str(pdfReader.numPages)?+?‘...‘)
評論
共有 條評論