From 7619928b07152126e0881ee46e0efac3e5819fd8 Mon Sep 17 00:00:00 2001 From: walon Date: Sun, 18 May 2025 10:36:45 +0800 Subject: [PATCH] refactor: refactor Obfuz project, simplify codes. --- Obfuz/Assets/{Scripts => }/Bootstrap.cs | 12 +++++------ Obfuz/Assets/{Scripts => }/Bootstrap.cs.meta | 0 .../Obfuz/SymbolObfus/symbol-mapping.xml | 17 ++++++--------- Obfuz/Assets/Scripts.meta | 8 ------- Obfuz/Assets/Scripts/Algorithm.cs | 18 ---------------- Obfuz/Assets/Scripts/Algorithm.cs.meta | 11 ---------- Obfuz/ProjectSettings/ProjectSettings.asset | 1 + Obfuz/README.md | 21 ++++++++++++------- 8 files changed, 26 insertions(+), 62 deletions(-) rename Obfuz/Assets/{Scripts => }/Bootstrap.cs (77%) rename Obfuz/Assets/{Scripts => }/Bootstrap.cs.meta (100%) delete mode 100644 Obfuz/Assets/Scripts.meta delete mode 100644 Obfuz/Assets/Scripts/Algorithm.cs delete mode 100644 Obfuz/Assets/Scripts/Algorithm.cs.meta diff --git a/Obfuz/Assets/Scripts/Bootstrap.cs b/Obfuz/Assets/Bootstrap.cs similarity index 77% rename from Obfuz/Assets/Scripts/Bootstrap.cs rename to Obfuz/Assets/Bootstrap.cs index 4bafe65..6adb0b8 100644 --- a/Obfuz/Assets/Scripts/Bootstrap.cs +++ b/Obfuz/Assets/Bootstrap.cs @@ -16,14 +16,14 @@ public class Bootstrap : MonoBehaviour Debug.Log("SetUpStaticSecret end"); } - // Start is called before the first frame update + public int Add(int a, int b) + { + return a + b; + } + void Start() { - var c = new Algorithm(); - int a = c.Add(100, 200); + int a = Add(100, 200); Debug.Log($"a = {a}"); - - int b = c.ComputeHashCode(a); - Debug.Log($"b = {b}"); } } diff --git a/Obfuz/Assets/Scripts/Bootstrap.cs.meta b/Obfuz/Assets/Bootstrap.cs.meta similarity index 100% rename from Obfuz/Assets/Scripts/Bootstrap.cs.meta rename to Obfuz/Assets/Bootstrap.cs.meta diff --git a/Obfuz/Assets/Obfuz/SymbolObfus/symbol-mapping.xml b/Obfuz/Assets/Obfuz/SymbolObfus/symbol-mapping.xml index 8ae7522..32d891a 100644 --- a/Obfuz/Assets/Obfuz/SymbolObfus/symbol-mapping.xml +++ b/Obfuz/Assets/Obfuz/SymbolObfus/symbol-mapping.xml @@ -1,13 +1,10 @@ - - + + - - - @@ -38,11 +35,11 @@ - - + + - - + + @@ -50,13 +47,11 @@ - - diff --git a/Obfuz/Assets/Scripts.meta b/Obfuz/Assets/Scripts.meta deleted file mode 100644 index 6081163..0000000 --- a/Obfuz/Assets/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c71b39fcf194d5049b95088ff01dd2cc -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/Assets/Scripts/Algorithm.cs b/Obfuz/Assets/Scripts/Algorithm.cs deleted file mode 100644 index bb55b21..0000000 --- a/Obfuz/Assets/Scripts/Algorithm.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Algorithm -{ - public int Add(int a, int b) - { - return a + b; - } - - public int ComputeHashCode(int a) - { - int hash = 17; - hash = hash * 23 + a.GetHashCode(); - return hash; - } -} diff --git a/Obfuz/Assets/Scripts/Algorithm.cs.meta b/Obfuz/Assets/Scripts/Algorithm.cs.meta deleted file mode 100644 index d4de597..0000000 --- a/Obfuz/Assets/Scripts/Algorithm.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 092862882a7a7ba43ac257ac990b1fb8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Obfuz/ProjectSettings/ProjectSettings.asset b/Obfuz/ProjectSettings/ProjectSettings.asset index 32f7fb5..9398732 100644 --- a/Obfuz/ProjectSettings/ProjectSettings.asset +++ b/Obfuz/ProjectSettings/ProjectSettings.asset @@ -877,6 +877,7 @@ PlayerSettings: Standalone: 1 il2cppCompilerConfiguration: Android: 0 + Standalone: 0 il2cppCodeGeneration: {} managedStrippingLevel: EmbeddedLinux: 1 diff --git a/Obfuz/README.md b/Obfuz/README.md index 3ab7998..952c515 100644 --- a/Obfuz/README.md +++ b/Obfuz/README.md @@ -24,27 +24,32 @@ using $a; using $A; using UnityEngine; -// Token: 0x02000003 RID: 3 +// Token: 0x02000002 RID: 2 public class Bootstrap : MonoBehaviour { - // Token: 0x06000004 RID: 4 RVA: 0x0000313D File Offset: 0x0000133D + // Token: 0x06000001 RID: 1 RVA: 0x000030F0 File Offset: 0x000012F0 [RuntimeInitializeOnLoadMethod(2)] private static void SetUpStaticSecret() { Debug.Log("SetUpStaticSecret begin"); - global::$A.$C<$c>.$L = new global::$a.$A(Resources.Load("Obfuz/defaultStaticSecret").bytes); + global::$A.$C<$c>.$L = new $a.$A(Resources.Load("Obfuz/defaultStaticSecretKey").bytes); Debug.Log("SetUpStaticSecret end"); } - // Token: 0x06000005 RID: 5 RVA: 0x000032E0 File Offset: 0x000014E0 + // Token: 0x06000002 RID: 2 RVA: 0x0000311F File Offset: 0x0000131F + public int $a(int 1, int 1) + { + return 1 + 1; + } + + // Token: 0x06000003 RID: 3 RVA: 0x00003204 File Offset: 0x00001404 private void Start() { - global::$a $a = new global::$a(); - int num = global::$e.$A($a, global::$e.$a(global::$d.$A, 8, 117, -2060908889, global::$A.$C<$c>.$d(-1139589574, 85, -452785586)), global::$e.$a(global::$d.$A, 12, 138, -1222258517, global::$A.$C<$c>.$d(-1139589574, 85, -452785586)), global::$A.$C<$c>.$d(-595938299, 185, 132898840)); + int num = global::$e.$A(this, global::$e.$a(global::$d.$A, 0, 117, -2060908889, global::$A.$C<$c>.$d(-1139589574, 85, -452785586)), global::$e.$a(global::$d.$A, 4, 138, -1222258517, global::$A.$C<$c>.$d(-1139589574, 85, -452785586)), global::$A.$C<$c>.$d(1757957431, 242, 760404455)); global::$e.$b(string.Format(global::$D.$a, num), global::$A.$C<$c>.$d(1718597184, 154, 2114032877)); - int num2 = global::$e.$B($a, num, global::$A.$C<$c>.$d(368894728, 171, -1414000938)); - global::$e.$b(string.Format(global::$D.$A, num2), global::$A.$C<$c>.$d(1718597184, 154, 2114032877)); } } + + ```