Home  >  Article  >  Anti-cheating in game development and a brief introduction to its principles

Anti-cheating in game development and a brief introduction to its principles

(*-*)浩
(*-*)浩forward
2019-08-09 17:11:283162browse

Preface

Anti-cheating in game development and a brief introduction to its principles

How to prevent cheating still accounts for a very important proportion in game development, which also involves Regarding game profitability, if anti-cheating measures are not taken, the app we develop may be released online the next day or a cracked free version will be released the next day. I have experienced this personally. Of course, this is based on the app and is easier to be cheated by cheating companies. I’ve been following it. The once popular PC version of the chicken game is actually very rampant in cheating. This is also because there is no anti-cheating. Job seekers are often asked how to prevent cheating when applying for jobs. Of course, we can think of the simplest way. The solution is not to trust any data on the client, but to verify the server data. Of course, this solution can be designed like this in some situations where there is relatively little client-server interaction. Assuming FPS, the damage caused by each shot is one frame. There will be many shots in it. It is impossible to check with the server every time. The interaction is too frequent and the experience is very poor. But if it is not checked, the client will modify the weapon attribute value. This is the client cheating. How? To solve this problem, the following will introduce anti-cheating ideas.

How to cheat on the client

Mobile version

When I first started playing mobile games, I must have played Flappy Bird. Everyone who plays the game knows that it is a very cruel mobile game. It was also very popular at the time, and everyone in the circle of friends was posting their scores. Later, I learned that I could use an app called "Eight Gate Artifacts" to cheat and modify the scores, and then modify them to very high scores. Posting your scores in your circle of friends will make you look "very awesome" and satisfy your own vanity. The principle is to modify the score memory value to achieve the effect of cheating.

PC side

There are also corresponding software for modifying the memory on PC, such as Cheat Engine, which is similar to the eight-door artifact on the mobile phone. How to apply it is shown in the figure below:

Anti-cheating in game development and a brief introduction to its principles

How to prevent cheating

Unity development recommends a plug-in called Anti-Cheat Toolkit, which you can download from the Asset Store. The specific principle is that through data obfuscation, the value displayed on the UI is actually the value we calculated, so the memory modifier cannot find the memory address based on the value displayed on the UI.

Anti-cheating principle

private int curATK;
private int curAtkKey;
public int CurATK {
    get {
        return curATK ^ curAtkKey;
    }
    set {
        curAtkKey = Random.Range(0, 0xffff);
        curATK = value^curAtkKey;
    }
}

Analysis: The ^ operation is an XOR operation, which requires a little bit of binary knowledge. The XOR operation means that the same is 0 and the difference is 1. Here is an example: 3 ^ 4=7, the binary number corresponding to 3 is 11, the binary number corresponding to 4 is 100, the binary number result after the XOR operation is 111, and the corresponding decimal number is 7. Verify it with the program below:

Anti-cheating in game development and a brief introduction to its principles

Analysis

According to the above program, do you really understand how to prevent cheating? num is the value we input. For example, the player’s current number of gold coins is 4. But the display on our UI is not directly Coin.Text = num.ToString(). In this way, the player can easily modify the memory of num, which is cheating. The value displayed on our UI is the value of hiddenValue^cryptoKey. Even if the player finds the value of num and changes it, it will not affect the actual number of gold coins we display.

Analysis Plug-in Anti-Cheat Toolkit

Our Unity developers estimate that many people will use this plug-in. How does it implement data encryption? Let’s read the manual. Know that it encapsulates Unity's basic data types into a corresponding data type, such as int->ObscuredInt, Float->ObscuredFloat, string->ObscuredString, etc. Take ObscuredInt as an example:

Anti-cheating in game development and a brief introduction to its principlesYou will find that it encapsulates a structure corresponding to Int, and has a confusion factor cryptoKey=444444. Let’s look at ObscuredString, a class encapsulated by the string type, and its confusion The factor is string cryptoKey="4441". If we use this plug-in without modifying anything, then if I am a hacker and I know that a certain game is currently developed by Unity and the data has been anti-cheat processing, then how can I crack the anti-cheat protection? The plug-in is definitely the first thing that comes to my mind, and if I know these confusion factors, it will be relatively easy for me to crack it. Therefore, how to further prevent cheating, it is very important to confuse or modify the mixing factors of the plug-in.

The above is the detailed content of Anti-cheating in game development and a brief introduction to its principles. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete
Previous article:How to use svnNext article:How to use svn