Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


RNG seed
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Tue Aug 18, 2015 5:17 pm    Post subject: RNG seed Reply with quote

Hi guys. How do you find rng seed in games ? Especially when the rng isn't shown to you. You know like random in general. For exemple looting.
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Wed Aug 19, 2015 12:35 am    Post subject: Re: RNG seed Reply with quote

Demonarke wrote:
Hi guys. How do you find rng seed in games ? Especially when the rng isn't shown to you. You know like random in general. For exemple looting.


Well, if there's something like "chance of finding magic items % chance", then you can increase it and decrease it and find the address that way. But if you can't change the "random", then you'll have to be more creative than that.
Back to top
View user's profile Send private message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Wed Aug 19, 2015 7:57 am    Post subject: Re: RNG seed Reply with quote

deama1234 wrote:
Demonarke wrote:
Hi guys. How do you find rng seed in games ? Especially when the rng isn't shown to you. You know like random in general. For exemple looting.


Well, if there's something like "chance of finding magic items % chance", then you can increase it and decrease it and find the address that way. But if you can't change the "random", then you'll have to be more creative than that.


And how can I be more creative than that ?
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Wed Aug 19, 2015 9:02 am    Post subject: Re: RNG seed Reply with quote

Demonarke wrote:
deama1234 wrote:
Demonarke wrote:
Hi guys. How do you find rng seed in games ? Especially when the rng isn't shown to you. You know like random in general. For exemple looting.


Well, if there's something like "chance of finding magic items % chance", then you can increase it and decrease it and find the address that way. But if you can't change the "random", then you'll have to be more creative than that.


And how can I be more creative than that ?


If the game uses the 'common PRNG' (the function rand in msvcrt.dll),then you can use the unrandomizer,or even set a breakpoint on it to get the return address [ESP],and find out where exactly the game generates random numbers.

For the seed,you could search for calls to msvcrt.srand, and try to find the only argument : the seed :
Code:
 void srand( unsigned int seed );
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Wed Aug 19, 2015 9:17 am    Post subject: Re: RNG seed Reply with quote

Demonarke wrote:
deama1234 wrote:
Demonarke wrote:
Hi guys. How do you find rng seed in games ? Especially when the rng isn't shown to you. You know like random in general. For exemple looting.


Well, if there's something like "chance of finding magic items % chance", then you can increase it and decrease it and find the address that way. But if you can't change the "random", then you'll have to be more creative than that.


And how can I be more creative than that ?


Depends on the game. Maybe it stores the RNG modifier close to the player's structure? Maybe each item has a base RNG value in its structure?
Back to top
View user's profile Send private message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Wed Aug 19, 2015 9:41 am    Post subject: Re: RNG seed Reply with quote

deama1234 wrote:
Demonarke wrote:
deama1234 wrote:
Demonarke wrote:
Hi guys. How do you find rng seed in games ? Especially when the rng isn't shown to you. You know like random in general. For exemple looting.


Well, if there's something like "chance of finding magic items % chance", then you can increase it and decrease it and find the address that way. But if you can't change the "random", then you'll have to be more creative than that.


And how can I be more creative than that ?


Depends on the game. Maybe it stores the RNG modifier close to the player's structure? Maybe each item has a base RNG value in its structure?


The item was just an example. I'm thinking more like. You know small games where you have chances to get spotted. Chances to succeed an action. Because those are really hard to find. And unrandomizer doesn't recognize it. I hate to say it but the unrandomizer isn't useful at all. Or for very very few games. Are there known codes for random ? That I could search for. Because finding for exemple. The chance of succeding an action is almost impossible with a scan.
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Wed Aug 19, 2015 10:27 am    Post subject: Re: RNG seed Reply with quote

Demonarke wrote:

The item was just an example. I'm thinking more like. You know small games where you have chances to get spotted. Chances to succeed an action. Because those are really hard to find. And unrandomizer doesn't recognize it. I hate to say it but the unrandomizer isn't useful at all. Or for very very few games. Are there known codes for random ? That I could search for. Because finding for exemple. The chance of succeding an action is almost impossible with a scan.


Oh, well; if you can't change those chances (e.g. moving away to reduce spotting chance, or closer to increase it, idk) then I don't really know how you'd do it. Maybe you can hex edit your save files and find the chance that way?
Back to top
View user's profile Send private message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Wed Aug 19, 2015 11:58 am    Post subject: Re: RNG seed Reply with quote

deama1234 wrote:
Demonarke wrote:

The item was just an example. I'm thinking more like. You know small games where you have chances to get spotted. Chances to succeed an action. Because those are really hard to find. And unrandomizer doesn't recognize it. I hate to say it but the unrandomizer isn't useful at all. Or for very very few games. Are there known codes for random ? That I could search for. Because finding for exemple. The chance of succeding an action is almost impossible with a scan.


Oh, well; if you can't change those chances (e.g. moving away to reduce spotting chance, or closer to increase it, idk) then I don't really know how you'd do it. Maybe you can hex edit your save files and find the chance that way?


Damn that's a shot in the dark. Well thanks anyway. I am guessing no one else can help me ?
Back to top
View user's profile Send private message
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Wed Aug 19, 2015 1:30 pm    Post subject: Reply with quote

Personally I don't bother with this 'cause I go one of three routes instead.

