Brute force is defined as an attack to crack passwords where we submit many passwords guessing that any of the passwords we are submitting may work.
In this tutorial, we will see a basic program that is basically a hint to brute force attack to crack passwords. In other words, we will make a program to Crack Any Password Using Python. So, we are applying a brute force attack here with the help of a while loop in python.
So, the process is something like that we will ask the user to enter some characters i.e. password, and then we will try to guess the password using a brute force attack.
Now let’s see and understand the code:
# importing random
from random import *
# taking input from user
user_pass = input("Enter your password")
# storing alphabet letter to use thm to crack password
password = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't','u','v',
'w', 'x', 'y', 'z',]
# initializing an empty string
guess = ""
# using while loop to generate many passwords untill one of
# them does not matches user_pass
while (guess != user_pass):
guess = ""
# generating random passwords using for loop
for letter in range(len(user_pass)):
guess_letter = password[randint(0, 25)]
guess = str(guess_letter) + str(guess)
# printing guessed passwords
print(guess)
# printing the matched password
print("Your password is
Output:
Enter your password
On running of the program, while loop will print a random password every time on execution until the password entered by the user matches the guess of our program. So is a basic program which is basically a hint to brute force attack to crack passwords if you have any query on our program to Crack Any Password Using Python, then comment.
#python