ConfuserEx icon indicating copy to clipboard operation
ConfuserEx copied to clipboard

.NET Core, .NET Standard, .NET 5 Support

Open alexguerin4 opened this issue 4 years ago β€’ 55 comments

Not really an issue, just wondering how compatible this project is with .Net 5 apps?

alexguerin4 avatar Jan 16 '21 04:01 alexguerin4

Not at all. The support for the core-like versions of .NET is broken with .NET Core 3 onwards.

mkaring avatar Jan 16 '21 10:01 mkaring

Is any work in progress with this

alex6dj avatar Jan 18 '21 13:01 alex6dj

What is broken from .NET Core 3 onwards? If the project was targeting .NET Standard 2.1 (or earlier versions) would that still be the case? Would really like to use Confuser.Core.dll within a project, that is written in .NET 5, I suppose I can just go the subprocess route; however, that is not necessarily ideal.

NotoriousRebel avatar Jan 24 '21 22:01 NotoriousRebel

The problem is the assembly resolving. The releases/2.0 is the furthest when it comes to preparing for the new versions of .NET, because that one has at least a proper handling for the runtime assemblies that would allow supporting the runtime up to .NET 5. That does not change that resolving the assembly references currently always snaps back to the .NET Framework that that is something that needs to be adressed.

Everything up to .NET Core 2.x and .NET Standard 2.0 can work when explicitly referencing all the required assemblies in the project file. .NET Core 3.x, .NET Standard 2.1 and .NET 5.0 I was not able to get working to this day without changes to the current version of ConfuserEx.

@NotoriousRebel: I am unsure if I understand correctly what you are trying to say here. But if you want to use the Confuser.Core.dll in your project, that is an entirely different topic.

The runtimes ConfuserEx is able to obfuscate and the version of .NET ConfuserEx itself uses to run, are two different things.

Now regarding the plan moving forward:

  • The proper support for .NET Standard, .NET Core and .NET >= 5, will be part of the 2.0 release. I'm planning to work on that once the 1.5 release that is close to completion now is released.
  • ConfuserEx 1.x itself will remain a .NET Framework 4.6.x application. Due to the way the runtime code deployment works, it has to remain a .NET Framework application.
  • ConfuserEx 2.x is already mostly migrated to .NET Standard. The command line application works as .NET Core application and only the user interface is currently a .NET Framework 4.6.1 application. The plan is to migrate everything that can't be .NET Standard to .NET 5. The .NET Framework version will be dropped. This does not mean that the support for obfuscating .NET Framework applications will be dropped.

mkaring avatar Jan 26 '21 18:01 mkaring

So I need to wait some time for v2 release? I have an app with .NET 4 and it won't launch after confusing.

Davilarek avatar Jun 04 '21 13:06 Davilarek

The release/2.0 branch has not been updated for months. Any news?

wmjordan avatar Jun 18 '21 08:06 wmjordan

Great work @mkaring ! Would you be comfortable sharing some progress update on this issue for those of us waiting? Perhaps you even have some tentative idea about when it could be done?

maximcus avatar Aug 19 '21 12:08 maximcus

I got a concept on how to approach the problem and a first rough version that works for all the .NET Framework, .NET 5/6, .NET Core and .NET Standard versions. There are still some problems when mixing different versions inside one ConfuserEx project and the performance is… problematic. Also it's not always injecting the correct runtime versions, leading the assemblies that target .NET Standard and .NET Framework at the same time and things like that. I'm getting there, but there are still some things to smooth out.

I'm expecting a first version that is ready for testing in October.

mkaring avatar Aug 19 '21 13:08 mkaring

Hi, Is there any update on when the first version that works for .net5 will be available? The Aug 19th comment mentions a first version ready for testing this October.

lsankar avatar Oct 19 '21 15:10 lsankar

Hello, Any news?

onurcanyilmaz avatar Oct 28 '21 06:10 onurcanyilmaz

.net 5 support would be much appreciated. Bought you some coffee, perhaps that helps ^_^

tyronx avatar Dec 01 '21 09:12 tyronx

Please consider focusing on .NET6 as this is LTS edition from MS

greenozon avatar Dec 05 '21 10:12 greenozon

I don't think there is a big difference between .NET6, .NET5, and even net core 3.1 in terms of ConfuserEx support.

KvanTTT avatar Dec 05 '21 10:12 KvanTTT

do you have any plan to test how compatible with .Net6?

dameng324 avatar Dec 11 '21 12:12 dameng324

Hi, Is there any news or planned release date for .net5? I would like to use this confuser in my .net5 project...

cs-blip avatar Jan 26 '22 13:01 cs-blip

Same here, just waiting :)

alex6dj avatar Jan 26 '22 14:01 alex6dj

