0

I am practicing generating all possible 6-digit employee ID's (all having 900 at the beginning followed by all possible 6-digit numbers) to brute force a password for a PDF file named PS7_encrypted.pdf. So far, I have successfully generated all 6-digit pins (with 900 at the front) and stored them into a dictionary.txt file. I am working on a program that would read the file and brute force the PDF using that text file that has all the possible numbers. When I run the program however, I got no results, no password printed. What did I do wrong? Code for generating the ID's:

#!/bin/python3
def genEmployeeID():
        with open('dictionary.txt', 'w') as wfile:
                for i in range(1000000):
                        wfile.write(f'900{i:06}' + "\n")
genEmployeeID()

Code for brute-forcing the PDF file:

#!/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
sierra117
  • 39
  • 7

1 Answers1

0

Is extractText a function of this object? I can't find it in the documentation. Since you don't specify a specific exception to catch, I assume it passes right into the except block when it doesn't find that function. What you are looking for seems to be decrypt(password).

Tyberius
  • 625
  • 2
  • 12
  • 20