dimanche 4 septembre 2016

Emulate C# Random() in C++ (Same Numbers)

Is there a way to implement the C# Random() class in C++? I specifically need to generate the same number sequences based on a given seed.

The scenario: I am working to "break" several encrypting malware by exploiting their usage of Random() in C# to generate the key. Obviously this is weak to having only 2^32 possible keys, ~4.3B keys, which is in the realm of possibility to guess. I have written bruteforcers in C#, but they are rather slow, no matter how much I optimize. I would like to implement a bruteforcer in C++ for the best efficiency ("closer to the hardware"), as I can get much better speed optimizations with the decryption part (e.g. AES-256 typically, could even leverage a GPU in the future), and exponentially get better outputs.

Obviously, Random(seed) != srand(seed), based on being different generators. Is there a way to implement the PRNG C# uses, in C++? I obviously cannot modify the C# malware, as the encryption has already been done to the victim's files, so I cannot just "rewrite both to use the same common RNG".




Aucun commentaire:

Enregistrer un commentaire