Giter Club home page Giter Club logo

confuserex's People

Contributors

a180285 avatar agilejoshua avatar almightyju avatar ambyte avatar andrew-skybound avatar caverna avatar cynecx avatar dependabot-preview[bot] avatar dependabot[bot] avatar elektrokill avatar gazzifx avatar gubed avatar imgbotapp avatar ivan-danilov avatar jbeshir avatar jonfuller avatar jroessel avatar jvitkauskas avatar kvanttt avatar luandevecchi avatar maddnias avatar mkaring avatar nik-net avatar osumatrix avatar picrap avatar rachamimyaakobov avatar rexyrexy avatar sebastianhaeni avatar xenocoderce avatar yck1509 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

confuserex's Issues

How can I prevent Enums from being renamed?

I decided to try to go forward with some small customization of the RenamePhase so that all public artifacts keep their names, including Events and Fields as I want users of my obfuscated dlls to be able to reference all things that are public but I'm running into some difficulties with Enum.

When going through all the obfuscation targets: foreach (var def in target)
the target list doesn't seem to have the Enums in there although their names are being obfuscated.

Can you help me find where the Enums are being renamed?

Integration with ILMerge

Would it be possible to add Integration with ILMerger into ConfuserEx?
perhaps it could come in the form of a packer.

ImportResolver error (Solved)

In InjectHelper.cs I found the error
'Importer' does not contain a definition for 'Resolver' and no accessible extension method 'Resolver' accepting a first argument of type 'Importer' could be found (are you missing a using directive or an assembly reference?)

Failed to extract binding property name

Some warning messages appeared, what problems will it cause, can I ignore?
...
[DEBUG] WinForms found, enabling compatibility.
[DEBUG] Newtonsoft.Json found, enabling compatibility.
[WARN] Failed to extract binding property name in 'System.Void xxx.FrmTerminal::InitializeComponent()'.
[INFO] Processing module 'xxx.Base.dll'...
[DEBUG] Executing 'Invalid metadata addition' phase...
...

Optimization: Indexed Iteration

For some commonly used list implementations, such as List<T>, arrays, ImmutableArray<T> and Span<T> the enumerator based iteration (with foreach) is slower than the iteration with using the index.

So it would be good to change the iteration from enumerator based iteration to the indexed iteration, provided the list implementation is known.

Additional considerations are required for List<T>, because the index based iteration does not check for concurrent modifications. It should be the default option to inject this check for modification into the code, but dropping this check should be possible as well, because the check will rely on reflection and may make thing slower than before.

So it needs to be checked if it is reasonable to create the indexed iteration with the modification check, or if that is slower than the iteration using the enumerator.

NuGet issue

Cannot compile "Error occurred while restoring NuGet packages: The operation failed as details for project Confuser.Optimizations.Exports could not be loaded."

Packer doesn't handle Satellite Assemblies correctly in net20

As of right now the compressor packer doesn't handle satellite assemblies for localisation correctly for net20 and net35. The reason is that the query for the satellite assembly isn't forwarded to the AssemblyResolve event of the AppDomain.

A possible solution is to force loading satellite assemblies once the parent assembly is unpacked.

Issue with name protection

I've successfully obfuscated an application using name protection only, but afterwards it crashes shortly after starting. It seems activating name protection results in failure during dll loading. This happens even when using name protection with debug mode:

System.IO.FileNotFoundException
HResult=0x80070002
Message=Die Datei oder Assembly "ProductName.slyckugiymmwnuoiyzbzdktvmzhgb, Culture=neutral" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
Source=mscorlib
StackTrace:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at System.Windows.Navigation.BaseUriHelper.GetLoadedAssembly(String assemblyName, String assemblyVersion, String assemblyKey)
at MS.Internal.AppModel.ResourceContainer.GetResourceManagerWrapper(Uri uri, String& partName, Boolean& isContentFile)
at MS.Internal.AppModel.ResourceContainer.GetPartCore(Uri uri)
at System.IO.Packaging.Package.GetPartHelper(Uri partUri)
at System.IO.Packaging.Package.GetPart(Uri partUri)
at System.Windows.Application.GetResourceOrContentPart(Uri uri)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at _ProductName.App.App.‍‍‌​‭‫‬​​​‫‍‪‎‫‎‪‮‮‫‌‮(Object , Uri )
at _ProductName.App.App._InitializeComponent()
at _ProductName.App.App._Main()

