From 0e1b20349f4c957883dcbc71443b0b5ff0e974f6 Mon Sep 17 00:00:00 2001 From: intelburn Date: Thu, 24 May 2018 20:45:24 -0400 Subject: [PATCH 1/2] Added solution for making the rainbow table --- Protecting_Passwords/intelburn_rainbow_table.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Protecting_Passwords/intelburn_rainbow_table.py diff --git a/Protecting_Passwords/intelburn_rainbow_table.py b/Protecting_Passwords/intelburn_rainbow_table.py new file mode 100644 index 0000000..7a48480 --- /dev/null +++ b/Protecting_Passwords/intelburn_rainbow_table.py @@ -0,0 +1,17 @@ +#This was created by intelburn for a Code With Me challenge +#Import HashLib for the MD5 hashing capability +import hashlib +#open the dictionary file +with open("plaintext_passwords.txt", "r") as candidates: + #Open the file for the future rainbow table + with open("rainbow_table.txt", "w") as rainbow: + #Loop through the lines in dictionary + for line in candidates.readlines(): + #This line does multiple things in one line the next comments will go into the what the line is doing + #First rainbow.write will write the contents of the argument into the file + #hashlib.md5 will calculate the contents on the argument + #line.rstrip() will remove the trailing newline + #.encode() will encode the line for hashlib.md5 + #.hexdigest returns the human readable version of the hash + #Then append a , and the content of the line from the plaintext + rainbow.write(hashlib.md5(line.rstrip().encode()).hexdigest()+","+line) From a82546672a8818b3dc0738659d33c3a27d25e083 Mon Sep 17 00:00:00 2001 From: intelburn Date: Fri, 25 May 2018 09:50:20 -0400 Subject: [PATCH 2/2] Added file to recover passwords using rainbow table --- .../intelburn_check_recovered.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Protecting_Passwords/intelburn_check_recovered.py diff --git a/Protecting_Passwords/intelburn_check_recovered.py b/Protecting_Passwords/intelburn_check_recovered.py new file mode 100644 index 0000000..03ee82e --- /dev/null +++ b/Protecting_Passwords/intelburn_check_recovered.py @@ -0,0 +1,26 @@ +#This was created by intelburn for a Code With Me challenge +#Open the file with all of the recovered hashes +with open("recovered_password_hashes.txt", "r") as hashes: + #Open the csv formatted rainbow table + with open("rainbow_table.txt", "r") as rainbow: + #create a dict for all of the hashes and paintext passwords + solutions={} + #loop through the lines in the rainbow table + for line in rainbow.readlines(): + #make an array of the line with the hash in position 0 and the plaintext in position 1 + #remove any trailing newlines + entry=line.rstrip().split(",") + #add the array to the dict + solutions[entry[0]]=entry[1] + #loop through the lines in the recovered passwords + for line in hashes.readlines(): + #Remove the trailing newline from the recovered password hash + password=line.rstrip() + #check if the recovered hash is in the rainbow table + if password in solutions: + #print the hash and plaintext + print(password+" "+solutions[password]) + #No match found + else: + #print that there is no match + print("Hash {0} not in table".format(password))