Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prediction of the next number generated by C (glibc) rand()

Given a series of numbers generated by rand(), how can I predict the next value? Brute force is out of the question. I'm aware that rand() is basically a linear congruential generator, but also makes bit shifting. What theory can I use to crack it? Any hints will be most welcome :)

like image 428
user1851752 Avatar asked Mar 18 '13 15:03

user1851752


People also ask

Can you predict random number generator?

Yes, it is possible to predict what number a random number generator will produce next. I've seen this called cracking, breaking, or attacking the RNG. Searching for any of those terms along with "random number generator" should turn up a lot of results.

Can rand function generates same value?

The RAND function in stand-alone applications generates the same numbers each time you run your application because the uniform random number generator that RAND uses is initialized to same state when the application is loaded.

Is Rand a pseudorandom?

Pseudorandom numbers are generated by computers. They are not truly random, because when a computer is functioning correctly, nothing it does is random. Computers are deterministic devices — a computer's behavior is entirely predictable, by design.


1 Answers

@unwind: thanks for the advice! I was wrong in some places, and the documentation got me on the right track.

Actually, predicting is a piece of cake when you know a sequence of 30 (or so) numbers. The 'computed' answer will be right in 50% of cases. More details present in the link provided by unwind, or in a simplified code: http://www.mathstat.dal.ca/~selinger/random/

like image 157
user1851752 Avatar answered Sep 28 '22 11:09

user1851752