The application is targeting .NET 4.6.

Supported target platforms

confuser-debug2.crproj.txt

(Hello and many thanks in advance)

I have got problems with a library targeting to the dotnet 4.7.1 platform

• Using https://github.com/mkaring/ConfuserEx.git (release/2.0)
• ConfuserEx.CLi.exe
• Simple project file:

Problem:
• Looking into the output with dotpeek => no confusion takes place
• Doing the same stuff with the library targeting to dotnet 4.5.1 => the confusion takes place

Another problem:
• Another library targeting to dotnet standard 2.0 confused by confuserEx causes a System.TypeLoadException on startup

Question: Is dotnet standard 2.0 and dotnet 4.7.1 generally supported?

MEF Issue

Hello,
I wanted import a object in InjectPhase class but the imported object always return null I added Export attribute to InjectPhase class but exclude plugin from protections.

UI Application as .NET Core application

The UI Application of ConfuserEx needs to be updated to use .NET core, instead of .NET framework.

There are two ways to go about this:
Wait for .NET Core 3.0 and utilise the desktop packs to get everything working again, or use a cross platform UI framework (Avalonia?) to get this working.

Temp Files remain after packing

During the packing stage, a temp directory is created containing the packed exe. After the protection, the file and directory remain, my suggestion is to make ConfuserEx delete the temp directory after everything is done.

CLI as .NET Core app

The CLI application has to be rewritten so it is running on .NET core and not .NET framework anymore. This way the application will be cross platform and properly running faster.

Can not build

Hi,

I got this error.

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\dnlib\src\bin\Debug\netstandard2.0\dnlib.dll' could not be found	Confuser.Core.Exports	D:\VisualStudio\confuserEX2\Confuser.Core.Exports\CSC	1	Active
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\dnlib\src\bin\Debug\netstandard2.0\dnlib.dll' could not be found	Confuser.Renamer.Exports	D:\VisualStudio\confuserEX2\Confuser.Renamer.Exports\CSC	1	Active
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\dnlib\src\bin\Debug\net461\dnlib.dll' could not be found	Confuser.Helpers (net461)	D:\VisualStudio\confuserEX2\Confuser.Helpers\CSC	1	Active
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\dnlib\src\bin\Debug\netcoreapp2.1\dnlib.dll' could not be found	Confuser.Helpers (net461)	D:\VisualStudio\confuserEX2\Confuser.Helpers\CSC	1	Active
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\dnlib\src\bin\Debug\net461\dnlib.dll' could not be found	Confuser.Utilities (net461)	D:\VisualStudio\confuserEX2\Confuser.Utilities\CSC	1	Active
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\dnlib\src\bin\Debug\netcoreapp2.1\dnlib.dll' could not be found	Confuser.Utilities (net461)	D:\VisualStudio\confuserEX2\Confuser.Utilities\CSC	1	Active
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\Confuser.Helpers\bin\Debug\netcoreapp2.1\Confuser.Helpers.dll' could not be found	Confuser.Core (net461)	D:\VisualStudio\confuserEX2\Confuser.Core\CSC	1	Active
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\Confuser.Utilities\bin\Debug\netcoreapp2.1\Confuser.Utilities.dll' could not be found	Confuser.Core (net461)	D:\VisualStudio\confuserEX2\Confuser.Core\CSC	1	Active
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\dnlib\src\bin\Debug\netcoreapp2.1\dnlib.dll' could not be found	Confuser.Core (net461)	D:\VisualStudio\confuserEX2\Confuser.Core\CSC	1	Active
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\Confuser.Helpers\bin\Debug\net461\Confuser.Helpers.dll' could not be found	Confuser.Core (net461)	D:\VisualStudio\confuserEX2\Confuser.Core\CSC	1	Active
Error	CS0006	Metadata file 'D:\VisualStudio\confuserEX2\dnlib\src\bin\Debug\net461\dnlib.dll' could not be found	Confuser.Core (net461)	D:\VisualStudio\confuserEX2\Confuser.Core\CSC	1	Active
Error		Unable to locate repository containing directory 'D:\VisualStudio\confuserEX2\dnlib\src'.	dnlib	C:\Users\Admin\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63127-02\build\Microsoft.Build.Tasks.Git.targets	20	
Error		Unable to locate repository containing directory 'D:\VisualStudio\confuserEX2\dnlib\src'.	dnlib	C:\Users\Admin\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63127-02\build\Microsoft.Build.Tasks.Git.targets	20	
Error		Unable to locate repository containing directory 'D:\VisualStudio\confuserEX2\dnlib\src'.	dnlib	C:\Users\Admin\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63127-02\build\Microsoft.Build.Tasks.Git.targets	20	

