Question

Write a password cracker program for the passwords created according to the policy outlined in assignment...

Write a password cracker program for the passwords created according to the policy outlined in assignment 15 (exactly 8 characters: 5 letters and 3 digits). You are to write a function that takes one parameter that is a hash of a password and should return a possible password (a string) that has the same hash. Use python secure hash function sha1 from hashlib module. Hint: brute force method will be more than adequate to the task.  

Please I need it as python program

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import hashlib


# function takes one parameter that is a hash of a password
# returns a possible password (a string) that has the same hash
def get_password(password_hash):
    # use brute force method to crack the password
    # password is exactly 8 characters: 5 letters and 3 digits
    password = [0, 0, 0, 0, 0, 0, 0, 0]  # create a password array of size 8
    possible_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    # create password with all possible combinations
    # loop 8 times for 8 character in password
    # loop for all possible letters
    for ch1 in possible_letters:
        password[0] = ch1
        for ch2 in possible_letters:
            password[1] = ch2
            for ch3 in possible_letters:
                password[2] = ch3
                for ch4 in possible_letters:
                    password[3] = ch4
                    for ch5 in possible_letters:
                        password[4] = ch5
                        for ch6 in possible_letters:
                            password[5] = ch6
                            for ch7 in possible_letters:
                                password[6] = ch7
                                for ch8 in possible_letters:
                                    password[7] = ch8
                                    # convert array into string
                                    string = ""
                                    for i in range(8):
                                        string = string + password[i]
                                    # create a hash for the string
                                    string_hash = hashlib.sha1(string.encode())
                                    # now compare string hash and password hash
                                    if string_hash.digest() == password_hash.digest():
                                        # return the string as it is the password
                                        return string


# main method to run the program
def main():
    # create a password (with 5 letters and 3 digits) to hash
    password = "aR3fg57Q"
    # hash the password by using sha1 function
    password_hash = hashlib.sha1(password.encode())
    # crack the password using our function
    cracked_password = get_password(password_hash)
    # print the password
    print(cracked_password)


if __name__ == '__main__':
    main()
Add a comment
Know the answer?
Add Answer to:
Write a password cracker program for the passwords created according to the policy outlined in assignment...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 4.16 LAB: Password modifier Many user-created passwords are simple and easy to guess. Write a program...

    4.16 LAB: Password modifier Many user-created passwords are simple and easy to guess. Write a program that takes a simple password and makes it stronger by replacing characters using the key below, and by appending "q*s" to the end of the input string. • i becomes ! • a becomes @ • m becomes M • B becomes 8 • o becomes Ex: If the input is: mypassword the output is: Mypassw.rdq*s Hint: Python strings are immutable, but support string concatenation. Store and build the stronger password in the given password...

  • **IN JAVA** Many user-created passwords are simple and easy to guess. Write a program that takes...

    **IN JAVA** Many user-created passwords are simple and easy to guess. Write a program that takes a simple password and makes it stronger by replacing characters using the key below, and by appending "q*s" to the end of the input string. i becomes ! a becomes @ m becomes M B becomes 8 o becomes . Ex: If the input is: mypassword the output is: [email protected]*s

  • Write a program that asks the user to enter a password, and then checks it for...

    Write a program that asks the user to enter a password, and then checks it for a few different requirements before approving it as secure and repeating the final password to the user. The program must re-prompt the user until they provide a password that satisfies all of the conditions. It must also tell the user each of the conditions they failed, and how to fix it. If there is more than one thing wrong (e.g., no lowercase, and longer...

  • i need know how Write a program that tests whether a string is a valid password....

    i need know how Write a program that tests whether a string is a valid password. The password rules are: It must have at least eight characters. It must contain letters AND numbers It must contain at least two digits It must contain an underscore (_) Write a program that prompts the user to enter a password and displays the password entered and whether it is valid or invalid.

  • Write a program that inputs a string from the user representing a password, and checks its...

    Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain: -At least 1 lowercase letter (between 'a' and 'z') and 1 uppercase letter (between 'A' and 'Z'). -At least 1 digit (between '0' and '9' and not between 0 and 9). At least 1 special character (hint: use an else to count all the characters that are not letters or digits). -A minimum length 6 characters. -No spaces...

  • 8.4 in python function that checks whether a string is a valid password. Suppose the pas...

    8.4 in python function that checks whether a string is a valid password. Suppose the pas rules are as follows: . A password must have at least eight characters - A password must consist of only letters and digits. ■ A password must contain at least two digits. Write a program that prompts the user to enter a password and displays valid password if the rules are followed or invalid password otherwise (Occurrences of a specified character) Write a function...

  • 1. Write a C++ program called Password that handles encrypting a password. 2. The program must...

    1. Write a C++ program called Password that handles encrypting a password. 2. The program must perform encryption as follows: a. main method i. Ask the user for a password. ii. Sends the password to a boolean function called isValidPassword to check validity. 1. Returns true if password is at least 8 characters long 2. Returns false if it is not at least 8 characters long iii. If isValidPassword functions returns false 1. Print the following error message “The password...

  • A CERTAIN program to user's password containing rules such as least n length, one uppercase, lowercase,...

    A CERTAIN program to user's password containing rules such as least n length, one uppercase, lowercase, one digit and white space is given as the code down below. So, simiiar to those rules, I need the code for the following questions post in pictures such as no more three consecutive letters of English alphabets, password should not contain User name and so on. //GOAL: To learn how to create that make strong passwords //Purpose: 1)To learn some rules that makes...

  • Please write code using Python. Rubric Assignment Solution Total: 100 pts Program successfully retrieves and validates...

    Please write code using Python. Rubric Assignment Solution Total: 100 pts Program successfully retrieves and validates user input 15 pts Morse Code Function Created 10 pts Function Uses Parameters to get input message 15 pts Function successfully converts passed message to Morse Code and returns the Morse Code equivalent of message 45 pts Program calls Morse Code function and outputs the result of the function (i.e. the actual Morse Code) 15 pts Main Function Requirement Part 2 MUST have a...

  • C Program In this assignment you'll write a program that encrypts the alphabetic letters in a...

    C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT