Python Forum

Full Version: Brute Force Password Cracker
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is a brute force password cracker. Input your (fake) password, and watch the computer go! Funnily enough, abc123 takes a very long time.
import itertools
import time
import string
import sys
import getpass
# Please do not do all numbers. 
 
#
pas = getpass.getpass(prompt='What is your password?(For security,(and added effect), the password is not shown) ')
 
def guess_password(real):
   chars = string.ascii_lowercase + string.digits + string.ascii_uppercase
   attempts = 0
   for password_length in range(1, 9):
     for guess in itertools.product(chars, repeat = password_length):
           attempts += 1
           guess = ''.join(guess)
           if guess == real:
               return 'password is {}. found in {} guesses.'.format(guess, attempts)
           print(guess, attempts)
 
 
print(guess_password(pas))
This is pretty cool and could be very useful for testing to see how easy it is for your password to be cracked