import pikepdf
import os
from PyPDF2 import PdfFileReader
from tqdm import tqdm
filename = "./1.pdf" #pdf文件路径
wordlist = "./rockyou.txt" #密码字典路径
n_words = len(list(open(wordlist, 'rb')))
fp = open(filename, "rb+")
pdfFile = PdfFileReader(fp)
filepath, tempfilename = os.path.split(filename)
with open(wordlist, "rb") as wordlist:
if pdfFile.isEncrypted:
for word in tqdm(wordlist, total=n_words, unit="word"):
try:
pdf = pikepdf.open(filename, password=word.strip())
except:
continue
else:
print("[+] 找到密码:", word.decode().strip())
exit(0)
print("[!] Password not found, try other wordlist!")
这里需要用到国际密码字典 rockyou.txt,可以到网上或者下面路径下载
国际密码字典rockyou.txt-其它文档类资源-CSDN下载
https://download.csdn.net/download/lustres/46697735
版权声明:本文为lustres原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。