-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpdf.py
More file actions
27 lines (20 loc) · 747 Bytes
/
pdf.py
File metadata and controls
27 lines (20 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
import pikepdf
import sys
if len(sys.argv) == 1 or '-h' in sys.argv:
print('Usage: "python3 pdf.py <file> <wordlist>"')
sys.exit()
pdffile = sys.argv[1]
passwordlist = sys.argv[2]
with open(passwordlist) as passlist:
passlist = [password for password in passlist.read().split('\n') if password]
for passwd in passlist:
try:
with pikepdf.open(pdffile, password = passwd) as pdfile:
pdfile.save('output.pdf')
print("\033[92m--------------------------------------------")
print(" Found Password: --> "+ passwd)
print("--------------------------------------------")
exit()
except pikepdf._qpdf.PasswordError:
print("\033[91mtrying: \033[0m"+ passwd)