Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alexguerin4 opened this issue Jan 16, 2021 · 55 comments
Open

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

alexguerin4 opened this issue Jan 16, 2021 · 55 comments

Comments

@alexguerin4
Copy link

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

@mkaring
Copy link
Owner

mkaring commented Jan 16, 2021

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

@alex6dj
Copy link

alex6dj commented Jan 18, 2021

Is any work in progress with this

@NotoriousRebel
Copy link

NotoriousRebel commented Jan 24, 2021

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
Copy link
Owner

mkaring commented Jan 26, 2021

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.

@Davilarek
Copy link

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
Copy link

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

@maximcus
Copy link

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
Copy link
Owner

mkaring commented Aug 19, 2021

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
Copy link

lsankar commented Oct 19, 2021

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
Copy link

Hello,
Any news?

@tyronx
Copy link

tyronx commented Dec 1, 2021

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

@greenozon
Copy link

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

@KvanTTT
Copy link

KvanTTT commented Dec 5, 2021

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

@dameng324
Copy link

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

@cs-blip
Copy link

cs-blip commented Jan 26, 2022

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

@alex6dj
Copy link

alex6dj commented Jan 26, 2022

Same here, just waiting :)

@joschmo80
Copy link

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
Copy link

xiaokun commented Feb 24, 2022

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

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

@MrMoonCH
Copy link

MrMoonCH commented Mar 7, 2022

.Net 5 Support is exactly what I need :)

@Kratheon
Copy link

Kratheon commented Mar 8, 2022

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
Copy link

alex6dj commented Mar 8, 2022

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
Copy link

cs-blip commented Mar 8, 2022

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
Copy link

gerneio commented Mar 26, 2022

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
Copy link

gerneio commented Apr 1, 2022

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

@LaraSQP
Copy link

LaraSQP commented Apr 8, 2022

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
Copy link

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
Copy link

kyamit commented Sep 4, 2022

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
Copy link

Is not working with .Net 6? :(

@LaraSQP
Copy link

LaraSQP commented Sep 21, 2022

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
Copy link

uvbkq commented Sep 22, 2022

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:

  • anti ildasm,
  • rename,
  • harden.

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
Copy link

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
Copy link

aboah commented Oct 28, 2022

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
Copy link

tabs commented Dec 26, 2022

wait for v2.0 support all .net

@greenozon
Copy link

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

@tabs
Copy link

tabs commented Jan 29, 2023

wait

@sunnamed434
Copy link

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
Copy link

greenozon commented Apr 18, 2023

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
Copy link

tshcherban commented Apr 18, 2023

@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
Copy link

aboah commented Apr 19, 2023

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

@tshcherban
Copy link

@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
Copy link

singerscreations commented Apr 19, 2023

@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:

  • C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\7.0.5
  • C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.5
  • C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\7.0.4

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
Copy link

Does anybody try arleady this approach on .NET 8?

@singerscreations
Copy link

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

@tshcherban
Copy link

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

@tshcherban
Copy link

tshcherban commented Apr 20, 2023

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
Copy link

Exciting update!

image

@sunnamed434
Copy link

the new era has come

@aboah
Copy link

aboah commented Apr 20, 2023

@tshcherban Thank you for your reply

@aboah
Copy link

aboah commented Apr 20, 2023

@singerscreations Thank you for your reply

@aboah
Copy link

aboah commented Apr 20, 2023

[ERROR] Failed to resolve dependency of 'Sunshine.dll'.
Exception: dnlib.DotNet.AssemblyResolveException: Could not resolve assembly: System.Security.Cryptography, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
at dnlib.DotNet.Extensions.ResolveThrow(IAssemblyResolver self, IAssembly assembly, ModuleDef sourceModule)
at Confuser.Core.ConfuserEngine.Inspection(ConfuserContext context)
Failed at 10:03 AM, 0:02 elapsed.

@tshcherban
Copy link

tshcherban commented Apr 20, 2023

@aboah you might need some additional probe paths, if dependencies come from a nuget packages. We are adding a path to every nuget package, so Confuser can find its dll.
Does that System.Security.Cryptography come from a nuget (or referenced from some custom folder)? If no - just find it on your machine and add its folder as a probe path.

@singerscreations
Copy link

@aboah double check your .NET probe paths. I see errors like that when any of those paths are pointed to the wrong version of .NET.

@aboah
Copy link

aboah commented Apr 20, 2023

Thanks to all. I will try again and get back to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests