This unity plugin provides an extra layer of security to your game from being pirated / cracked / running in clone space or in emulator and more..
This library protects your game against simple tampering attacks. But, this isn't guaranteed to stop your app from getting pirated. There is no such thing as 100% security, and a determined and skilled attacker with enough time, could remove these checks from the code. The real objective here is to raise the bar out of reach of opportunist and automatic attackers.
- Open Package Manager in Unity
- Press "+" and "Add package from git URL..."
- Enter this repository and version as
https://github.com/onedevapp/Unity_GameGuard_Android.git#TAG
(see latest version here)
Create a new GameGuardBuilder object.
GameGuardBuilder guardBuiler = new GameGuardBuilder()
The app signatures will be broken if the .apk is altered in any way and doesn't match with originaly signed signature.
Warning
Don't use this method when using Google Play App Signing since Google removes the original signature and add another one, so this method will fail.
// appSignature : The original APK signature for the PRODUCTION version, empty value will not validate signature
// showSignature : If ture then certificate signature will be print to the logcat.
guardBuiler.BlockAppSingatureIsNotMatched(string appSignature, bool showSignature = false)
Note
To get the App signature, pass empty string with showSignature as true, once you had your signature, set appSignature with your signature and showSignature as false to validate
Set the package name to validate whether the current app was running with the exact same package name specified, because some tools can change the package name while rebuilding the APK from the original
guardBuiler.BlockPackageNameIsNotMatched(string packageName) // Dont use Application.identifier, just Hardcode/pass the value from server
Check whether the source of installation is APK or not, by doing so, we are allowing only installing APP via any Store such as PlayStore, Amazon Store etc.
// block : true to block and default is false
guardBuiler.BlockIfInstalledViaAPK(bool block)
Some tools can run the build in Clone or Dual Space to hack the game
// block : true to block and default is false
guardBuiler.BlockDualOrCloneSpaceApps(bool block)
Emulators are most widley used to hack the games.
Note:
- Disabling Emulator might leads to users loss, since few percentage of users actually enjoys playing in the emulators than the actual device.
- Uses Android-Emulator-Detection library by reveny to detect emulator
// block : true to block and default is false
guardBuiler.BlockRunningInEmulator(bool block)
Checks if the device is rooted.
// block : true to block and default is false
guardBuiler.BlockIfRootedDevice(bool block)
Checks if the device using proxy.
// block : true to block and default is false
guardBuiler.BlockIfUsingProxy(bool block)
Checks the device whether Developer Options is enabled or not. Note that by enabling this, it also checks for whether Debugger is attched
// block : true to block and default is false
guardBuiler.BlockIfDevOptionsEnabled(bool block)
Toggle logs
// By default puglin console log will be diabled, but can be enabled
guardBuiler.ToggleLogs(bool showLogs);
// Verify the game guard with the config values
bool isValid = guardBuiler.Validate(); // or
bool isValid = await guardBuiler.ValidateAsync();
// Complete Sample
bool isValid = new GameGuardBuilder()
.BlockPackageNameIsNotMatched("com.DefaultCompany.MyAwesomeGame") // Dont use Application.identifier, just Hardcode the package name
.BlockDualOrCloneSpaceApps(true)
.BlockRunningInEmulator(true)
.BlockIfInstalledViaAPK(true)
.BlockIfRootedDevice(true)
.BlockIfUsingProxy(true)
.BlockIfDevOptionsEnabled(true)
.ToggleLogs(true)
.Validate(); // ValidateAsync or Validate
// or get more details with game guard status
public enum GameGuardedStatus
{
Valid = 0,
AppSingature,
PackageNameChanged,
UnknownPackageInstaller,
InstalledViaAPK,
InDualSpace,
InClonedSpace,
ZygoteCountTwice,
IsEmulator,
IsRooted,
UsingProxy,
Debugger,
DevOptions
}
GameGuardedStatus guardStatus = guardBuiler.GetStatus(); //or
GameGuardedStatus guardStatus = await guardBuiler.GetStatusAsync();
// Complete Sample
GameGuardedStatus guardStatus = await new GameGuardBuilder()
.BlockPackageNameIfNotMatched("com.DefaultCompany.MyAwesomeGame") // Dont use Application.identifier, just Hardcode the package name
.BlockDualOrCloneSpaceApps(true)
.BlockRunningInEmulator(true)
.BlockIfInstalledViaAPK(true)
.BlockIfRootedDevice(true)
.BlockIfUsingProxy(true)
.BlockIfDevOptionsEnabled(true)
.ToggleLogs(true)
.GetStatusAsync(); // GetStatusAsync or GetStatus
- ByteProtector - ByteProtector is a lightweight anti-cheat for Android™ games. It helps game developers detect cheating methods like code injections, debuggers, emulators, root, and Xposed.
- Anti-Cheat Toolkit - Protects variables & saves, detects plenty of cheats and many more.
- Obfuscator - This asset obfuscates your code making it harder for bad guys to reverse engineer your projects.
- Mfuscator: IL2CPP Encryption - Protect Unity IL2CPP builds using etadata encryption and initialization pattern obfuscation and impede the reverse-engineering efforts of hackers targeting your game.
Any contributions are welcome!
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create New Pull Request