Wednesday 14 August 2013

Generating an small MD5 Rainbow Table in C#

I need a simple Rainbow Table today, and since I couldn’t easily find one I could download, I decided to create it in C#

So I went to the O2 Platform REPL and quickly wrote this script (included in full at the end of this post):


image

… which creates files with MD5 Hashes:

image

… in the “{MD5} \tab {value} \newline” format:

image

Note: It might be easier to see what is inside these txt files if I rename the names to:

image

Note that this version is VERY inefficient from a memory point of view. This is why its limits are at about 70Mbs, which at the moment are reached with:
  • 10x numbers with a depth/length of 6
  • 26x letters with a depth/length of 4
  • 10x numbers and 26x letters (36 chars) with a depth/length of 4
A better way to do this is to use a light database to store the values (anybody wants to do that?) and to put it on azure

To consume these files

1)  load the md5 hashes files:

image

2) get its contents:

image

3) split the file on its lines

image

4) create a Dictionary to hold the mappings (which is a split of \tab for each line):

image

5) resolve an MD5 Hash (for example FBD7939D674997CDB4692D34DE8633C4):

image

… which is the number 76

Note: we can confirm this result, if we try to resolve the FBD7939D674997CDB4692D34DE8633C4 hash on http://www.md5this.com/:

image

6) create a GUI to resolve the MD5 Hashes:

image

… which when executed looks like this (on first run)

image

… like this when there is a match:

image

… and like this when there is no match:

image

For reference the 40Mb file with 45,432,060  hashes loaded in about 25sec and resolved hashes like in milliseconds:

image

Source code of scripts created
(also available as the PoC - Generate Small MD5 Rainbow Table.h2 and PoC - Consume Simple MD5 Rainbow Table.h2 scripts)