Skip to content

This class is able to predict the random numbers generated by the Random class in .NET (based on the workings of the Random class in .NET framework 4.8)

License

Notifications You must be signed in to change notification settings

SeppeDejonckheere/dotnet-randcrack

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

dotnet-randcrack

This class is able to predict the random numbers generated by the legacy random number generator in .NET (based on the workings of the Random class in .NET framework 4.8 as described here). The legacy version of the random number generator is used when:

  • Your code targets .NET verions prior to .NET 6.0
  • Your code targets .NET 6.0 or newer and you passed a seed into the constructor of the Random object.

How it works

A pseudo random number generator generates numbers based on an internal state. If the internal state is known, it is possible to predict the next numbers that will be generated. The RandCrack class is able to determine the internal state of the .NET legacy random number generator, and use this information to predict the numbers that will be generated in the future.

How to use

In order to use RandCrack you have to create a RandCrack object and give it an array of at least 55 consecutively generated 32 bit numbers. These 55 numbers are necessary to determine the state of the generator. After that, you can predict the coming numbers in the same way as you would generate them with a Random object.

Random r = new Random(secretseed);

// Generate at least 55 numbers, these are used to determine the state of the generator
int[] series = new int[55];
for(int i = 0 ; i< series.Length ; i++)
{
  series[i] = r.Next();
}

RandCracker rc = new RandCracker(series);
int pred = rc.PredictNext();
int actual = r.Next();

Console.WriteLine("Random result " + actual + " | Predicted result " +  pred);

About

This class is able to predict the random numbers generated by the Random class in .NET (based on the workings of the Random class in .NET framework 4.8)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%