A - Play with normal drops.
B - Use a save editor.
C - Hack stats and status and junk.

Each of which is far less work and all that jazz.
Not many people have experience reversing RNG systems for these and other reasons.

_________________
Back to top
View user's profile Send private message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Wed Aug 19, 2015 2:24 pm    Post subject: Reply with quote

Rydian wrote:
Personally I don't bother with this 'cause I go one of three routes instead.

A - Play with normal drops.
B - Use a save editor.
C - Hack stats and status and junk.

Each of which is far less work and all that jazz.
Not many people have experience reversing RNG systems for these and other reasons.


Not all games have save editors. And especially indie games. And hex editing can be hard when you are searching for small values but I get it. Reverse rng is hard...
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Wed Aug 19, 2015 3:07 pm    Post subject: Reply with quote

I've seen Mersenne twisters (MT) in several (jap) games and this article ( https://jazzy.id.au/2010/09/22/cracking_random_number_generators_part_3.html ) confirms it's a pretty popular PRNG, so I'd try to see if your game uses a MT.
How?
By scanning for its specific constants (0x9908b0df, 0x9d2c5680, 0xefc60000) in executable memory (which is not CE's default setting); if I see them in bunch of code mostly made of additions/xoring/shifting/masking along with a few 623/624 (0x26F/0x270) I'll assume I found a MT. Check if this function is actually used ingame, and if it is, find the MT's state array, and the function that initializes it. Your seed is passed on to this function.

But tbh, it's not how I found the MTs I mentioned earlier; I accidentally stumbled upon them while back tracing decryption functions.

As for detecting other PRNGs, it's the same idea, just with different constants.
...Or maybe your game is simply reading how many cpu clock cycles have elapsed since the start of your computer, and uses the lower digits of that as a random number, in which case it might be simpler to start from the consequence, ie: Random chance to be detected? The enemy moves toward you when you are detected, so find position, find what changes position, find why position changed and you'll have the detected on/of flag, then find what changes detection, then find why detection changed and you'll have the output of your PRNG, then dive into it... Not the simplest hack ever, but theoretically doable, especially on small/old games.

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Wed Aug 19, 2015 4:13 pm    Post subject: Reply with quote

Gniarf wrote:
I've seen Mersenne twisters (MT) in several (jap) games and this article ( https://jazzy.id.au/2010/09/22/cracking_random_number_generators_part_3.html ) confirms it's a pretty popular PRNG, so I'd try to see if your game uses a MT.
How?
By scanning for its specific constants (0x9908b0df, 0x9d2c5680, 0xefc60000) in executable memory (which is not CE's default setting); if I see them in bunch of code mostly made of additions/xoring/shifting/masking along with a few 623/624 (0x26F/0x270) I'll assume I found a MT. Check if this function is actually used ingame, and if it is, find the MT's state array, and the function that initializes it. Your seed is passed on to this function.

But tbh, it's not how I found the MTs I mentioned earlier; I accidentally stumbled upon them while back tracing decryption functions.

As for detecting other PRNGs, it's the same idea, just with different constants.
...Or maybe your game is simply reading how many cpu clock cycles have elapsed since the start of your computer, and uses the lower digits of that as a random number, in which case it might be simpler to start from the consequence, ie: Random chance to be detected? The enemy moves toward you when you are detected, so find position, find what changes position, find why position changed and you'll have the detected on/of flag, then find what changes detection, then find why detection changed and you'll have the output of your PRNG, then dive into it... Not the simplest hack ever, but theoretically doable, especially on small/old games.


Yeah well I'm not an expert and I understand half of what you said :/ too bad. Guess I'll have to train hard...
Back to top
View user's profile Send private message
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Wed Aug 19, 2015 4:51 pm    Post subject: Reply with quote

Well, what is your end goal?

If it's just to mess with the RNG by raising chances on things, an alternate method could be to see if the game's install folder has loot pools in some sort of editable text format like JSON or XML or something.

_________________
Back to top
View user's profile Send private message
Demonarke
Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 31

PostPosted: Wed Aug 19, 2015 5:12 pm    Post subject: Reply with quote

Rydian wrote:
Well, what is your end goal?

If it's just to mess with the RNG by raising chances on things, an alternate method could be to see if the game's install folder has loot pools in some sort of editable text format like JSON or XML or something.


this happen very rarely. I mean most of the time things are encrypted. This is indie games but it is kinda known anyway. But I wanted to find RNG in general you know. In fact this is almost the only real thing I want to do in games O_o .But I've never been able to find how to do it. And I don't think editing files is an option. Except if you can decrypt it but I don't see how.
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Thu Aug 20, 2015 8:29 am    Post subject: Reply with quote

Thinking again about it, every PRNG has a state stored somewhere, it can be a list of numbers (like for a MT), or it can be a single number. If there is a list, there is an additional number -the index- that tells the generator which entry it should pull out of the list.
So in theory there should be a variable (the state or the index) that changes every time the generator spits something, and only at that time, meaning you could find it with changed/unchanged scans, freeze it and always get the same results.

(There is also the case where an entry of a list would be modified after being used, there you'd have to find another variable after locking the index)

Hint: for a Mersenne twister, the index varies between 0 and 623, increasing (or decreasing) by 1 at each draw, until it reaches 623 (or 0) where it resets to 0 (or 623)

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites