Obfuscating .NET core assembly loads invalid references (from GAC instead of current directory)
I'm trying to obfuscate a .NET core dll that uses netstandard16, one of the references I'm using is the System.Reflection.dll.
I'm getting the following error:
[ERROR] Failed to resolve a type, check if all dependencies are present in the correct version. Exception: dnlib.DotNet.TypeResolveException: Could not resolve type: System.Reflection.ICustomAttributeProvider (System.Reflection, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) at dnlib.DotNet.TypeRef.ResolveThrow(ModuleDef sourceModule) in E:\Source\Public\Confuser2\dnlib\src\DotNet\TypeRef.cs:line 333
With the cached assemblies confirming:
[ERROR] System.Reflection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\System.Reflection\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Reflection.dll)
I've copied the actual correct System.Reflection.dll in the same folder but it still uses the incorrect one from the GAC.
I have all this working out of the box:
<protection id="ref proxy" />
<protection id="anti ildasm" />
<protection id="constants" />
<protection id="ctrl flow" />
<protection id="anti debug" />
I will try to make rename work too.
@stevehansen I'm working on my own fork of ConfuserEx: https://github.com/0xFireball/ModPhuserEx
I have successfully got the renamer to work with ASP.NET Core, but it requires some special things to do.
I'll soon write a documentation page that details .NET Core support if you're interested. Like I said earlier, plenty of protections are working fine with .NET Core.
Here you go! @stevehansen
I wrote a wiki page on using ModPhuserEx with .NET Core.
https://github.com/0xFireball/ModPhuserEx/wiki/Working-with-.NET-Core
@0xFireball i am trying to obfuscate .net core 1.1 but getting some errors about dependecies..
https://github.com/0xFireball/ModPhuserEx/issues/8
[INFO] ModPhuserEx v1.0.0-45-g1a7cffe Copyright (C) 0xFireball 2016, Ki 2014
[INFO] Running on Microsoft Windows NT 6.2.9200.0, .NET Framework v4.0.30319.42000, 64 bits
[DEBUG] Discovering plugins...
[INFO] Discovered 10 protections, 2 packers.
[DEBUG] Resolving component dependency...
[INFO] Loading input modules...
[INFO] Loading 'DataAccess.dll'...
[INFO] Initializing...
[DEBUG] Building pipeline...
[INFO] Resolving dependencies...
[DEBUG] Checking Strong Name...
[DEBUG] Creating global .cctors...
[DEBUG] Watermarking...
[DEBUG] Executing 'Name analysis' phase...
[DEBUG] Building VTables & identifier list...
[DEBUG] Analyzing...
[DEBUG] ASP.NET Core found, enabling compatibility.
[ERROR] Failed to resolve a type, check if all dependencies are present in the correct version.
Exception: dnlib.DotNet.TypeResolveException: Could not resolve type: System.Reflection.BindingFlags (System.Reflection, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
konum: dnlib.DotNet.TypeRef.ResolveThrow(ModuleDef sourceModule) C:\sil\ModPhuserEx\dnlib\src\DotNet\TypeRef.cs içinde: satır 334
konum: dnlib.DotNet.TypeRef.ResolveThrow() C:\sil\ModPhuserEx\dnlib\src\DotNet\TypeRef.cs içinde: satır 320
konum: dnlib.DotNet.Extensions.ResolveTypeDefThrow(ITypeDefOrRef tdr) C:\sil\ModPhuserEx\dnlib\src\DotNet\ICodedToken.cs içinde: satır 476
konum: Confuser.Renamer.Analyzers.InterReferenceAnalyzer.Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) C:\sil\ModPhuserEx\Confuser.Renamer\Analyzers\InterReferenceAnalyzer.cs içinde: satır 38
konum: Confuser.Renamer.AnalyzePhase.Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, Boolean runAnalyzer) C:\sil\ModPhuserEx\Confuser.Renamer\AnalyzePhase.cs içinde: satır 180
konum: Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters) C:\sil\ModPhuserEx\Confuser.Renamer\AnalyzePhase.cs içinde: satır 66
konum: Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action1 func, Func1 targets, ConfuserContext context) C:\sil\ModPhuserEx\Confuser.Core\ProtectionPipeline.cs içinde: satır 138
konum: Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) C:\sil\ModPhuserEx\Confuser.Core\ConfuserEngine.cs içinde: satır 219
konum: Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) C:\sil\ModPhuserEx\Confuser.Core\ConfuserEngine.cs içinde: satır 173
[ERROR] ---BEGIN DEBUG INFO---
[ERROR] Installed Framework Versions:
[ERROR] v2.0.50727 2.0.50727.4927
[ERROR] v3.0 3.0.30729.4926
[ERROR] v3.5 3.5.30729.4926
[ERROR] v4
[ERROR] Client 4.6.01055
[ERROR] Full 4.6.01055
[ERROR] v4.0
[ERROR] Client 4.0.0.0
[ERROR] v4.5 394271
[ERROR]
@0xfireball I have got the same problem with System.Reflection.BindingFlags In my project, I referenced "System.Runtime.Serialization.Formatters": "4.3.0" including System.Reflection 4.1.0