Finding the seed of a random sequence

Look at the following piece of code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <EVERYTHING>

const unsigned int MAX = 10000;

int main()
{
   srand(time(NULL));
   int Numbers[MAX];
   int Unknown;

   for(unsigned int i = 0; i < MAX; i++)
   {
      Numbers[i] = rand()%255;
   }

   Unknown = rand()%255;
}


By knowing a given set of values of Numbers, is it possible to either calculate the seed of the random function (find the time that the program ran), or calculate what Unknown will be without brute forcing every possible seed? Suppose I know/wrote the specific algorithm that this implementation of rand() uses.

If anyone has any insight to this problem, or knows any literature either in print or on the web that I could consult, that would be lovely.

Thank you.
Well, the answer depends on the algorithm used to generate the pseudo-random numbers. But if I understand correctly, most implementations of rand() use a linear congruential generator [1].

In that case, you're lucky. As someone has written a paper about this!

"How to crack a Linear Congruential Generator", Haldir, 22nd December 2004
http://www.reteam.org/papers/e59.pdf

It is about solving the simple case, so am unsure of its limitations.

Andy

[1] Linear congruential generator
http://en.wikipedia.org/wiki/Linear_congruential_generator
Of things I was looking for, this was exactly it.

The title of the article also gave me the correct terms to google for.

Thank you.
Topic archived. No new replies allowed.