Anti-hacking using maths
#1
Posted 11 December 2011 - 04:17 AM
Begin step;
x = (((22*x)-7)/4)+.123 (packing)
End step;
x = (((x-.123)*4)+7)/22 (unpacking)
if x is now a decimal, then we've been hacking. See below
Alright, if x is a decimal then that means that between the begin step and end step events, the variable has been modified - unless the hacker chooses an extremely random decimal and gamemaker's rounding to 2 decimal places lands a very lucky shot, the game should catch the hacker.
However (I know very little about programs that modify these variables eg Cheatengine) the hacker can change the variable during the begin step, end step or draw events and mess up this method, yes? Does this mean that if the hacker continues to try to modify variables eventually it will work? Does it also mean that the unpacking and checking should occur in the draw event, as that reduces the amount of time a hacking program can modify the variables?
Also, this method will probably slow down the game a bit (does gamemakers rounding decimals reduce the work it has to do?), so how much math would be required to still have a high probability of catching the hacker out, but retain the performance of the game itself?
I'd actually be pretty interested in the probability (with working) of the math I gave above for a variable being changed by 1 or some whole integer.
#2
Posted 11 December 2011 - 06:28 AM
#3
Posted 11 December 2011 - 04:31 PM
Recently I saw something like this to protect the valuable variables in a game, replace x with them;
Begin step;
x = (((22*x)-7)/4)+.123 (packing)
End step;
x = (((x-.123)*4)+7)/22 (unpacking)
if x is now a decimal, then we've been hacking. See below
Alright, if x is a decimal then that means that between the begin step and end step events, the variable has been modified - unless the hacker chooses an extremely random decimal and gamemaker's rounding to 2 decimal places lands a very lucky shot, the game should catch the hacker.
However (I know very little about programs that modify these variables eg Cheatengine) the hacker can change the variable during the begin step, end step or draw events and mess up this method, yes? Does this mean that if the hacker continues to try to modify variables eventually it will work? Does it also mean that the unpacking and checking should occur in the draw event, as that reduces the amount of time a hacking program can modify the variables?
Also, this method will probably slow down the game a bit (does gamemakers rounding decimals reduce the work it has to do?), so how much math would be required to still have a high probability of catching the hacker out, but retain the performance of the game itself?
I'd actually be pretty interested in the probability (with working) of the math I gave above for a variable being changed by 1 or some whole integer.
GameMaker naturally modifies the x variable between the begin step and end step. This won't work.
GameMaker doesn't round variables to two variables, though the string function will for display purposes only.
Edited by NakedPaulToast, 11 December 2011 - 04:31 PM.
#4
Posted 11 December 2011 - 08:31 PM
1) if the same number gives the same encoded result then it's rather poor approach;
2) if the sensible variables use the same mem offset then it's but useless;
3) if 'protection' makes the software rather complex or oven unstable then;
4) very few games are even worth cheating, let alone made in GM...
Anyway, just add built-in cheat and let those who really want to use it.
#5
Posted 11 December 2011 - 08:45 PM
For those you may want to have 'verification' variables along with all important ones.
So you would create a script(s) like:
// score_set(value, skip) - changes score // value - new score value // skip - skip verification if (!argument1) if ((score ^ 77) != score_) global.is_cheating = true; score = argument0; score_ = score ^ 77;Replace '^ 77' by calculation of choice - be that division, lengthdir, or checksum.
This method leaves variable(s) well exposed, however you will know if player changed something, and take care - be that shutting the game down, resetting their score, or kicking them out just before the end of game (warning: may cause hate).
#6
Posted 11 December 2011 - 10:52 PM
NPT:
GameMaker naturally modifies the x variable between the begin step and end step. This won't work.
GameMaker doesn't round variables to two variables, though the string function will for display purposes only.
Why does GM modify the x variable? I really hope you're not meaning all the variables and mistook my meaning of x being co-ordinate variables...
And yeah, wow, GM doesn't actually round the decimals except when displaying them, which is a bit weird. Again, why was this done...? >_>
DZiW... please don't assume the importance of this protection to be null. Even if it was, that is not the question.
YAL: I don't really see how that helps at all?
#8
Posted 12 December 2011 - 02:10 AM
That's their problem if they get pleasure out of freaking CHEATING on someone's game maker game, I mean seriously...
#9
Posted 12 December 2011 - 02:41 AM
Why do you care so much if people cheat in your game?
That's their problem if they get pleasure out of freaking CHEATING on someone's game maker game, I mean seriously...
These comments are beginning to irritate me. Evidently you cannot conceive a possible scenario where cheating would be detrimental to other players; ie online communication. If you are not going to post something useful, please do not post at all.
#10
Posted 12 December 2011 - 05:37 AM
GameMaker changes a lot of its own variables every step. If hacker has patience to do step-by-step debugging of your game to track down second variable, figure out it's formulae, and change those at once, anti-hacking protections wouldn't protect your game anyway.YAL: After re-reading that, I understand and it's a pretty good method other than a hacker aware of this could observe the trend between both variables. I like this method though. What about speed? Would the extra memory and math calculations matter much?
About performance - depends on operations that you perform, but in most cases not significiant (other in-game calculations are likely to take more time than it anyway). I have succesfully used Le Maire's random number generation algorithm (value_ = ((value * const1) + const2) mod const3) for this purpose in few games and it still wasn't noticable behind other calculations. Obviously, a more complex algorithm also makes it harder to track down 'protecting' variable.
#11
Posted 12 December 2011 - 01:26 PM
Furthermore, all GM EXE are so easily ripped back as GMx/K that I don't think it's a real problem--so now you have also to check CRC/MD5 or something too, right? Go ahead and on
The 'real' protection which I find really cute makes a few indirect checks, but doesn't cry out 'WOLF! WOLF!' or something, it just modifies memory a heap/data so that the app successfully crashes--every cheat is a crash.
But there's no need of it all: if one really wants he can just modify the routine or send his modified data to your server of hi-scores even without running your game. So, the only relevant criterion of hi-score is... game time?
#12
Posted 12 December 2011 - 02:52 PM
Why does GM modify the x variable? I really hope you're not meaning all the variables and mistook my meaning of x being co-ordinate variables...
Yes I interpreted your use of the x variable as the co-ordinate. That's what the x variable represents.
For convenience. Take the default of two decimal points or use string_format if you want to control the number of decimal points.And yeah, wow, GM doesn't actually round the decimals except when displaying them, which is a bit weird. Again, why was this done...?
#13
Posted 12 December 2011 - 07:56 PM
Begin step;
x = (((22*x)-7)/4)+.123 (packing)
End step;
x = (((x-.123)*4)+7)/22 (unpacking)
if x is now a decimal, then we've been hacking.
I need to place a word of warning here, because GM cannot exactly represent the number 0.123. The reason is that computers work in binary and the decimal fraction 0.12310 is in fact the binary fraction
0.00011111011111001110110110010001011010000111001010110000001000001100010010011011101001011110001101010012
in binary (the undelined part is the period, should be overlined instead of underlined).
So GM will round this number, it will not be exactly decimal 0.123 anymore. It may only differ for 2-53 (I believe), but a difference that small will make x into a decimal (because 256.000000000000001 is a decimal).
For this reason I'm always cautious with floating point arithmetic and I prefer integer arithmetic for those kinds of things.
#14
Posted 13 December 2011 - 01:41 AM
Why does GM modify the x variable? I really hope you're not meaning all the variables and mistook my meaning of x being co-ordinate variables...
Yes I interpreted your use of the x variable as the co-ordinate. That's what the x variable represents.
Recently I saw something like this to protect the valuable variables in a game, replace x with them;
Erik, that's actually really interesting, so you're saying that I should use something 'nice' for binary? I'ma test that out...
Anyway thanks a lot YellowAfterlife, your points are most helpful.
#15
Posted 18 December 2011 - 07:21 PM
For onstance, in my demo I used hack-revealing method of 'score/time' aspect where time value was encoded with fingeprints (e.g. '24-Hh' and '60-Mm'), so I could check the pseudo-CRC and assess allegedly time spent. The point is when one sees the formula then it's more than trivial to use math-reversal: a friend of mine once showed me how hacked hi-score sending routine without real hacking - just via ol' TCP_VIEW!
Yet I would like to make a compliment to you: if at least someone really wanted to hack your GM game then it must be something really worthy
#16
Posted 11 January 2012 - 09:28 PM
It's simple and it sure covers the variable in Cheat Engine.
#17
Posted 12 January 2012 - 01:07 AM
Cheating is critical only for games where online highscores or achievements are available.
So if you are going to have online highscores, you might as well use a server and have the important variables stored by the server.
Otherwise the safest way in my opinion is encryption but I don't really see the point of having so much protection for simple single-player games.
Also keep in mind that everything can be hacked.
Edit: If Game Maker stores data in RAM at the exact moment when you assign a value to a variable (I'm 99% sure that this is what it does), then I believe that to determine what time Cheat Engine can capture variables you would need to know in what order the CPU executes the commands (GameMaker's first or Cheat Engine's). If Cheat Engine captures data directly from RAM, and Game Maker stores data immediately in RAM then you would need to find out which program's commands are executed first.
Edited by loverock125, 12 January 2012 - 01:16 AM.
#18
Posted 27 February 2012 - 08:46 PM
Thus the anti randomizer function which would help for code injections.
What you wanna do is:
-When the game is paused varibles add a random number which is stored and minus off when unpaused (I say this because if the change is constant during the pause it will be very easy, for obvious reasons)
-Have two varible to represent one. Eg, money have coins and cents.. Once cents equals 100, it is sent to 0 and we then have a coin.
If the player doesnt know this is happening since the score will be reprensented visually as something different, we have our solution.
Edited by jonathanz, 27 February 2012 - 08:52 PM.
#19
Posted 20 March 2012 - 10:40 PM
#20
Posted 29 April 2012 - 10:29 AM
Was this a good suggestion or no ?
Edited by Primoz128, 29 April 2012 - 10:36 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











