Skip to content

Commit 7974567

Browse files
committed
added pdf cracker tutorial
1 parent b0da74f commit 7974567

File tree

7 files changed

+5024
-0
lines changed

7 files changed

+5024
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
2626
- [How to Brute Force FTP Servers in Python](https://www.thepythoncode.com/article/brute-force-attack-ftp-servers-using-ftplib-in-python). ([code](ethical-hacking/ftp-cracker))
2727
- [How to Extract Image Metadata in Python](https://www.thepythoncode.com/article/extracting-image-metadata-in-python). ([code](ethical-hacking/image-metadata-extractor))
2828
- [How to Crack Zip File Passwords in Python](https://www.thepythoncode.com/article/crack-zip-file-password-in-python). ([code](ethical-hacking/zipfile-cracker))
29+
- [How to Crack PDF Files in Python](https://www.thepythoncode.com/article/crack-pdf-file-password-in-python). ([code](ethical-hacking/pdf-cracker))
2930

3031
- ### [Machine Learning](https://www.thepythoncode.com/topic/machine-learning)
3132
- ### [Natural Language Processing](https://www.thepythoncode.com/topic/nlp)

ethical-hacking/pdf-cracker/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# [How to Crack PDF Files in Python](https://www.thepythoncode.com/article/crack-pdf-file-password-in-python)
2+
To run this:
3+
- `pip3 install -r requirements.txt`
4+
- Use any `wordlist.txt` you want, and run `pdf_cracker.py`
83.1 KB
Binary file not shown.

ethical-hacking/pdf-cracker/foo.pdf

82.2 KB
Binary file not shown.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pikepdf
2+
from tqdm import tqdm
3+
4+
# load password list
5+
passwords = [ line.strip() for line in open("wordlist.txt") ]
6+
7+
# iterate over passwords
8+
for password in tqdm(passwords, "Decrypting PDF"):
9+
try:
10+
# open PDF file
11+
with pikepdf.open("foo-protected.pdf", password=password) as pdf:
12+
# Password decrypted successfully, break out of the loop
13+
print("[+] Password found:", password)
14+
break
15+
except pikepdf._qpdf.PasswordError as e:
16+
# wrong password, just continue in the loop
17+
continue
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pikepdf
2+
tqdm

0 commit comments

Comments
 (0)