我正在练习生成所有可能的6位员工ID(开头都是900,后面是所有可能的6位数字),以便暴力破解一个名为PS7_encrypted.pdf的PDF文件的密码。到目前为止,我已经成功地生成了所有6位引脚(前面有900个),并将它们存储到一个dictionary.txt文件中。我正在开发一个程序,它可以读取文件,并使用包含所有可能数字的文本文件暴力破解PDF。然而,当我运行该程序时,我没有得到任何结果,也没有打印密码。我做错什么了?生成ID的代码:
#!/bin/python3
def genEmployeeID():
with open('dictionary.txt', 'w') as wfile:
for i in range(1000000):
wfile.write(f'900{i:06}' + "\n")
genEmployeeID()
暴力破解PDF文件的代码:
#!/bin/python3
import PyPDF2
import sys
filename = 'PS7_encrypted.pdf'
dictionary = 'dictionary.txt'
password = None
file_to_open = PyPDF2.PdfFileReader(filename)
with open(dictionary, 'r') as f:
for line in f.readlines():
password = line.strip('\n')
try:
pss = bytes(password, 'utf-8')
file_to_open.extractText(pwd = pss)
password = 'Password found: %s' % pss
print(password)
except:
pass
发布于 2020-04-03 01:44:52
extractText
是这个对象的函数吗?我在documentation里找不到它。由于您没有指定要捕获的特定异常,因此我假定它在找不到该函数时直接传递到except
块中。你要找的似乎是decrypt(password)
。
https://stackoverflow.com/questions/60997193
复制相似问题