yck1509 / ConfuserEx

An open-source, free protector for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
3.57k stars 1.64k forks source link

ObfuscationAttribute doesn't work #296

Closed rupertsciamenna89 closed 9 years ago

rupertsciamenna89 commented 9 years ago

Hi, I'm using ConfuserEx 1.5 and I try to exclude a member from renaming in the follow mode:

Imports System.Reflection

Public NotInheritable Class ProdottiTariffa
    Implements IEquatable(Of ProdottiTariffa)

    Friend Sub New()

    End Sub

    Friend Sub New(tariff As String, descri As String)
        Tariffa = tariff
        Descrizione = descri
    End Sub

    <Obfuscation(Feature:="rename", Exclude:=True)> _
    Public Property Tariffa As String

    <Obfuscation(Feature:="rename", Exclude:=True)> _
    Public Property Descrizione As String

    Public Overrides Function Equals(obj As Object) As Boolean
        Return Me.Equals(TryCast(obj, ProdottiTariffa))
    End Function

    Public Overloads Function Equals(obj As ProdottiTariffa) As Boolean Implements IEquatable(Of ProdottiTariffa).Equals
        If obj Is Nothing Then Return False
        Return obj.Tariffa.IEquals(Me.Tariffa)
    End Function
End Class

But If I decompile the source I have the follow result

using Methodos;
using System;
using System.Reflection;

public sealed class \u202B‫‌‬‪‍‏‭‏‫‫‍‭‭‮‎‍​‮ : IEquatable<\u202B‫‌‬‪‍‏‭‏‫‫‍‭‭‮‎‍​‮>
{
  [Obfuscation(Exclude = true, Feature = "rename")]
  public string \u206F‪‎‌‏‭‬‬‬‭​‬‪‪‍‎‎‫‭​‎‮‮ { get; set; }

  [Obfuscation(Exclude = true, Feature = "rename")]
  public string \u206D‍‍‫‭‭‍​‌‫‍‭‌‭‏‌‍‌‬​​‎‮‪‌‫​‮ { get; set; }

  internal \u202B‫‌‬‪‍‏‭‏‫‫‍‭‭‮‎‍​‮()
  {
  }

  internal \u202B‫‌‬‪‍‏‭‏‫‫‍‭‭‮‎‍​‮(string tariff, string descri)
  {
    this.\u206F‪‎‌‏‭‬‬‬‭​‬‪‪‍‎‎‫‭​‎‮‮ = tariff;
    this.\u206D‍‍‫‭‭‍​‌‫‍‭‌‭‏‌‍‌‬​​‎‮‪‌‫​‮ = descri;
  }

  public virtual bool \u200F‏‎‮‍‏‪‬‬‌‫‏‎‪​​‎‫‮‪‭‌‎‎‪‬​‮(object _param1)
  {
    return this.Equals(param0 as \u202B‫‌‬‪‍‏‭‏‫‫‍‭‭‮‎‍​‮);
  }

  public bool Equals(\u202B‫‌‬‪‍‏‭‏‫‫‍‭‭‮‎‍​‮ obj)
  {
    if (obj == null)
    {
label_1:
      uint num;
      switch ((num = (uint) (426475175 ^ 882029705)) % 3U)
      {
        case 0U:
          goto label_1;
        case 2U:
          return false;
      }
    }
    return StringExtensions.IEquals(obj.\u206F‪‎‌‏‭‬‬‬‭​‬‪‪‍‎‎‫‭​‎‮‮, this.\u206F‪‎‌‏‭‬‬‬‭​‬‪‪‍‎‎‫‭​‎‮‮);
  }
}

I've got another class with the ObfuscationAttribute with Exclude Flag to True and it works.

yck1509 commented 9 years ago

Hi, To remove a protection, you should use:

[Obfuscation(Exclude = false, Feature = "-rename")]
rupertsciamenna89 commented 9 years ago

Thanks, It works.

rupertsciamenna89 commented 9 years ago

Hi, I have still the issue.

I've got two auto-properties written in VB.NET on VS2013, but ConfuserEx rename them.

<Obfuscation(Feature:="-rename", Exclude:=False)> 
Public Property Tariffa As String

<Obfuscation(Feature:="-rename", Exclude:=False)> 
Public Property Descrizione As String

If I add the Get and the Set statements, the Confuser didn't perform the rename. Why? I changed the lines:

<Obfuscation(Feature:="-rename", Exclude:=False)> _
Public Property Tariffa As String
    <DebuggerStepThrough()> Get
        Return GetValue(Of String)("Tariffa")
    End Get
    <DebuggerStepThrough()> Set(ByVal value As String)
        SetValue("Tariffa", value)
    End Set
End Property

<Obfuscation(Feature:="-rename", Exclude:=False)> _
Public Property Descrizione As String
    <DebuggerStepThrough()> Get
        Return GetValue(Of String)("Descrizione")
    End Get
    <DebuggerStepThrough()> Set(ByVal value As String)
        SetValue("Descrizione", value)
    End Set
End Property
yck1509 commented 9 years ago

Hi, Please try the latest version at CI Server and see whether your problem had been fixed.