Did I miss something?

Thank in advance.

Version 2.0 alpha not renaming

Hello, I compiled my self the app and when I try to use the renamer it does nothing, just saves the assembly.

Do you know what could it be?

In Name Protection, renPublic parameter seems to be missing

I may be missing something here.

If I activate Name Protection, all classes are being renamed, including public ones (I wanted public classes to keep their name and namespace) even though the default of the renPublic parameter is false.

After checking the code there seems to be no renPublic parameter implemented:

internal sealed class NameProtectionParameters : ProtectionParametersBase {
		internal IProtectionParameter<bool> RickRoll { get; } = ProtectionParameter.Boolean(rickRoll, false);
		internal IProtectionParameter<bool> RenameArguments { get; } = ProtectionParameter.Boolean("renameArgs", true);
		internal IProtectionParameter<bool> RenamePdb { get; } = ProtectionParameter.Boolean("renPdb", false);
		internal IProtectionParameter<bool> FlattenNamespace { get; } = ProtectionParameter.Boolean("flatten", true);
		internal IProtectionParameter<RenameMode> Mode { get; } = ProtectionParameter.Enum("mode", RenameMode.Unicode);
		internal IProtectionParameter<string> Password { get; } = ProtectionParameter.String("password", "");
		internal IProtectionParameter<bool> ForceRename { get; } = ProtectionParameter.Boolean("forceRen", false);
		internal IProtectionParameter<uint> IdOffset { get; } = ProtectionParameter.UInteger("idOffset", 0);

		internal IProtectionParameter<string> SymbolMapFileName { get; } =
			ProtectionParameter.String("mapFileName", "symbols.map");

		internal IProtectionParameter<bool> RenameXaml { get; } = ProtectionParameter.Boolean("renXaml", true);
	}

How can I rename only non public classes?

New Project Format

To support the feature requires in #23 and #24 it will be required to rework the project files. It is important that ConfuserEx will still be able to load the current project files to maintain proper backwards compatibility.

Required features:

  • Extended pattern - The pattern of the current system are good but at times miss leading. Things like is-public doesn't actually trigger on public members, but it triggers on members that are visible outside of the assembly, unless the current assembly is a executable, where it doesn't trigger at all. Things like this have to be cleaned up.
  • Flexible file references - Currently the project format only allows assemblies to be set as file. For the assembly it can be set, if the assembly is just a reference or of the assembly is subject to the protection. The new format should allow multiple formats such as assemblies, archives and utility files (to support references from utility files for project like NHibernate) and it should support hierarchical file references to allow referencing files inside archive or to support embedded reference files from projects like Costura.
  • No more presets - Presets will be removed, because they are not sufficiently flexible. ConfuserEx 2 will still contain presets, but more different presets for specific use cases (for executables, for libraries, for cross-platform projects) and these will populate the project with specific settings, but the settings will be stored directly in the project file and not the reference to the preset. This will allow more complex configurations to be stored in the presets, including specific options for the different settings.

Thats the plan to get started. More ideas are welcome. 😉

The difference regarding what format is currently used will be done based on the namespace and the names of the XML tags. The new format simply gets a new namespace.

Generic parameter sometimes not renamed in class method that implements an interface

