mkaring / ConfuserEx

An open-source, free protector for .NET applications
https://mkaring.github.io/ConfuserEx/
MIT License
2.39k stars 370 forks source link

.NET Core, .NET Standard, .NET 5 Support #302

Open alexguerin4 opened 3 years ago

alexguerin4 commented 3 years ago

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

mkaring commented 3 years ago

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

alex6dj commented 3 years ago

Is any work in progress with this

NotoriousRebel commented 3 years ago

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.

mkaring commented 3 years ago

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:

Davilarek commented 3 years ago

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

wmjordan commented 3 years ago

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

maximcus commented 3 years ago

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?

mkaring commented 3 years ago

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.

lsankar commented 3 years ago

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.

onurcanyilmaz commented 3 years ago

Hello, Any news?

tyronx commented 3 years ago

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

greenozon commented 2 years ago

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

KvanTTT commented 2 years ago

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

dameng324 commented 2 years ago

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

cs-blip commented 2 years ago

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

alex6dj commented 2 years ago

Same here, just waiting :)

joschmo80 commented 2 years ago

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!

xiaokun commented 2 years ago

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

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

MrMoonCH commented 2 years ago

.Net 5 Support is exactly what I need :)

Kratheon commented 2 years ago

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>
alex6dj commented 2 years ago

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.

cs-blip commented 2 years ago

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

gerneio commented 2 years ago

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.

mkaring commented 2 years ago

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:

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 😞

gerneio commented 2 years ago

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 commented 2 years ago

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

LaraSQP commented 2 years ago

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.

Sylvain2703 commented 2 years ago

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)
kyamit commented 2 years ago

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 !

darkfoxdeveloper commented 2 years ago

Is not working with .Net 6? :(

LaraSQP commented 2 years ago

I do not think @mkaring has made a commit to any of his repos in almost a year, whatever the reason.

So, a big thanks to him for taking up the project but we are royally screwed moving forward, it would seem, unless someone with the know-how picks it up again.

uvbkq commented 2 years ago

We've found it to be working with ConfuserEx 1.6 within the limits that mkaring described in his answer above while adding the required probe paths as described in an earlier post.

It has been applied to a reasonably complex .NET 6 project and was working with the following protections:

It is clearly a reduced scope of protections but probably what you can expect to work at this point in time until someone picks up the incredible work that has been done on ConfuserEx.

himanshukodwani commented 2 years ago

Is not working with .Net 6? :(

Inserting probe paths like below made it work with .net 6.

C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.6 C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\6.0.6 C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\6.0.6\ref\net6.0 C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.9\ref\net6.0 C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\6.0.9\ref\net6.0 C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\6.0.9
aboah commented 2 years ago

Please I would like to know the status of this project on dotnet 6 support What level of dotnet core can ConfuserEx support as at now

tabs commented 1 year ago

wait for v2.0 support all .net

greenozon commented 1 year ago

Any fresh & exciting news for .NET 7 (seven) support please?...

tabs commented 1 year ago

wait

sunnamed434 commented 1 year ago

my simple idea thing is to write plugins for bitmono based on confuserex protections and add any support you want :D

more info about the bitmono project

greenozon commented 1 year ago

OK, 2023 is in the air! how about this:

.NET 8 is the successor to .NET 7. It will be supported for three years as a long-term support (LTS) release. You can download .NET 8 here.

Microsoft suggests we focus only on 6/7/8, these are considered obsoleted...

image

tshcherban commented 1 year ago

@greenozon Im using ConfuserEX to obfuscate NET 6 [WPF] project. Not working out of the box, i needed to add probe paths of the installed NET manually:

C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.15\ref\net6.0
C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\6.0.15\ref\net6.0
C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\6.0.15\ref\net6.0

and 6.0.15 depends on the installed version, so i just ended up with a script determining the latest available version and inserting it as a probe path into confuser's crproj. Maybe the same will do for NET 7/8? Or you mean retargeting Confuser itself for NET 6/8?

aboah commented 1 year ago

I want to use ConfuseEx for dotnet 7 asp.net core web app but it is not working. How should it be done.

tshcherban commented 1 year ago

@aboah find your dotnet installed directory (might be C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\7.0.4\ref\net7.0) and add it as a probe path into your obfuscation project

singerscreations commented 1 year ago

@aboah add those directory paths here in ConfuserEx:

image

You can find your .NET directories here: C:\Program Files\dotnet\shared

Since you're using .NET 7, you'll want to add the following directories:

That's assuming you have the current version of .NET 7 installed (7.0.5 as of today). Browse to each of the above directories on your computer to find the latest version you have installed.

For example, when I browse to the "Microsoft.AspNetCore.App" directory on my computer, I found 7.0.5 is the latest version I have installed. That's why I'm using "7.0.5" in the directory path above.

image

Note: Your installed .NET version could be different for each of those directories.

greenozon commented 1 year ago

Does anybody try arleady this approach on .NET 8?

singerscreations commented 1 year ago

@greenozon I haven't tried .NET 8 yet, but the instructions I shared above should work.

tshcherban commented 1 year ago

Instructions above works for me for .NET6 for both WPF and ASP.NET will try NET8 shortly

tshcherban commented 1 year ago

UPD: Works on NET 8 for both ASP.NET and WPF projects. Added the following probe paths:

C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.0-preview.3.23174.8\ref\net8.0\
C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\8.0.0-preview.3.23177.8\ref\net8.0\
C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\8.0.0-preview.3.23178.1\ref\net8.0\

To make it work out of the box - maybe at some spare time ill try creating a PR (within my fork) which would add those paths automatically if dll to obfuscate targeting NET 6/7/8.

greenozon commented 1 year ago

Exciting update!

image

sunnamed434 commented 1 year ago

the new era has come

aboah commented 1 year ago

@tshcherban Thank you for your reply