Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from 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
@ntoskrnl Valid point. Thanks – Basic Mar 25 '14 at 21:08
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
up vote 3 down vote accepted

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.

share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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