So, I have this:
I know that some code was used to generate a random sequence, and it looked roughly like this:
#include <iostream>
#include <string>
int main() {
const std::string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
std::string temp = "1234567890";
srand(MAGICNUMBER);
for (int i = 0;; ++i) {
for (int j = 0; j < 10; ++j) {
temp[j] = alphabet[rand() % alphabet.size()];
}
std::cout << temp << std::endl;
}
}
It was used to generate a sequence of 124660967 strings, the last of which was "2lwd9JjVnE", and then stopped. The compilator used was 64-bit g++ 4.8 for Linux. What I want is to find the 124660968th string – that is, the one that would have been printed next. The caveat, of course, is that I don't know the MAGICNUMBER
. I'm pretty sure that it's possible to brute-force all possibilities, but it would take millennia, it seems. I've tried to snoop around in rand()
source code, but I don't really understand it, much less exploit it. Is it possible to find that string in more or less reasonable time?
UPD Is it even possible to generate what is supposed to go after my string without finding out the seed?