Secure your Game with Unity Game Shield - An open-source anti-cheat and encryption toolkit
Tags: unity3d, opensource, programming, security
Published: 2024-04-11 13:38:41

**Hey, everybody.** Today I'd like to talk about a new set of tools I've been developing lately. **Unity Game Sheild** is an open-source comprehensive suite of tools for your apps and games, including many **anti-cheat and securty tools**. This framework is easy to use on any projects and platforms.

❓**Why GameShield?**  
- Easy to install (only 4 steps basic installation);  
- Easy to configure each module;  
- Reporting system;  
- Lightweight;  
- Event-based and modular;

![Unity Game Shield Toolkit - Anti-Cheat and Security](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lr85xzcc0o0jbi23p6sq.png)

⭐ **Features:**
- Memory Protection and Secured Types;  
- Secured Game Saves;  
- Teleport Protector;  
- SpeedHack Detector;  
- WallHack Detector;  
- Time Skip Detector with Network Compare;  
- Injection Scanner;  
- Rewarded Captcha;  
- Secured Web Requests;  
- Large Crypto Library;  
- Cheating Reporting;  
- Ready-to-Use UI;

## Get Started
**GameShield** installs into your project as easily as possible - basic installation and configuration takes **only 4 steps**. Below we will consider both **automatic initialization** and **manual configuration**.

![Get Started with Unity GameShield - Anti-Cheat toolkit for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/unms4aqiknsgth75k2hb.png)