mkaring, any update on this? I tried getting the latest release (1.6.0) to work with my .NET Core 6.0 project, w/o success. The same project was able to be obfuscated when it still targeted .NET Framework 4.8. I also tried https://github.com/obfuscar/obfuscar which worked w/ my .NET Core project, but didn't obfuscate private method contents which is key IMHO. Thank you in advance - ConfuserEx is amazing!

joschmo80 avatar Feb 23 '22 12:02 joschmo80

Same here, just waiting :)......

May be another new ConfuseEx project target only .net core?

xiaokun avatar Feb 24 '22 08:02 xiaokun

.Net 5 Support is exactly what I need :)

MrMoonCH avatar Mar 07 '22 12:03 MrMoonCH

If you want to make it work with the latest .net versions, you will maybe have to resolve some dependencies issues. In order to resolve them, don't forget to add, after the modules in your .crproj, the path to the missing dependencies using the probePath element like this (i.e) :

<probePath>C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.2\ref\net6.0</probePath>
<probePath>C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0</probePath>

Kratheon avatar Mar 08 '22 12:03 Kratheon

If you want to make it work with the latest .net versions, you will maybe have to resolve some dependencies issues. In order to resolve them, don't forget to add, after the modules in your .crproj, the path to the missing dependencies using the probePath element like this (i.e) :

<probePath>C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.2\ref\net6.0</probePath>
<probePath>C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0</probePath>

@Kratheon is possible to migrate a Net 4.7.2 WPF app to Net 5 or Net 6 and use ConfuserEx this way? Or it is not supported yet. If some one share an history it will be welcome.

alex6dj avatar Mar 08 '22 14:03 alex6dj

If you want to make it work with the latest .net versions, you will maybe have to resolve some dependencies issues. In order to resolve them, don't forget to add, after the modules in your .crproj, the path to the missing dependencies using the probePath element like this (i.e) :

<probePath>C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.2\ref\net6.0</probePath>
<probePath>C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0</probePath>

@Kratheon is possible to migrate a Net 4.7.2 WPF app to Net 5 or Net 6 and use ConfuserEx this way? Or it is not supported yet. If some one share an history it will be welcome.

Doesn't work for me. With 1.6.0 I get the Error: error MSB4018: System.AggregateException: One or more errors occurred. (Could not load file or assembly 'dnlib, Version=3.4.0.0, Culture=neutral, PublicKeyToken=50e96378b6e77999'. The system cannot find the file specified.) Seems it fails to copy the needed lib.

With 2.0.0-alpha-0191 I get: COnfuser.MSBuild.targets: [MSB4181] Confuser.MSBuild.Tasks.ConfuseTask returned FALSE no error in protocol.

But didn't invest much time TBH

cs-blip avatar Mar 08 '22 14:03 cs-blip

Was hoping to get this working with Blazor WASM on .NET 6.0, but keep getting this in browser console:

blazor.webassembly.js:1 RuntimeError: memory access out of bounds
    at dotnet.wasm:0x5cedc
    at dotnet.wasm:0x5b576
    at dotnet.wasm:0x5b48c
    at dotnet.wasm:0x6da89
    at dotnet.wasm:0x6d751
    at dotnet.wasm:0x327e4
    at dotnet.wasm:0x33233
    at dotnet.wasm:0x34287
    at dotnet.wasm:0x322e6
    at dotnet.wasm:0x31ed5

The obfuscated DLL is being generated, but I guess the "blazor.webassembly.js" WASM runtime has a problem with it.

gerneio avatar Mar 26 '22 16:03 gerneio

The whole thing to support .NET Standard 1.0 - 2.1, .NET Core 1.0 - 3.1 and .NET 5/6 really is a hassle to get working. The main issues are that the injected code messes a lot of things up and causes the assemblies to link to the wrong target assemblies. This is especially true, when mixing assemblies targeting different frameworks in one obfuscation run. For example one .NET 5 executable and one .NET Standard 2.1 class library.

The current state is:

  • Anti Debug - Works for assemblies clearly targeting windows
  • Anti Dump - Works for assemblies clearly targeting windows
  • Anti IL Dasm - Works
  • Anti Tamper - Completely broken
  • Constants - Mostly broken
  • Control Flow - Works
  • Invalid Metadata - Breaks everything
  • Name - Works
  • Hardening - Works kind of, depending on what else is active
  • Reference Proxy - Works
  • Resources - Broken
  • Type Scramble - Very broken
  • Watermark - Works :tada:
  • Compile Regex - Only works for .NET 5 (even .NET Framework versions are broken)
  • Tail Call - Works
  • Compressor - I don't even want to think about it

The main issue is matching the target assembly references correctly in each obfuscation unit.

I'm still on it and I know it's taking too long 😞

mkaring avatar Apr 01 '22 13:04 mkaring