I have an odd case where the override IL declaration for a method that implements an interface method does not have the generic parameter of the return type renamed. This only happens sometimes, though. Running Confuser for identical inputs (same project file/input assemblies) sometimes correctly does the rename, and other times it doesn't. I haven't been able to identify what triggers this, other than just rerunning Confuser until it fails to rename (although it's fairly frequent).

The class that implements the interface is in assembly A, while the interface itself is in assembly Dep. Public member renaming is enabled.

This results in a TypeLoadException when trying to run the program/access the type:

Unhandled Exception: System.TypeLoadException: Type '_hEn8b4s8oBY1jgZcQVQz4THS2ij' from assembly 'ConfuserTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' tried to override method '_dmsD4dyBswIfo0cd1FveEj2vUhX' but does not implement or inherit that method. at _i3zNHiwCYlitdxpMvsALWfmv8OM._tZQC7BOe6PSavpqbssDocOJC0W7(String[] )

Below is a screenshot of what I mean. _c4N69m2rOXJXyRZw1HwXxNcEk7c corresponds to Dep.IB.

image

The corresponding code:

class A : Dep.IA<Dep.IB>
{
    public Dep.IB Test(int a, string b, Dep.IB t) {
        return default;
    }
}

Version: 2.0-master
Example: ConfuserTest.zip

ERROR running ConfuserEx

The target framework of application to protect is .NET 2.0.
Following exception is thrown:
[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.Boolean System.Reflection.MethodInfo::op_Inequality(System.Reflection.MethodInfo,System.Reflection.MethodInfo) (mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
in dnlib.DotNet.MemberRef.ResolveMethodThrow()
in Confuser.Core.DnlibUtils.ResolveThrow(IMethod method)
in Confuser.Protections.ReferenceProxy.MildMode.ProcessCall(RPContext ctx, Int32 instrIndex)
in Confuser.Protections.ReferenceProxy.ReferenceProxyPhase.ProcessMethod(RPContext ctx)
in Confuser.Protections.ReferenceProxy.ReferenceProxyPhase.Execute(ConfuserContext context, ProtectionParameters parameters)
in Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action1 func, Func1 targets, ConfuserContext context)
in Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context)
in Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token)
[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.7.03056
[ERROR] Full 4.7.03056
[ERROR] v4.0
[ERROR] Client 4.0.0.0
[ERROR] v4.5 461808
[ERROR]

Runtime: Implementations for different framework version

Currently there is always exactly one version of the runtime part of the ConfuserEx. The problem is that the version has to be compatible to the version ConfuserEx itself is build, due to the way the build process is set up.

How ever in order to properly cover a wide range of target platforms, the runtime needs to be provided compiled for and with the specific dependencies for multiple versions.

Goal of this enhancement is to deploy multiple versions of the runtime with ConfuserEx, to cover frameworks that are incompatible with the framework version of ConfuserEx itself.

Declarative obfuscation is broken / not backwards compatible.

Hey!

Thanks for maintaining the project.
I've just run into an issue whilst migrating to this fork - we make heavy use of declarative obfuscation in our projects and found that this version throws a parsing error for our use case:

Broken:

preset(aggressive);+rename(mode=decodable)

Working:

false:preset(aggressive);+rename(mode=decodable)

I found out how to do this by looking at the feature match regex. Putting that colon in pushes the protection string into another capture group. I then checked the pattern parser's lexer to find a good value to use here, and false turns out to be a noop.

Exception when getting a column item from a DataRow object

I get the following exception on an execution path in our app:

Err number: 5. System.ArgumentNullException: Argumentet name kan ikke være null.
Parameternavn: name
ved System.Data.DataColumnCollection.get_Item(String name)
ved System.Data.DataRow.GetDataColumn(String columnName)
ved Agendec.Client.rscActivitySrv.CheckRemindForAct(AgFoundation.rscActivityBE& , DateTime& )

"Argumentet name kan ikke være null" translates to something like "The argument 'name' cannot be null", and "Parameternavn" to "Parameter name".

As stated in the header it seems to happen when accessing a column item from a DataRow object.
We access the get property of a column item in two ways:

  1. row.Item("nameOfColumn").
  2. row!nameOfColumn.

However, the exception doesn't seem to happen consistently; it seems to go ok in other parts of the code where we have the same type of code. Also, when I tried to add some logging code in the function where the exception occurred, the exception no longer occurred!?

When not obfuscated it works fine, and also works fine with ConfuserEx 1.0.0.

[Bug] Same key has already been added

Trying to run confuser against my project and some of the class libraries that it builds and get the following error:

[INFO] Initializing...
[DEBUG] Building pipeline...
[INFO] Resolving dependencies...
[DEBUG] Checking Strong Name...
[WARN] [EntityFramework.dll] SN Key is not provided for a signed module, the output may not be working.
[DEBUG] Creating global .cctors...
[DEBUG] Watermarking...
[DEBUG] Executing 'Name analysis' phase...
[DEBUG] Building VTables & identifier list...
[ERROR] Unknown error occurred.
Exception: System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at Confuser.Renamer.VTable.Implements(VTableConstruction vTbl, Dictionary2 virtualMethods, VTable ifaceVTbl, TypeSig iface)
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, Action1 func, Func1 targets, ConfuserContext context)
at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context)
at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token)
Failed at 11:10, 0:04 elapsed.

I was able to decompile the dll that I obfuscated with ConfuserEx

First, I'd like to thank you for providing the open source software to obfuscate the dll, exe and .csproj files. I tried to protect the dll using the ConfuseEx UI application from the latest release and tried to test it to decompile using dotPeek. I could see the source as is clearly. Is there any settings I must apply to properly protect it?

Unhandled Exception: System.PlatformNotSupportedException: Operation is not supported on this platform

I'm having some issues running Confuser.CLI.exe under dotnet on Linux and MacOS.

$ dotnet Confuser.CLI.exe
A fatal error was encountered. The library 'libhostpolicy.dylib' required to execute the application was not found in '/Users/davidtavarez/Development/ConfuserEx/'.
Failed to run as a self-contained app. If this should be a framework-dependent app, add the /Users/davidtavarez/Development/ConfuserEx/Confuser.CLI.runtimeconfig.json file specifying the appropriate framework.

$ dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

I did create the file called: Confuser.CLI.runtimeconfig.json:

{
  "runtimeOptions": {
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "2.2.2"
    }
  }
}

Now I have:

$ dotnet Confuser.CLI.exe

Unhandled Exception: System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.ConsolePal.get_Title()
   at Confuser.CLI.Program.Main(String[] args)
[1]    16476 abort      dotnet Confuser.CLI.exe

nuget package not found?

The readme notes:

The nuget package can be accessed using the AppVeyor Nuget Feed or it has to be self-hosted.

But there doesn't seem to be any packages available from the feed:

C:\Users\user>nuget list -Source https://ci.appveyor.com/nuget/confuserex-r4olq7m3uysu
No packages found.

Thanks in advance!

Selectable Assembly Packing [Feature]

The compressor doesn't allow to select which assemblies you do want to pack into your executable module.

Let's say you have 5 DLLs, but you only want the compressor to pack three of them into your EXE, the other two you want as-is, unpacked.

Today all DLLs are packed.
This issue is to request a feature to allow you to choose which assemblies will be packed.

Optimizaton: Local variable reusage

Local variables are always declared for the entire method, but they may not be used for the entire method.

This optimization should reduce the local variables by analyzing the scope where the local variable is used. Two variables with disjoint scopes may be combined into a single variable, provided both are reference types or the same value type.

The challenge for this optimization is to properly detect the scope of the variables.

This "optimization" will reduce the size of the stack marginally. Also it is unlikely to have any measurable impact on the performance. How ever local variables that are being reused do not make for easier to read code. So if nothing else, it is something to make the deobfuscated sources a little harder to work with.

System.ArgumentException: Feature property cannot be set when Exclude is true

[ERROR] Unknown error occurred.
Exception: System.ArgumentException: Feature property cannot be set when Exclude is true. Owner=Resque.Job
   at Confuser.Core.ObfAttrMarker.ToInfo(ObfuscationAttributeInfo attr, ProtectionSettingsInfo& info)
   at Confuser.Core.ObfAttrMarker.<ReadInfos>d__7.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Confuser.Core.ObfAttrMarker.ProtectionSettingsStack.Apply(IDnlibDef target, IEnumerable`1 infos)
   at Confuser.Core.ObfAttrMarker.ProcessModule(ModuleDefMD module, ProtectionSettingsStack stack)
   at Confuser.Core.ObfAttrMarker.MarkModule(ProjectModule projModule, ModuleDefMD module, Dictionary`2 rules, Boolean isMain)
   at Confuser.Core.ObfAttrMarker.MarkProject(ConfuserProject proj, ConfuserContext context)
   at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token)
Failed at 10:53, 0:00 elapsed.

Obfuscates public constants; causing problems/exceptions

It seems the contents of public constants are being obfuscated, causing problems/exceptions during app runtime.
In my case it seems the "dpConfig" in a class level constant I have is being obfuscated:
Public Const DEFAULT_ROOT_ELEMENT_NAME As String = "dpConfig"

As I've understood from the issue below, such constants should not be obfuscated?
yck1509#369

Various issues when building VB.Net project

The built file doesn't show at all and the output shows (Release 1.1.0):

[WARN] Could not find resource type 'DBMLBuilderLib.Dbml'.
[WARN] Could not find resource type 'DBMLBuilderLib.Gen'.
[WARN] Could not find resource type 'DBMLBuilderLib.Utis'.
[WARN] Could not find resource type 'DBMLBuilderLib.Sql'.
[WARN] Failed to extract binding property name in 'System.Windows.Forms.Binding DBMLBuilder.AdvancedBindingExtensions::AddOrReplace(System.Windows.Forms.ControlBindingsCollection,System.String,System.Object,System.String,System.Boolean,System.Windows.Forms.DataSourceUpdateMode,System.Object,System.String,System.IFormatProvider)'.
[WARN] Failed to extract binding property name in 'System.Windows.Forms.Binding DBMLBuilder.AdvancedBindingExtensions::AddBindingLazy<TControl,TDataObject,TBindingControlDataType,TBindingDataType>(TControl,System.Linq.Expressions.Expression1<System.Func2<TControl,TBindingControlDataType>>,System.Object,TDataObject,System.Linq.Expressions.Expression1<System.Func2<TDataObject,TBindingDataType>>,System.Boolean,System.Windows.Forms.DataSourceUpdateMode,System.Object,System.String,System.IFormatProvider,System.Windows.Forms.ConvertEventHandler,System.Windows.Forms.ConvertEventHandler)'.
[WARN] Failed to extract binding property name in 'System.Void FastColoredTextBoxNS.HotkeysEditorForm::InitializeComponent()'.

EDIT: I think that the issue is with the constraints renaming ... it seems to work when I don't use that.

Improve the code injection

The code injection is currently very … simple. It can't handle dependencies to other classes within the runtime assembly and it does not check if the injected code is actually properly referencing existing members in the new assembly.

All these problems need to be fixed.

Obfuscating assemblies in-place causes an IOException: The requested operation cannot be performed on a file with a user-mapped section open.

Previously I was able to obfuscate assemblies in-place successfully, however now it fails every time.

Unfortunately I can't provide the project I was testing with. I looked into the issue with procmon while stepping through code and found that there is a handle left open to one of the obfuscated modules.

This is even with the code that was originally intended to fix this problem: yck1509#76

I gave up here, as I'm not 100% sure where in ConfuserEx 2 to begin hunting for this!

Baml exception error

WpfApp1.zip

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <TextBlock>[123456</TextBlock>
    </Grid>
</Window>

Error occurred while using invalid metadata protection.

[DEBUG] Encrypting resources... [ERROR] Unknown error occurred. Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.Collections.Generic.List1.get_Item(Int32 index)
at dnlib.DotNet.Writer.MDTable1.get_Item(UInt32 rid) at Confuser.Core.Services.RandomGenerator.Shuffle[T](MDTable1 table)
at Confuser.Protections.InvalidMetadataProtection.InvalidMDPhase.Randomize[T](MDTable1 table) at Confuser.Protections.InvalidMetadataProtection.InvalidMDPhase.OnWriterEvent(Object sender, ModuleWriterEventArgs e) at dnlib.DotNet.Writer.EventHandler21.Invoke(Object sender, TEventArgs e)
at dnlib.DotNet.Writer.ModuleWriterOptionsBase.RaiseEvent(Object sender, ModuleWriterEventArgs e)
at dnlib.DotNet.Writer.ModuleWriterBase.OnWriterEvent(ModuleWriterEvent evt)
at dnlib.DotNet.Writer.ModuleWriterBase.Metadata_MetadataEvent(Object sender, MetadataWriterEventArgs e)
at dnlib.DotNet.Writer.Metadata.OnMetadataEvent(MetadataEvent evt)
at dnlib.DotNet.Writer.Metadata.Create()
at dnlib.DotNet.Writer.Metadata.CreateTables()
at dnlib.DotNet.Writer.ModuleWriter.WriteImpl()
at dnlib.DotNet.Writer.ModuleWriterBase.Write(Stream dest)
at dnlib.DotNet.ModuleDef.Write(Stream dest, ModuleWriterOptions options)
at Confuser.Core.ConfuserEngine.WriteModule(ConfuserContext context)
at Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action1 func, Func1 targets, ConfuserContext context)
at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context)
at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token)
Failed at 2:04 PM, 0:08 elapsed.

