Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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).

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: The brute force method will be more than adequate to the task. This program doesn't print anything, I don't know what's wrong please help!

image text in transcribed

import hashlib def get_password(password_hash): password = [0, 0, 0, 0, 0, 0, 0, 0] # create a password array of size 8 possible_letters - "abcdefghijklmnopqrstuvwxy ZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" for chi in possible_letters: password[] = chi 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 = "" 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 def main(): password = "aR3fg570" password_hash = hashlib.shal(password. encode()) cracked_password = get_password(password_hash) print(cracked_password) - if __name__ == '__main_': main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions