Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Rainbow Tables Challenge
#!/usr/bin/env python3
import argparse
import math
import random
import hashlib
import codecs
Given the following MD5 Rainbow table that was generate using this program, determine
the password for this hash bcccb2598de87da2952522eae448b356. You must use this program
to solve the problem. Bruteforce md5 cracking will not count.
[['mark', '0drUPiyl'],
['ed', 'qPYgBkmL'],
['don', 'iVDxXJuE'],
['chris', 'koaEUK4z'],
['bill', 'FRIdNmNT'],
['tad', 'z0Smes0J'],
['lester', 'BzInH0n2'],
['josh', 'gcFqhXph']]
def reduction_function(ahash_hexdigest):
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
ahash_digest = codecs.decode(ahash_hexdigest,"HEX")
bignumber = int.from_bytes(ahash_digest, byteorder = "little")
base = len(charset)
max_length = 8
rnum = bignumber % base**max_length
random_length = math.ceil(math.log(rnum, base))
pw = ""
while bignumber > 0 and len(pw)<random_length:
pw = pw + charset[bignumber%base]
bignumber -= (bignumber % base)
bignumber //= base-1
return pw
parser = argparse.ArgumentParser()
parser.add_argument("HASH", type=str, help = "A Hexidecimal hash to reduce to the next possible password")
parser.add_argument("-r","--rehash", action="store_true", help = "If this argument is passed it will reduce the hash to a new password and then convert the new password to a MD5 hash.")
args = parser.parse_args()
newpw = reduction_function(args.HASH)
if args.rehash:
newpw= hashlib.md5(newpw.encode()).hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment