4

While pointing out a SQL injection flaw on another question, I was able to show that an arbitrary sha1 hash could be inserted into a query such that it would be taken for a real hash, and was therefore able to login assuming the dummy hash was used. I could inject an ORDER BY but then wanted to make sure the hash I was using as an example was likely to come out at the top.

From my understanding, 0000000...0 should be a valid possible output from the hash function but, of course, finding the associated input is non-trivial.

In any case, it got me wondering. Is there any way - except brute force or downloading a rainbow table - to find a hash that would sort before an arbitrary point (say before 99% of passwords =~ in the first 1.46150x10^46)

I suspect the answer is no but would like confirmation.

migrated from stackoverflow.com Mar 26 '14 at 4:44

This question came from our site for professional and enthusiast programmers.

  • Perhaps better suited at crypto.SE since no programming is involved. – ntoskrnl Mar 25 '14 at 20:54
  • 1
    Bitcoin mining is very similar to this: The goal it to find an x for which SHA256(SHA256(x)) starts with enough leading zero bits. – CodesInChaos Mar 26 '14 at 8:47
  • @CodesInChaos Fascinating. I never took the time to look intop what bitcoin was doing under the hood. Thanks very much – Basic Mar 26 '14 at 9:17
3

If there is a method faster than brute force, it represents a weakness in the hash function. Essentially what you're looking for is a modified preimage attack, just for a group of hash values rather than a single value.

  • From the link... "By definition, an ideal hash function is such that the fastest way to compute a first or second preimage is through a brute force attack". That pretty much hits the nail on the head. Thanks for the reference. – Basic Mar 26 '14 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.