我想使用AOT编译来保护我的代码,但请注意:https://docs.microsoft.com/uk-ua/xamarin/android/deploy-test/release-prep/?tabs=windows#aot生成的本机代码与未编译的程序集一起包含在APK中。这是否意味着编译版本和未编译版本都包括在内,而AOT并不能真正帮助混淆?
答案 0 :(得分:0)
完整的AOT可能会使您的APK更大,因此不确定是否应该仅出于混淆目的而走这条路。
您可以尝试专门为此设计的Dotfuscator
Visual Studio for Windows
即使禁用了调试,攻击者仍然有可能重新打包应用程序,添加或删除配置选项或权限。这使他们可以对应用程序进行逆向工程,调试或篡改。 Dotfuscator社区版(CE)可用于混淆托管代码,并在构建时将运行时安全状态检测代码注入Xamarin.Android应用中,以检测并响应该应用是否在有根设备上运行。
Dotfuscator CE随Visual Studio 2017一起提供。要使用Dotfuscator,请单击“工具”>“ PreEmptive Protection-Dotfuscator”。
要配置Dotfuscator CE,请参阅将Dotfuscator社区版与Xamarin一起使用。配置完成后,Dotfuscator CE将自动保护创建的每个内部版本。
Visual Studio for Mac
即使禁用了调试,攻击者仍然有可能重新打包应用程序,添加或删除配置选项或权限。这使他们可以对应用程序进行逆向工程,调试或篡改。尽管它不支持Mac的Visual Studio,但您可以将Dotfuscator Community Edition(CE)与Visual Studio结合使用,以混淆托管代码并将运行时安全状态检测代码注入Xamarin.Android应用程序中,以在构建时检测并响应该应用程序是否在有根设备上运行。
要配置Dotfuscator CE,请参阅将Dotfuscator社区版与Xamarin一起使用。配置完成后,Dotfuscator CE将自动保护创建的每个内部版本。
答案 1 :(得分:0)
我使用Hybrid AOT从.NET程序集中删除IL代码。 您需要在C:\ Program Files(x86)\ Microsoft Visual Studio \ 2019 \ Enterprise \ MSBuild \ Xamarin \ Android \
中手动编辑Xamarim.Android.Common.Targets <CilStrip
Condition=" '$(AndroidAotMode)' == 'Hybrid' And '$(AotAssemblies)' == 'True' "
AndroidAotMode="$(AndroidAotMode)"
ToolPath="$(_MonoAndroidToolsDirectory)"
ApkOutputPath="$(_BuildApkEmbedOutputs)"
ResolvedAssemblies="@(_ShrunkAssemblies)">
</CilStrip>
并编辑您的Android.csproj
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<EnableLLVM>false</EnableLLVM>
<AotAssemblies>true</AotAssemblies>
<AndroidAotMode>Hybrid</AndroidAotMode>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<AndroidAotAdditionalArguments>no-write-symbols,nodebug</AndroidAotAdditionalArguments>
</PropertyGroup>