Xamarin 项目中的混淆 [英] Obfuscation in Xamarin Projects

查看:55
本文介绍了Xamarin 项目中的混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如您所知,Xamarin 项目被编译为 dot net dll 程序集,并将其打包到 apk 文件中,并且可以通过 DotPeek 等反射器轻松反映.

我的第一个问题是:我们如何保护我们的代码?

我的第二个问题是:像 SmartAssembly 这样的混淆器工具是否可用于 Xamarin 项目或 Xamarin 项目不支持它们?

解决方案

保护 APK 的 .NET 代码 (.DLLS) 的最佳方法是启用

AOT 编译会将您的应用程序 IL 代码 (.dll) 编译为本机指令.打包到 APK 中的最终代码是 X86、arm 等指令,而不是托管 IL 代码.

AOT 编译仅适用于 Enterprise 和更高许可证.

虽然 AOT 增加了逆向工程的难度,但仍然不是 100% 万无一失.最终的二进制文件仍然可以从有根设备中提取,并使用 IDA pro 等软件进行逆向工程.这比使用 DotPeek 要困难得多,但它仍然是可能的.

同样重要的是要注意启用 AOT 编译的缺点.应用程序构建时间显着增加,因为您的应用程序引用的每个程序集都需要编译;我的经验表明,当启用 AOT 时,您应该期望构建时间增加 200%-300%.

另外,AOT 编译会增加最终的 APK 大小.

As you know Xamarin projects are compiled into dot net dll assembly and it'll be pack into apk file and can be easily reflected by reflectors like DotPeek.

My first question is: How can we protect our code?

My second question is: Do obfuscator tools like SmartAssembly are usable in Xamarin projects or Xamarin projects won't support them?

解决方案

The best way to protect your .NET code (.DLLS) for APKs is to enable Ahead Of Time (AOT) compilation:

AOT compilation will compile your applications IL code (.dlls) into native instructions. The final code that is packaged into the APK is then X86, arm etc instructions rather than managed IL code.

AOT compilation is only available in Enterprise and higher licenses.

While AOT increases the difficulty of reverse engineering, it's still not 100% fool-proof. The final binaries can still be pulled from a rooted device and reverse engineered using software like IDA pro. It's a lot harder than using DotPeek but its still possible.

It is also important to note the down sides of enabling AOT compilation. Application builds times increase significantly as every assembly referenced by your app needs to be compiled; my experiences indicated that you should expect a 200%-300% increase in build times when AOT is enabled.

Additionally, AOT compilation will increase the final APK size.

这篇关于Xamarin 项目中的混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