0

I wrote this brute force attacker in Python. It cracks any file numeric password protected file.

import pikepdf

def brute_num_attack(file):
    i = 0
    while True:
        try:
            print(i)
            with pikepdf.open(file, password=str(i)) as file:
                print("Password: ", i)
                print("Total pages:", len(file.pages))
                break
        except:
            i += 1

If I need this to do a brute force attack of all alphanumeric characters and punctuation, how should I do it?

Using this:

characters = string.ascii_letters + string.digits + string.punctuation

This is just for proof of concept how brute force is implemented.

Usman
  • 14
  • 3
  • 2
    Are you aware that that string contains 94 characters and you will have to try 689,869,781,056 passwords for a password length of 6 (94^6)? – Selcuk Jul 15 '21 at 03:19
  • Yup. This is just for practice and proof of concept. I tried using for loops but did not get desired functionality. – Usman Jul 15 '21 at 03:42

0 Answers0