`

Location : ConfuserEx\Confuser.Core\Services\RandomService.cs Line 208
Solution :
image

Release?

I've got issues with the current 1.0 release of ConfuserEx, not renaming references in XAML, so all WPF applications break, unless I don't rename classes, which kinda defeats the purpose.

Could you make a release of this fork? I really don't wanna deal with .NET Core.

Obfuscation cannot handle reflections

The Obfuscator can't handle reflections within the Assembly since it doesn't check for reflections before renaming.

Example: typeof(Program).GetMethod("HelloWorld"); will throw a NullReferenceException, because the "HelloWorld" method gets renamed after Obfuscation (if Renaming Feature is enabled).

Solution: Add a reflection analyzer to cex using blocks and analyze all methods before renaming them

Test files (unobf & obfed):
TestFile.zip

Optimization: Tail Recursion

While generally something that always should be avoided, tail recursions are something that is written every now and then in the code.

Detecting and optimizing this is relatively easy. There are in general two ways to optimize a tail recursion when it is written in C# or VB.

  1. Adding the TailCall instruction before the return. This will clear out all memory preserved on the stack before moving on to the next iteration of the function. The upside of this method is that the stack depth behaves the same way as the original version.
  2. Adding a loop to the method instead of the recursive call. This is the solution everyone should write in the first place. The only disadvantage is that the stack behaves differently, compared to the original version.

Both method should be supported. Adding the TailCall should be the default option, as it just causes the stack memory to be discarded before the resursive invoke.

In case the method that calls itself recursively is virtual, only the first option is relevant, because the invocation may cause another implementation of the method to be called.

Issue with resources

Hi.

First of all I want to thank you for continuing development of ConfuserEx :)

We get the following exception when embedded resource are being used:
System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Agendec.Client.Resources.resources" was correctly embedded or linked into assembly "DPAgenda" at compile time, or that all the satellite assemblies required are loadable and fully signed.

We are using Normal preset and adding rename.
I've also tried removing resources but still get the same exception.
Without obfuscation it works fine.

Regards, Rolf

Can not build

Hello,
I got the error

CS1061 'Importer' does not contain a definition for 'Resolver' and no accessible extension method 'Resolver' accepting a first argument of type 'Importer' could be found (are you missing a using directive or an assembly reference?)

Am I missing something? Or do I use wrong dnlib version?

Generic class sometimes missing generic arguments in name after rename protection

I've got a case where a generic type does not have its generic arguments applied to the name - instead, the name is obfuscated and the generic arguments are trimmed off (A'1 -> _ujkljsfuoiu instead of the expected A'1 -> _ujkljsfuoiu'1. It seems to happen with the following setup:

  1. Enable decodable renaming
  2. Create a non-generic class, A
  3. Create a generic class, A`1
  4. Apply renaming protection

The problem only appears when the non-generic class A is loaded/obfuscated before the generic variant. If the generic class is processed first, it is named correctly.

As a result, attempting to run the program/load an assembly like this fails with a duplicate type exception similar to the following:

Unhandled Exception: System.BadImageFormatException: Duplicate type with name '_KXAnX9u6N2HxWpPt3OaOUtHSGLF' in assembly 'ConfuserTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Confuser version: 2.0-master
Minimal example: ConfuserTest.zip

Thanks!

Rename local variable names

Private attributes, properties and methods are renamed, also invocation to public methods are obfuscated with a proxy, but local variables are kept clear. Is there any reason? It seems easier. There is a configuration for that?
Example of protected code:
int a = 1; int b = 2; int addition = iojw80efas6dfy2ay(a, b);

It seems the function iojw80efas6dfy2ay() is a+b, due to the local variable name :P

Optimization: Compiling Regex

Regular Expressions are usually interpreted by the .NET regex implementation. How ever the implementation offers the possibility to compile the expressions into MSIL code that is exposed as an DynamicMethod. The main disadvantage of the compiled version of the expressions is the high upfront cost of compiling the expression. Also there are reports of memory leaks popping up every now and then.

This optimization should compile every constant regular expression into MSIL and embed the result into the assembly. While this may increase the size of the assembly significantly, it offers the increased performance of the compiled assemblies with none of it drawbacks, because the upfront cost of compiling the expression is done by ConfuserEx.

The main challenge is to find as many combinations of pattern and options that are used as possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.