Class MyClass { private int _propertyA; private int _propertyB; public int PropertyA { get{return _propertyA;} set{_propertyA = value;} } [Obfuscation(Feature = "renaming",Exclude = true)] public int DestinationReference { get{return _propertyB;} } }
混淆的类将写成这样的东西
Class a { int s() void z(int a) public int DestinationReference { get{return _propertyB;} } }
这是我从使用.Net Reflector看到的假设
我的问题如下:
– 在我们的代码中,我们实现了一个方法,该方法使用反射查找类的所有属性,以便查找特定参数
– 此方法在混淆代码中不起作用,因为我的访问者PropertyA已被替换为get访问器和set访问器的两种不同方法.
– 我知道如果我将一个访问者排除在重命名之外它会在msil代码中保留一个访问者,并且可以通过我的方法查找访问者
我的问题是:
– 不是重命名唯一的选择吗?
– Dotfuscator中是否有一个参数允许重命名访问者,而不将其分成两个不同的方法并丢失访问者?
我对混淆很新,所以原谅我的不完美之处,这就是我所能看到的类似于上面反射器中所描述的类的东西.
如您所见,从重命名中排除的属性将保留具有get访问器的属性.但对于另一个被混淆的人,我可以看到两个不同的方法s和z
我试图看看是否有办法获得单个访问器,例如使用底层的getter和setter重命名为“s”
解决方法
我看到MSIL生成了get_XXX()方法和set_XXX(int)方法以及添加属性. Dotfuscator负责重命名get和set方法(这是我们想要的),但也用于删除属性本身(我不想要)
解决方案是为混淆的DLL启用“库模式”,如果启用了库模式,则文档说明:
- Names of public classes and nested public classes are not renamed. Members (fields and methods) of these classes are also not renamed if they have public,family,or famorassem access.
- In addition,no virtual methods are renamed,regardless of access specifier. This allows clients of your library to override private virtual methods if need be (this is allowed behavior in the .NET architecture).
- Any user-specified custom renaming exclusions are applied in addition to the exclusions implied by the above rules.
- Property and Event Metadata are always preserved.
这可以在反射器中进行模糊处理后看到,顶部库模式被禁用,底部库模式被启用
可以看出,没有公共类/方法/字段被重命名,更重要的是我保留了属性元数据.
现在我的下一个问题是,如何保留属性元数据但允许重命名属性本身.我想找到一个令人满意的解决方案,而无需使用自定义混淆属性定义手动装饰每个属性.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。