Anti-Cheating Plug-in Access Document
1、Tool Target
Enhance the security of C# code in Unity projects.
2、Tool Function
- Obfucate symbols in C# code for Unity projects, Tool can reduce the risk of game resource theft.
- This feature takes advantage of Mono.Cecil to modify assembly, Tool can enhance the security of game resources.
- Tools are involved in modifying areas such as namespaces, class names, methods, properties, etc.
- You can use the Inspector to modify options for actions.
- Obfuscating tools may or may not apply to a particular class.
3、Access steps
3.1、Open the Unity project, double-click unitypackage and import unitypackage
3.2、Find ObfuscateConfig
at the bottom left, check Enable Code Obfuscate
, and directly Build after Obfuscate Names
can complete the obfuscation
3.3、Plugin Configuration
Enable Code Obfuscator
Control the total confusion switch.- You can enter the value of the random seed for confusion in
Random Seed
, or you can checkUse Time Stamp
to use the timestamp as the random seed. - Can control
Obfuscate Name
switch. - Obfuscate Name
- Filter Type: The BlackList and WhiteList mode used for
Obfuscate Name
, see the blackList and whiteList configuration below for the specific mode difference. - Name Source:Two modes of
Random
andWord Library
are available.Random
is a random string name, andWord Library
is a name extracted from the word library.
- Filter Type: The BlackList and WhiteList mode used for
- DLL Path Setting: The path of the DLL that needs to be obfuscated, the DLL generated by Unity by default is in the
Library/ScriptAssemblies
path under the project directory, and the default assembly isAssembly-CSharp.dll
.(If there are multiple DLLs in the project, and there is a situation: A.dll is obfuscated, and B.dll needs to call the code of A.dll, then B.dll must also be added to the obfuscated list to modify the name of the call. If B. The dll itself does not need to be confused, it can be controlled by the black and white list). - Test: Provide direct obfuscation function, you can output obfuscated files without Build, improve debugging efficiency, and output obfuscated files to
Output Path
.
- The thesaurus file path of Name Source's Word Library is
UnityObfuscator/Editor/Res/NameList.txt
, you can replace the thesaurus by yourself, just follow the format of each name on one line, and note that the names in the thesaurus cannot be repeated.
3.4、BlackList And WhiteList Configuration
Mode description
There are 3 modes of blacklist, whitelist, and blacklist mixed.
- The blacklist mode is to confuse only the content in the blacklist.
- The whitelist mode is all confusion except for the whitelist.
- The two mixed mode is to confuse within the scope of the blacklist, but will exclude the content of the whitelist.
Configuration File
The configuration file is located in the Assets\UnityObfuscator\Editor\Res
directory.
ObfuscateList: // BlackList Directory
ObfuscateList-Class.txt // The classes in the list (including class names and class member names) will be confused
ObfuscateList-ClassExceptClassName.txt // The class member names of the classes in the list will be confused, but the class names will not be confused
ObfuscateList-ClassMember.txt // The names of class members in the list will be confused
ObfuscateList-Method.txt // The method names in the list will be confused
ObfuscateList-Namespace.txt //The contents of the namespace in the list include (Namespace name, class name, class member name) will be confused
ObfuscateList-NamespaceExceptNamespaceName.txt //The contents of the namespace in the list (including class name and class member name) will be confused, but the namespace name will not be confused
WhiteList: // WhiteList Directory
WhiteList-Class.txt //The classes in the list (including class names and class members) are not confused
WhiteList-ClassMember.txt //Class members in the list are not confused
WhiteList-ClassNameOnly.txt //The class names of the classes in the list are not confused, but the class members are confused
WhiteList-Method.txt //The method names in the list are not confused
WhiteList-NameSpace.txt //The contents of the namespace in the list (including namespace name, class name, class member name) are not confused
WhiteList-NamespaceNameOnly.txt //The names of the namespaces in the list are not confused
Name list Writing:
NameSpace|Class|Method
Priority: The whitelist has a higher priority than the blacklist in the mixed mode of the two.
For example: in the mixed mode of the two, the blacklist is filled in the A namespace, and the whitelist is filled in the B category under the A namespace, then the A namespace will be confused except for the B category.
Configuration Format
NameSpace Configuration Format:
UnityEngine
UnityEngine.UI
Class Configuration Format:
UnityEngine|GameObject
*|GameObject
Class Member Configuration Format:
UnityEngine|GameObject|name
UnityEngine|GameObject|AddComponent
*|GameObject|active
*|*|active
*|*|Start
UnityEngine|GameObject|*
The overall format is namespace|class name|member name
, separated by the symbol |
, where *
can represent any member, for example, *|*|Start
represents the Start member of any class in any clear space, UnityEngine|GameObject|*
means any member in the GameObject class under the UnityEngine namespace. When a certain class does not have a namespace, it can also be represented by *
.
Configuration Rules
If you use this package, then more method names in your code may be confused. But please make sure that the following methods are marked with [WhiteList-Method.txt], otherwise they will not work properly.
- Unity’s life cycle methods and Callback methods (most Unity life cycle methods and callback methods have been excluded from the package).
- The class names of components directly hung on the Prefab or on the GameObject fo the scene should not be confused (you can add components dynamically).
- Methods that are directly mounted on the Inspector panel, such as the OnClick event of the Button component of UGUI, should not be confused.
- Method names such as Unity's Invoke, StartCoroutine, etc. that call methods through strings should not be confused
- Lua's direct access to C# can not be confused (members who have registered the mapping relationship through Wrap can).
- Part of the code involved in reflection cannot be confused.
- In the Native level of the mobile apps, calling C# directly or sending events to C# through Unity's built-in API should not be confused.
4、Effect Display
Use ILSpy
open source software to open /Library/ScriptAssemblies/Assembly-CSharp.dll
to compare and analyze the confusion effect.
5、The Matters Needing Attention
1.Supported Unity Versions
- 2018LTS
- 2019LTS
- 2020LTS
2. Platform Supported
- Android
- iOS
3. The problem that the Inspector page does not display
Package generates ObfuscatorConfig configuration problems by default, If the Inspector panel of ObfuscatorConfig fails to load due to version compatibility issues, you need to delete it and create->Obfuscator Config in the Editor folder again.
4.Function Whitelist
//Function Whitelist
#region MonoBehaviour Message
"Awake",
"FixedUpdate",
"LateUpdate",
"OnAnimatorIK",
"OnAnimatorMove",
"OnApplicationFocus",
"OnApplicationPause",
"OnApplicationQuit",
"OnAudioFilterRead",
"OnBecameInvisible",
"OnBecameVisible",
"OnCollisionEnter",
"OnCollisionEnter2D",
"OnCollisionExit",
"OnCollisionExit2D",
"OnCollisionStay",
"OnCollisionStay2D",
"OnConnectedToServer",
"OnControllerColliderHit",
"OnDestroy",
"OnDisable",
"OnDisconnectedFromServer",
"OnDrawGizmos",
"OnDrawGizmosSelected",
"OnEnable",
"OnFailedToConnect",
"OnFailedToConnectToMasterServer",
"OnGUI",
"OnJointBreak",
"OnJointBreak2D",
"OnMasterServerEvent",
"OnMouseDown",
"OnMouseDrag",
"OnMouseEnter",
"OnMouseExit",
"OnMouseOver",
"OnMouseUp",
"OnMouseUpAsButton",
"OnNetworkInstantiate",
"OnParticleCollision",
"OnParticleTrigger",
"OnPlayerConnected",
"OnPlayerDisconnected",
"OnPostRender",
"OnPreCull",
"OnPreRender",
"OnRenderImage",
"OnRenderObject",
"OnSerializeNetworkView",
"OnServerInitialized",
"OnTransformChildrenChanged",
"OnTransformParentChanged",
"OnTriggerEnter",
"OnTriggerEnter2D",
"OnTriggerExit",
"OnTriggerExit2D",
"OnTriggerStay",
"OnTriggerStay2D",
"OnValidate",
"OnWillRenderObject",
"Reset",
"Start",
"Update",
#endregion
};