Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Suppose I wanted to have this script run through more than one shadow file, what would the code look like? So it would go through/open
Suppose I wanted to have this script run through more than one shadow file, what would the code look like? So it would go through/open shadow one then shadow 2 etc....
I have 3 files total. Shadow1-3
import hashLib #Open the files in read mode shadowopen('shadow1', 'r') dictionary = openCdictionary.txt', 'r') #Loop through all lines in the shadow file for line in shadow: #Split username:MDShash the line using the ":" delimiter entry line . split(':' ,1) The first item in the list of split values is the username #We also strip the values of any invisible characters #in the beginning or end using the strip() function user entry[0].stripO) #The hash value is the next hash = entry[1] . strip #Reset the dictionary file cursor to the start of the file dictionary.seek(0,0) #For each line in the shadow file loop #through all lines in the dictionary for word in dictionary: #For each line in the shadow file loop through all lines in the #dictionary and salt values from 0x00 to 0xFF for i in range(256): salt = chr(i) password = Word. strip saltedpassword salt password We initialize the MD5 hashlib object in the loop so that #it reinitializes every time, clearing its contents x = hashlib.md50 #Compute the digest x.update(saltedpassword) #if the generated hash matches the shadow hash --> Success! if (x.hexdigest() == hash): print '::.format(user, i, passwordStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started