views:

4010

answers:

11

Someone told me that he has seen software systems that would accept MD5 encrypted passwords (through various integrations with other systems), decrypt them, and store them in the systems own database using it's own algorithm.

Is that possible? I thought that it wasn't possible (feasible) to decrypt MD5 hashes.

I know there are MD5 dictionaries, but is there an actual decryption algorithm?

+31  A: 

No. MD5 is not encryption (though it may be used as part of some encryption algorithms), it is a one way hash function. Much of the original data is actually "lost" as part of the transformation.

Think about this: An MD5 is always 128 bits long. That means that there are 2128 possible MD5 hashes. That is a reasonably large number, and yet it is most definitely finite. And yet, there are an infinite number of possible inputs to a given hash function (and most of them contain more than 128 bits, or a measly 16 bytes). So there are actually an infinite number of possibilities for data that would hash to the same value. The thing that makes hashes interesting is that it is incredibly difficult to find two pieces of data that hash to the same value, and the chances of it happening by accident are almost 0.

A simple example for a (very insecure) hash function (and this illustrates the general idea of it being one-way) would be to take all of the bits of a piece of data, and treat it as a large number. Next, perform integer division using some large (probably prime) number n and take the remainder (see: Modulus). You will be left with some number between 0 and n. If you were to perform the same calculation again (any time, on any computer, anywhere), using the exact same string, it will come up with the same value. And yet, there is no way to find out what the original value was, since there are an infinite number of numbers that have that exact remainder, when divided by n.

That said, MD5 has been found to have some weaknesses, such that with some complex mathematics, it may be possible to find a collision without trying out 2128 possible input strings. And the fact that most passwords are short, and people often use common values (like "password" or "secret") means that in some cases, you can make a reasonably good guess at someone's password by Googling for the hash or using a Rainbow table. That is one reason why you should always "salt" hashed passwords, so that two identical values, when hashed, will not hash to the same value.

Once a piece of data has been run through a hash function, there is no going back.

Adam Batkin
+1 you beat me to it
Robert Greiner
however, there are more collisions than originally thought in the MD5 hash space. It is no longer considered optimal as the best hash for passwords.
Cheeso
And that is why the NIST is running a competition to determine a replacement for the SHA-1 and SHA-2 algorithms, all of which are more secure than MD5. MD5 should not be used in new security-critical applications. It is not clear that SHA-1 is safe. SHA-2 is recommended until SHA-3 is available.
Jonathan Leffler
+9  A: 

Not directly. Because of the pigeonhole principle, there is (likely) more than one value that hashes to any given MD5 output. As such, you can't reverse it with certainty. Moreover, MD5 is made to make it difficult to find any such reversed hash (however there have been attacks that produce collisions - that is, produce two values that hash to the same result, but you can't control what the resulting MD5 value will be).

However, if you restrict the search space to, for example, common passwords with length under N, you might no longer have the irreversibility property (because the number of MD5 outputs is much greater than the number of strings in the domain of interest). Then you can use a rainbow table or similar to reverse hashes.

bdonlan
I would add that finding another value that hashes to the same output is called a "collision". This is the most common method of breaking MD5-hashed systems.
Renesis
@Renesis, finding data that hashes to a previously known value is called a "preimage", actually, and it's much, _much_ harder than just a collision. No preimage attack has yet been demonstrated against MD5, but collision attacks have been used.
bdonlan
+1  A: 

No, it cannot be done. Either you can use a dictionary, or you can try hashing different values until you get the hash that you are seeking. But it cannot be "decrypted".

Vilx-
+4  A: 

No, he must have been confused about the MD5 dictionaries.

Cryptographic hashes (MD5, etc...) are one way and you can't get back to the original message with only the digest unless you have some other information about the original message, etc. that you shouldn't.

Robert Greiner
Just to nitpick, additional information about the *algorithm* would be irrelevant, since the MD5 algorithm is well-known; whereas additional information about the *input* (or "message") could narrow down the remainder.
harpo
oh, thank you for catching that, it completely slipped by me.
Robert Greiner
A: 

No, there are dictionaries as you say, but no way to decrypt MD5

instanceofTom
A: 

MD5 is considered broken, not because you can get back the original content from the hash, but because with work, you can craft two messages that hash to the same hash.

You cannot un-hash an MD5 hash.

Ned Batchelder
By design, all same-length hashes suffer from collisions. It's unavoidable when restraining variable-length data. MD5 is considered obsolete for its rate of collisions, not for the fact of colliding.
Jonathan Lonowski
MD5 is considered broken because of the proven possibility of constructing inputs that collide.
Ned Batchelder
A: 

No but you can build a comparaison tool like a "dictionary"

dassouki
+4  A: 

Decryption (directly getting the the plain text from the hashed value, in an algorithmic way), no.

There are, however, methods that use what is known as a rainbow table. It is pretty feasible if your passwords are hashed without a salt.

Sinan Taifour
+1  A: 

You can find online tools that use a dictionary to retrieve the original message.
In some cases, the dictionary method might just be useless:
- if the message is hashed using a SALT message
- if the message is hash more than once
For example, here is one md5 decrypter online tool!
David

davitz38
A: 

Well you can't decrypt it directly. Md5 it's one way hash function. But there are some limited choices, like this database with md5 decrypted strings. md5-decrypter.com

andrei