forked from nitin42/Python-Automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject15.py
More file actions
31 lines (21 loc) · 770 Bytes
/
project15.py
File metadata and controls
31 lines (21 loc) · 770 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
28
29
# Brute-Force PDF Password Breaker
# Brute-Forcing the pdf files to break the encryption using dictionary attack
import os
import PyPDF2
# Opening the dictionary file that contains all the possible combinations of words
read_file = open('dictionary.txt')
file_content = read_file.read()
# Making a list of word strings by reading this file
wordlist = file_content.split('\n')
# Using PyPDF2 module to read pdf files
pdfreader = PyPDF2.PdfFileReader(open('pdf_file','rb'))
# Checking whether the file is encrypted or not
try:
if pdfreader.isEncrypted == True:
for word in wordlist:
pdfreader.decrypt(word)
if (decrypt()): return 1
elif not (decrypt()): return 0
else:
# If the file is not encrypted then simply open the file
pdfreader.numPages