We appreciate your hard work and continued effort! I'm guessing it's the same amount of work, but for me, even if we got it working for .net standard prior to .net latest, it would be of great help.

gerneio avatar Apr 01 '22 13:04 gerneio

P.S. to everyone who wants that .net latest support, I'm sure @mkaring would appreciate any donations (sponsor button below).

gerneio avatar Apr 01 '22 15:04 gerneio

The whole thing to support .NET Standard 1.0 - 2.1, .NET Core 1.0 - 3.1 and .NET 5/6 really is a hassle to get working. The main issues are that the injected code messes a lot of things up and causes the assemblies to link to the wrong target assemblies. This is especially true, when mixing assemblies targeting different frameworks in one obfuscation run. For example one .NET 5 executable and one .NET Standard 2.1 class library.

The current state is:

  • Anti Debug - Works for assemblies clearly targeting windows
  • Anti Dump - Works for assemblies clearly targeting windows
  • Anti IL Dasm - Works
  • Anti Tamper - Completely broken
  • Constants - Mostly broken
  • Control Flow - Works
  • Invalid Metadata - Breaks everything
  • Name - Works
  • Hardening - Works kind of, depending on what else is active
  • Reference Proxy - Works
  • Resources - Broken
  • Type Scramble - Very broken
  • Watermark - Works πŸŽ‰
  • Compile Regex - Only works for .NET 5 (even .NET Framework versions are broken)
  • Tail Call - Works
  • Compressor - I don't even want to think about it

The main issue is matching the target assembly references correctly in each obfuscation unit.

I'm still on it and I know it's taking too long 😞

That's very good progress, actually.

Which branch has the commits? I cannot find it under master/2.0

Now, this could be a stupid question but, would it be possible to skip the "mixed assemblies problem" for now and release a version that would simply confuse Net6 assemblies?

Thanks again, man, you rock.

LaraSQP avatar Apr 08 '22 21:04 LaraSQP

Hello! Thanks a lot @mkaring for the hard work you put into this project!

With @Kratheon, we are able to obfuscate .NET Standard 2.0 libraries and some simple .NET 6 projects, using ConfuserEx 1.6 and the probePath workaround.

I just have a small question for you, @mkaring... In a more complex .NET 6 project, I'm facing this error:

[ERROR] Failed to resolve a member, check if all dependencies are present in the correct version.
Exception: dnlib.DotNet.MemberRefResolveException: Could not resolve method: System.Drawing.Rectangle DevExpress.XtraSpreadsheet.ISpreadsheetControl::get_ViewBounds() (DevExpress.Spreadsheet.v22.1.Core, Version=22.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a)

I suspect the "mixed assemblies" problem. Can you please confirm (or not) this assumption?


The full log:

 [INFO] Confuser.Core 1.6.0+447341964f Copyright Β© 2014 Ki, 2018 - 2022 Martin Karing
 [INFO] Running on Microsoft Windows NT 6.2.9200.0, .NET Framework v4.0.30319.42000, 64 bits
[DEBUG] Discovering plugins...
 [INFO] Discovered 13 protections, 1 packers.
[DEBUG] Resolving component dependency...
 [INFO] Loading input modules...
 [INFO] Loading 'TestConfuserEx.dll'...
 [INFO] Initializing...
[DEBUG] Building pipeline...
[DEBUG] Executing 'Type scanner' phase...
 [INFO] Resolving dependencies...
[DEBUG] Checking Strong Name...
[DEBUG] Creating global .cctors...
[DEBUG] Executing 'Name analysis' phase...
[DEBUG] Building VTables & identifier list...
[ERROR] Failed to resolve a member, check if all dependencies are present in the correct version.
Exception: dnlib.DotNet.MemberRefResolveException: Could not resolve method: System.Drawing.Rectangle DevExpress.XtraSpreadsheet.ISpreadsheetControl::get_ViewBounds() (DevExpress.Spreadsheet.v22.1.Core, Version=22.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a)
  at dnlib.DotNet.MemberRef.ResolveMethodThrow()
  at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage)
  at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type)
  at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage)
  at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type)
  at Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters)
  at Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action`1 func, Func`1 targets, ConfuserContext context)
  at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context)
  at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token)

Sylvain2703 avatar Jul 12 '22 09:07 Sylvain2703

Hi All, What is the status for .NET 5 and 6 please ? I'm using since years on this awesome ConfuserEx for .Net Framework, but I really need to know asap if I can use it for my news projects on .NET 5 and 6 ? I'm kind of stuck right now with some issues, and I would like to be sure that I'm not trying to resolve the impossible :) Thx for your hard work, in any case I will continue to support you !

kyamit avatar Sep 04 '22 18:09 kyamit

Is not working with .Net 6? :(

darkfoxdeveloper avatar Sep 21 '22 21:09 darkfoxdeveloper