Rainbow Tables Question

Discussion in 'Networking & Security' started by JC724, Mar 11, 2018.

  1. JC724

    JC724 [H]Lite

    Jan 20, 2016
    I am learning about rainbow tables. I am trying to write a reversal function.

    Can someone give me some guidelines on how to do this? I am working with MD5 hash and trying to reverse the hash so I can see the password.
  2. grasshoppa

    grasshoppa [H]Lite

    Jun 18, 2017
    So you want to take a hash and pull out the plaintext password? Why not use any freely available database technology, import your tables and do a simple select?
  3. bman212121

    bman212121 [H]ard|Gawd

    Aug 18, 2011
    A rainbow table isn't a reverse function. There is no way to actually reverse the hash so it spits out the key that was used to hash the file with, as that would be bad. What you can do however is take guesses at what the original value was, and generate the hash and then compare them. So let's say I hash asdf using MD5.

    That gives you:

    Your Hash: 912ec803b2ce49e4a541068d495ab570

    Your String: asdf

    Once you have that hash, you can't convert 912ec803b2ce49e4a541068d495ab570 back into asdf. It doesn't work that way. But if I know that my original value was asdf, I can rerun asdf through an md5 hash and compare the two steps. If the output matches, then I know that I have the right input.

    But if I don't know the input needs to be asdf, I can just start slamming guesses.

    I can try asdd, which is:

    Your Hash: 0ec53c34ceb021b4c7907d31db2ff752

    Your String: asdd

    You can clearly see that hash doesn't match the original one, so your program will compare that hash to the one it has stored, and say it doesn't match and not perform whatever function it was supposed to do. (Like letting you login)

    So then I try asde, and that still doesn't work.

    Your Hash: 56fb167809cddf32a68168c0511c654d

    Your String: asde

    Then I finally try asdf:

    Your Hash: 912ec803b2ce49e4a541068d495ab570

    Your String: asdf

    Yup, that hash matches the hash I had stored, so go ahead and do some function.

    As you can see if you don't know you can brute force your way in by taking guesses. But having to take guesses can take a considerable amount of time. What we can do to make this faster is to just start at "a", and generate the hash for that and store it, then generate "b", and store that hash. So to make a rainbow table, you need to create a loop that generates hashes for everything from "a" through "ZZZZZZZZZ" and stores them. Someone has already done all of that work and saved it into a document for you to import, so you don't have to calculate it on the fly. That's what the rainbow table is, a listing of every possible combination and what the hash value is. So the "reversal" function is simply obtaining a hash from somewhere, and then looking it up in your document, database, or whatever it is, and then seeing what it says should be the original value.

    So to the original question, do you actually need to generate your own rainbow table, or do you just need to write something to lookup a hash and provide the associated value? If you just need to download a rainbow table to look stuff up, you can use select-string from powershell, or grep on Linux to just search a flatfile for a string a return the line. You certainly don't need it to be in a database if you just want to pull a couple of strings out. It might take a minute or so to search a few hundred megabyte text doc, but either one should have no problems returning the data you need.
    Ur_Mom likes this.
  4. SticKx911

    SticKx911 [H]ard|Gawd

    Mar 14, 2004