【问题标题】:Declarative Obfuscation in Xamarin Forms with ConfuserEx使用 ConfuserEx 在 Xamarin 表单中进行声明性混淆
【发布时间】:2018-01-13 13:32:28
【问题描述】:

我正在使用 Xamarin.Forms 创建一个 Android 应用程序,并使用 ConfuserEx 进行混淆。我想使用像 example 这样的声明性混淆,所以我可以更改每个类的混淆属性。

但是,Xamarin.Forms 中的 System.Reflection 命名空间无法识别 System.Reflection.ObfuscationAttribute 类。我需要使用另一个 NuGet 包还是遗漏了什么?

否则,有没有办法以不同的方式在不同的类中包含或排除混淆特征?

【问题讨论】:

    标签: xamarin xamarin.android xamarin.forms obfuscation confuserex


    【解决方案1】:

    ConfuserEx 只查看属性的名称

    if (ca.TypeFullName != "System.Reflection.ObfuscationAttribute")
    

    所以我会在 PCL (Xamarin.Forms) 项目本身中创建一个 System.Reflection.ObfuscationAttribute 类。

    using System.Runtime.InteropServices;
    
    namespace System.Reflection
    {
        [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate, AllowMultiple = true, Inherited = false), ComVisible(true)]
        public sealed class ObfuscationAttribute : Attribute
        {
            //
            // Fields
            //
            private bool m_strip = true;
    
            private bool m_exclude = true;
    
            private bool m_applyToMembers = true;
    
            private string m_feature = "all";
    
            //
            // Properties
            //
            public bool ApplyToMembers
            {
                get
                {
                    return this.m_applyToMembers;
                }
                set
                {
                    this.m_applyToMembers = value;
                }
            }
    
            public bool Exclude
            {
                get
                {
                    return this.m_exclude;
                }
                set
                {
                    this.m_exclude = value;
                }
            }
    
            public string Feature
            {
                get
                {
                    return this.m_feature;
                }
                set
                {
                    this.m_feature = value;
                }
            }
    
            public bool StripAfterObfuscation
            {
                get
                {
                    return this.m_strip;
                }
                set
                {
                    this.m_strip = value;
                }
            }
        }
    }
    

    回复:https://github.com/yck1509/ConfuserEx/blob/3c9c29d9daf2f1259edf69054c5693d5d225a980/Confuser.Core/ObfAttrMarker.cs#L138

    【讨论】:

    • 我尝试使用此方法将重命名功能添加到类中,但它没有改变任何内容。我是否需要在我的 .crproj 文件中添加任何内容才能让 ConfuserEx 识别出我也在使用声明性混淆?
    猜你喜欢
    • 2019-01-08
    • 1970-01-01
    • 1970-01-01
    • 2022-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-10
    • 1970-01-01
    相关资源
    最近更新 更多