**Basic Installation:**
- Download [Latest Release from GitHUB](https://github.com/DevsDaddy/GameShield/releases);
- Import **.unitypackage** into your project;
- Run **Setup Wizzard** at Unity Top Menu (**GameShield** -&gt; **Setup Wizzard**);
- Check all settings and press **"Complete"**;
- **Done!**

**Manual Installation:**
- Download [Latest Release from GitHUB](https://github.com/DevsDaddy/GameShield/releases);
- Import **.unitypackage** into your project;
- Place Prefab with **GameShield** main script at scene;
- Write initialization code at your game installer script ([see how to here](https://github.com/DevsDaddy/GameShield/wiki/GameShield-Core#manual-registering-gameshield));
- **Done!**

**Dependencies:**
- **Unity 2019+**
- [Unity Event Framework](https://github.com/DevsDaddy/UnityEventFramework) (Included);
- [Unity Crypto Library](https://github.com/DevsDaddy/UnityCrypto) (Included);

## About Modules
### Memory Protector

![Memory Protector for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wb9nq80k213v11vxdwh2.png)

**The Memory Protection** module allows you to protect your application from external access to RAM. In this way you can organize a simple and fast protection against software like **CheatEngine**.

![Memory Protector for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k8euauh40czdxoj0dl6v.png)

This module includes **SecuredTypes**, which serve as a protected island for basic types in your game or application.

---

### Secured Types
![Secured Types for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5cun1d25s6kw5iexgpf.png)
**Secured Types** allow you to hide the real value of variables from users in memory by embedding symmetric encryption in basic types. In turn, Memory Detector reports on attempts to swap values, because each assignment checks the real and fake value of the variable.

**Usage Example:**
```csharp
SecuredInt myInt = 32; // Yeah, it's that simple. Now you can use it in your game objects / serialization
```

**Note! Turn-On Memory Protector to get events of cheating detection for any secured type!**

---

### Secured (Encrypted) Game Saves
![Encrypted Game Saves for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/287m7dmch9o1jmkff600.png)
The **Secured Saves** module allows you to store your data on the user's device in encrypted form. It is also recommended to use it together with Memory Protector - which simplifies working with objects in memory.

![Encrypted Game Saves for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yzy6vd7huxks1k30ozjw.png)

Module serialize your objects using **JSON and Encryption Providers** such as AES, DES, and other popular encryption methods available to you. The module uses the **Unity Crypto Library**, which is already included in **GameShield**. Standard .Net methods are used for serialization/deserialization to files.

---

### Injection Scanner (Assembly Protector)
![Injection Scanner for Unity (Assembly Protection)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdm1wqfk9aoygwo949vk.png)
The injection scanning module allows you to protect your application from external access when malware attempts to tamper with or inject its own libraries.

![Injection Scanner for Unity (Assembly Protection)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ojoy8ay9phowayf6vo3.png)

During the application development process, you specify a list of valid libraries that will be used after the product is built. Thus, during the application build process, GameShield captures the internal hashes of the libraries and their build versions to scan for spoofing at runtime or at startup.

---

### SpeedHack Detector
![Speed Hack Protection in Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9yhl4a8vm5y2kf5s8hy.png)
This module allows you to track the tick rate in the game and compare it to the actual CPU tick time that has passed on the device to detect game speed spoofing - aka **SpeedHack Cheat**. When detected, it sends an event.

![Speed Hack Protection in Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e25808iezk3qsqu35wyd.png)

At each interval, the module checks how many game ticks and real device ticks have passed, requesting a specific number of ticks per interval from the processor. This allows you to synchronize Update in Unity and lets you know where the speed has changed.

---

### Wallhack Detector
![Wallhack Detector for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ii9z25ymgzigbsslvtq.png)
This module **allows you to use physics simulation to check the presence of Wallhack in the game**. It simulates the behavior of both Rigidbody and Character Controller for both types of player controllers

When passing the next physics tick - check modules are created on the basis of **Rigidbody** and **Character Controller**, if these components were detected a change in Velocity on the Z-axis more than the maximum allowable value, then most likely WallHack was used.

---

### Teleport Detector
![Teleport Detector for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwyi7g0rixxtn3ijmgh7.png)
**Teleport Detector** is a small module that allows you to compare the speed and position of targets to the maximum allowed values to check for possible player teleportation. Works well in conjunction with **SpeedHack Detector**.

![Teleport Detector for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s18o6r9ye94ebonn8wm.png)

**The detector checks the distance of positions between ticks of a game cycle** to make sure that it is not greater than the maximum allowed distance for that tick. The check is based on the formula of the distance between two vectors and the maximum speed variable. It also supports tracking multiple targets in the game.

---

### Time Skip Detector
![Time Skip Detector for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p13cxqt0ia8xk8ypkh1x.png)

This module checks the system time by comparing it with the network time to see if the time in the game has been rewound. It also checks local time rewind from the previous value. The server of choice is used for operation. You can also run your own time check server.

---

### Secured Web Request
![Secured (Encrypted) Web Requests for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zc7alfmxvfnq56v4hpso.png)
**This module is a wrapper over Unity Web Request** - it handles encrypted data both sending and receiving. It uses one of the crypto providers of your choice, which will perform encryption/decryption. It uses Unity Crypto Library already embedded in GameShield for its operation.

![Secured (Encrypted) Web Requests for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmo5en17hkweu0lk38fi.png)

---

### Rewarded Captcha
![Rewarded Captcha for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7gbot49mz9ena1p8936.png)

This module provides functionality to implement a simple client-side captcha. The method of operation is quite simple - the user needs to click on the icons in the sequence indicated at the top of the screen. 

**After successful completion, you can give him a reward:**
![Rewarded Captcha for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ld4persfwr6bjsnh81e.png)

---

### Cheating Reporting
![Cheating Reporting for Unity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bbgsq7l3bp8o5601yii6.png)

This module allows you to **send cheating / custom reports** to your server where you can track and manage them. You can easily use it for normal user feedback as well.

> Note that for this module to work, you need to implement your own message reception on your server side.

---

## In conclusion
To summarize - **Unity Game Shield** is a large library that includes many modules already, with a number more in development.

I'm preparing a **server-side solution for GameShield soon**, including reporting, secure authorization, and more. You can follow the progress here.

I also suggest you visit the [Wiki for full documentation](https://github.com/DevsDaddy/GameShield/wiki).

**Thanks for reading! If you still have any questions, feel free to contact me:**

[My Discord](https://discord.gg/a7cHDtfYbv) | [My Blog](https://devsdaddy.hashnode.dev/) | [My GitHub](https://github.com/DevsDaddy) | [Buy me a Beer](https://boosty.to/devsdaddy)