打從前陣子就一直在思考怎麼作 source encrypt,看了很多 unity forum 卻總是沒看到實際作法跟可用的方式,standalone 跟 webplayer 似乎都有確切解法了,但 android / ios 一直沒有,總算看到有人使用 Crypto Obfuscator 的案例,在這邊講解一下作法跟設
定。
上圖是我參考網路資訊作的,有幾點需要注意:
(1) Test Mode 可以用來作測試用,但實際 Release 版本千萬別用這個。
(2) 採用 Unprintable Mode,我試過 Cryptographic、Normal 也都可行。
(3) Encrypt String 不勾選,主要是打亂後會造成很多 Unity call method 問題。
(4) rename symbol 勾選 For Fields、For Methods。
(5) 其他就參考上圖吧,也可以自行測試看看,依自己喜好設定。
在實際測試中發現打亂後執行 apk 預到非預期問題,大多都是 function name 被打亂了,但 regist function name 沒打亂的緣故,所以我們需要設立一些 pass 規則。
如上圖,在 Obfuscation Rules 中設立了滿多規則,像是 Monobehaviour::Update、LateUpdate、Awake....等都加入規則內;在這邊列出了打亂後會遇到問題的 case 供大家參考:
1. ScriptableObject 2. Coroutine function name 3. Invoke function name
4. SendMessage function name
5. AddComponent 採用 AddComponent<Type>() 而不是 AddComponent("Type")
有關 Crypto Obfuscator Q & A 中提:
Crypto Obfuscator does not automatically suppress the warning even after you add proper obfuscation rules/attributes for it. You have to 'suppress' that warning explicitly by right-clicking on the warning and selecting the proper menu item from the context menu. You may ask why this is so or why it does not exclude the type/member from renaming in the first place? Because it is impossible to determine, just by doing static analysis of your code, the exact type/member to exclude. It can only detect the use of a potentially dangerous method call or a property get/set. For example, while it can detect the use of the System.Type.Name property, it has no way of knowing on which System.Type instance the Name property is being retrieved - this can only be determined at run-time and the System.Type instance may very well change from run to run.
主要是說明,Crypto obfuscator 可以幫你偵測到一些立即的危險,像是 Reflection.Get/Set,但程式執行中動態產生或修改的則很難發現。目前會卡在一個問題,也就是目前的版本真的沒問題嗎?其實沒辦法保證,因為必須遊戲執行中剛好跑到錯誤的程式才會造成問題,這是無法保證的,目前有待思考解決方案。
定。
上圖是我參考網路資訊作的,有幾點需要注意:
(1) Test Mode 可以用來作測試用,但實際 Release 版本千萬別用這個。
(2) 採用 Unprintable Mode,我試過 Cryptographic、Normal 也都可行。
(3) Encrypt String 不勾選,主要是打亂後會造成很多 Unity call method 問題。
(4) rename symbol 勾選 For Fields、For Methods。
(5) 其他就參考上圖吧,也可以自行測試看看,依自己喜好設定。
在實際測試中發現打亂後執行 apk 預到非預期問題,大多都是 function name 被打亂了,但 regist function name 沒打亂的緣故,所以我們需要設立一些 pass 規則。
如上圖,在 Obfuscation Rules 中設立了滿多規則,像是 Monobehaviour::Update、LateUpdate、Awake....等都加入規則內;在這邊列出了打亂後會遇到問題的 case 供大家參考:
1. ScriptableObject 2. Coroutine function name 3. Invoke function name
4. SendMessage function name
5. AddComponent 採用 AddComponent<Type>() 而不是 AddComponent("Type")
有關 Crypto Obfuscator Q & A 中提:
Crypto Obfuscator does not automatically suppress the warning even after you add proper obfuscation rules/attributes for it. You have to 'suppress' that warning explicitly by right-clicking on the warning and selecting the proper menu item from the context menu. You may ask why this is so or why it does not exclude the type/member from renaming in the first place? Because it is impossible to determine, just by doing static analysis of your code, the exact type/member to exclude. It can only detect the use of a potentially dangerous method call or a property get/set. For example, while it can detect the use of the System.Type.Name property, it has no way of knowing on which System.Type instance the Name property is being retrieved - this can only be determined at run-time and the System.Type instance may very well change from run to run.
主要是說明,Crypto obfuscator 可以幫你偵測到一些立即的危險,像是 Reflection.Get/Set,但程式執行中動態產生或修改的則很難發現。目前會卡在一個問題,也就是目前的版本真的沒問題嗎?其實沒辦法保證,因為必須遊戲執行中剛好跑到錯誤的程式才會造成問題,這是無法保證的,目前有待思考解決方案。


留言
張貼留言