Created
July 2, 2021 09:55
-
-
Save hyeonseok/f1c49af76a7c013c5fbb8d26f82e82f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.thepythoncode.com/article/crack-pdf-file-password-in-python | |
import pikepdf | |
from tqdm import tqdm | |
# load password list | |
passwords = [] | |
for y in range(70, 99): | |
for m in range(1, 12): | |
for d in range(1, 31): | |
passwords.append(str(y) + ('0' + str(m))[-2:] + ('0' + str(d))[-2:]) | |
# iterate over passwords | |
for password in tqdm(passwords, "Decrypting PDF"): | |
try: | |
# open PDF file | |
with pikepdf.open("../Downloads/1.pdf", password=password) as pdf: | |
# Password decrypted successfully, break out of the loop | |
print("[+] Password found:", password) | |
break | |
except pikepdf._qpdf.PasswordError as e: | |
# wrong password, just continue in the loop | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment