yck1509 / ConfuserEx

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

Strange reference added to my DLL library #623

Open monobeginner opened 7 years ago

monobeginner commented 7 years ago

Hello,

Strange reference "ZbYCazQkHSfnBCWrIGrvlzUAiHhwA" has been added to my DLL library after obfuscation. In the end, it leads to error during my build (obfuscation finished successfully): Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'RhVFYHANogTjhuVxVlyMrkpvTdHZ, Version=0.0.0.0, Culture=neutral, PublicKeyToken='.

This is my config in csproj file:

    <Target Name="AfterCompile">
    <Exec Command="if &quot;$(PlatformName)&quot; == &quot;AnyCPU&quot; (if &quot;$(ConfigurationName)&quot; == &quot;Release&quot; (powershell.exe  -ExecutionPolicy Bypass -File  &quot;$(ProjectDir)confuserEx\confuserps.ps1&quot; &quot;'C:\Program Files (x86)\ConfuserEx\Confuser.CLI.exe'&quot; &quot;'$(ProjectDir)confuserEx\confuser.crproj'&quot; &quot;'$(ProjectDir)obj\$(ConfigurationName)\'&quot; &quot;'$(ProjectDir)obj\$(ConfigurationName)\$(TargetFileName)'&quot; &quot;'aggressive'&quot; )&#xD;&#xA;) else (if &quot;$(ConfigurationName)&quot; == &quot;Release&quot; (powershell.exe  -ExecutionPolicy Bypass -File  &quot;$(ProjectDir)confuserEx\confuserps.ps1&quot; &quot;'C:\Program Files (x86)\ConfuserEx\Confuser.CLI.exe'&quot; &quot;'$(ProjectDir)confuserEx\confuser.crproj'&quot; &quot;'$(ProjectDir)obj\$(PlatformName)\$(ConfigurationName)\'&quot; &quot;'$(ProjectDir)obj\$(PlatformName)\$(ConfigurationName)\$(TargetFileName)'&quot; &quot;'minimum'&quot; )&#xD;&#xA;)" />
  </Target>

Any workaround for this issue ? I also noticed that obfuscation works, but class names and namespaces stays the same. Is it expected behavior ? I would also like to have classes and namespaces obfuscated.

From output log it seems that everything went OK, no warnings / notes etc.

paulisfluent commented 7 years ago

I have seen something very similar. After Confusing, my DLL has a reference to QpngQPGzAUWMJUyWwOjulxYmwgXbA, or, in another build of the same DLL, QNACzHWbgCaNvFmlYuWwQJHJBRGhA.

paulisfluent commented 7 years ago

While investigating another issue, I seem to have inadvertently fixed this, by copying agray's Confuser rules in https://github.com/yck1509/ConfuserEx/issues/450#issuecomment-210821516. Here they are:

<rule preset="none" pattern="true">
        <protection id="anti debug" />
        <protection id="anti dump" />
        <protection id="anti ildasm" />
        <protection id="anti tamper" />
        <protection id="ctrl flow" />
        <protection id="ref proxy" />
        <protection id="rename" />
        <!--<protection id="invalid metadata" />-->
        <!--<protection id="constants" />-->
        <!--<protection id="resources" />-->
</rule>

I would guess it is one of the commented-out protections that's causing this error.

baswanders commented 6 years ago

I can confirm that this is solved when you exclude protection of resources.

I also noticed that the "strange" assembly is in fact a reference to the main assembly itself.

vinogradniy commented 6 years ago

"Strange" assembly is fact contains the compressed encrypted resources of the main assembly and it is loaded from the assembly data when the Module initialized. Main assembly contains only AssemblyLinked resources which refer to this "strange assembly".