Closed hitgubmitt closed 2 years ago
I replicated the problem and wish to learn how to fix it as well. It seems that the biggest issue here is not only that ConfuserEx can't handle serialization yet, but that it won't obey the flags that are supposed to tell it what not to obfuscate, but it goes ahead and still does it.
I tried at assembly level
[assembly:ObfuscateAssemblyAttribute(true)]
at individual methods
[ObfuscationAttribute(Exclude=true)]
and classes
[ObfuscationAttribute(Exclude=true, ApplyToMembers=true)]
None worked and the code example still got obfuscated. Am I using them wrong? I followed the official MS guide: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.obfuscationattribute?view=netframework-4.6.1
[Obfuscation(Exclude = true)] wouldn't work
you should use
[Obfuscation(Exclude = false, Feature="-typescramble;-rename;-anti debug")]
the string inside Feature is the feature you want to exclude for the type in ConfuserEx
@vincenthawke the only supported annotation is [Obfuscation(Exclude = false, Feature="-feature")]
Okay, so there is a problem here for sure. Excluding the class from protection is done correctly in your example @hitgubmitt. So that should work.
Fixing it on your end can be done by marking your Obf
class with the Newtonsoft.Json.JsonObjectAttribute
. ConfuserEx will detect this any this will resolve the issue.
I'm investigating why ConfuserEx isn't handling the [Obfuscation(Exclude = true)]
attribute correctly.
The issue why the [Obfuscation(Exclude = true)]
does not take it identified and will be fixed with the referenced pull-request.
@hitgubmitt: You'll find a build that resolves the bug with the exclude attribute here on the buildserver.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Steps to Reproduce:
I obfustacted the code below with this crproj:
Obf.cs
Program.cs
This code triggers an error:
As you can see, serialization breaks application. Even with [Obfuscation(Exclude = true)] attribute on the Obf class. What is the recommended way to achieve obfuscation when using json serialization via newtonsoft?
Thanks