XenocodeRCE / neo-ConfuserEx

Updated ConfuserEX, an open-source, free obfuscator for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
746 stars 89 forks source link

Newtonsoft JSON deserialization not working #20

Closed oddmario closed 5 years ago

oddmario commented 5 years ago

Hello, I have a JSON class like this:

    public class UpdateCheck
    {
        public bool UpdatesAvailable { get; set; }
        public string LinkOfNewVersion { get; set; }
    }

But the value of UpdatesAvailable and LinkOfNewVersion are null when I confuse my assembly using ConfuserEx :/

I've tried all the following:

    [Obfuscation(Exclude = false, Feature = "-rename")]
    public class UpdateCheck
    {
        public bool UpdatesAvailable { get; set; }
        public string LinkOfNewVersion { get; set; }
    }
    [Serializable]
    public class UpdateCheck
    {
        public bool UpdatesAvailable { get; set; }
        public string LinkOfNewVersion { get; set; }
    }
    [Serializable]
    [Obfuscation(Exclude = false, Feature = "-rename")]
    public class UpdateCheck
    {
        public bool UpdatesAvailable { get; set; }
        public string LinkOfNewVersion { get; set; }
    }

But all what I've tried failed :/

My obfuscation properties:

  <rule pattern="true" preset="maximum" inherit="false">
    <protection id="anti ildasm" />
    <protection id="anti tamper" />
    <protection id="constants" />
    <protection id="ctrl flow" />
    <protection id="anti dump" />
    <protection id="anti debug" />
    <protection id="invalid metadata" />
    <protection id="ref proxy" />
    <protection id="resources" />
    <protection id="typescramble" />
    <protection id="rename" />
  </rule>

Any help would be appreciated.

Thanks!

oddmario commented 5 years ago

EDIT: When I remove the "rename" protection from my ConfuserEx config file, my assembly crashes like that:

https://vgy.me/aUqg72.png

oddmario commented 5 years ago

SOLVED:

First of all, the solution of JSON is here: https://stackoverflow.com/a/52312266/10349407

NOTE: You don't even need to add the [Obfuscation(Exclude = false, Feature = "-rename")] or the [Serializable] attributes above your JSON class... Just add the JsonProperty attribute above each element in your JSON class.

And for this crash (https://vgy.me/aUqg72.png): I solved it by disabling the typescramble feature of ConfuserEx.