Coder Social home page Coder Social logo

xenocoderce / neo-confuserex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yck1509/confuserex

736.0 41.0 87.0 2.15 MB

Updated ConfuserEX, an open-source, free obfuscator for .NET applications

Home Page: http://yck1509.github.io/ConfuserEx/

License: Other

Batchfile 0.02% C# 99.98%
msil protect obfuscator csharp jit managed confuser confuserex obfuscation

neo-confuserex's People

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

neo-confuserex's Issues

Unknown error in dnlib, while Encrypting resources

Describe the bug
Unknown error in dnlib (see log below), while Encrypting resources, but not every time. Sometimes all ok, but target app become corrupted (not run at all). Original ConfuserEx with same config work well.

To Reproduce
See #12 (comment)

Expected behavior
No error.

Log

[DEBUG] Encrypting resources...
[ERROR] Unknown error occurred.
Exception: dnlib.DotNet.Writer.ModuleWriterException: Target instruction is too far away for a short branch. Use the long branch or call CilBody.SimplifyBranches() and CilBody.OptimizeBranches()
at dnlib.DotNet.DummyLogger.Log(Object sender, LoggerEvent loggerEvent, String format, Object[] args) in C:\projects\neo-confuserex\dnlib\src\DotNet\ILogger.cs:line 456
at dnlib.DotNet.Writer.MetaData.dnlib.DotNet.Writer.IWriterError.Error(String message) in C:\projects\neo-confuserex\dnlib\src\DotNet\Writer\MetaData.cs:line 2575
at dnlib.DotNet.Writer.MethodBodyWriterBase.WriteShortInlineBrTarget(BinaryWriter writer, Instruction instr) in C:\projects\neo-confuserex\dnlib\src\DotNet\Writer\MethodBodyWriterBase.cs:line 360
at dnlib.DotNet.Writer.MethodBodyWriterBase.WriteInstructions(BinaryWriter writer) in C:\projects\neo-confuserex\dnlib\src\DotNet\Writer\MethodBodyWriterBase.cs:line 118
at dnlib.DotNet.Writer.MethodBodyWriter.WriteFatHeader() in C:\projects\neo-confuserex\dnlib\src\DotNet\Writer\MethodBodyWriter.cs:line 144
at dnlib.DotNet.Writer.MethodBodyWriter.Write() in C:\projects\neo-confuserex\dnlib\src\DotNet\Writer\MethodBodyWriter.cs:line 97
at dnlib.DotNet.Writer.MetaData.WriteMethodBodies() in C:\projects\neo-confuserex\dnlib\src\DotNet\Writer\MetaData.cs:line 1552
at dnlib.DotNet.Writer.MetaData.Create() in C:\projects\neo-confuserex\dnlib\src\DotNet\Writer\MetaData.cs:line 1206
at dnlib.DotNet.Writer.ModuleWriter.WriteImpl() in C:\projects\neo-confuserex\dnlib\src\DotNet\Writer\ModuleWriter.cs:line 171
at dnlib.DotNet.Writer.ModuleWriterBase.Write(Stream dest) in C:\projects\neo-confuserex\dnlib\src\DotNet\Writer\ModuleWriterBase.cs:line 503
at Confuser.Core.ConfuserEngine.WriteModule(ConfuserContext context) in C:\projects\neo-confuserex\Confuser.Core\ConfuserEngine.cs:line 393
at Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action1 func, Func1 targets, ConfuserContext context) in C:\projects\neo-confuserex\Confuser.Core\ProtectionPipeline.cs:line 135
at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) in C:\projects\neo-confuserex\Confuser.Core\ConfuserEngine.cs:line 244
at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in C:\projects\neo-confuserex\Confuser.Core\ConfuserEngine.cs:line 175
Failed at 13:45, 0:04 elapsed.

Failed to protect exe file that have Embedded Resource dll file.

[ERROR] Failed to resolve dependency of 'filename.exe'.
Exception: dnlib.DotNet.AssemblyResolveException: Could not resolve assembly: testlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
at dnlib.DotNet.Extensions.ResolveThrow(IAssemblyResolver self, IAssembly assembly, ModuleDef sourceModule) in G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\dnlib\src\DotNet\IAssemblyResolver.cs:line 114
at Confuser.Core.ConfuserEngine.Inspection(ConfuserContext context) in G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Core\ConfuserEngine.cs:line 267
Failed at 6:30 PM, 0:00 elapsed.

[Discussion] - Ideas

Hi, @XenocodeRCE.

Thanks for continuing ConfuserEx, no one else "really" continued it, but there are some cool ideas scattered around which I think might be useful, and, if all parties agreed, could be merged in one project.

Here are some links.

Protection plugins (type scramble, anti-watermark, fake-obfuscator, memory protection, may be more)
https://github.com/BahNahNah/ConfuserExPlugins
https://github.com/HoLLy-HaCKeR/Confuser.Protections.HoLLy

Project updates (.net core, bug fixes, etc..)
Pending pull requests - https://github.com/yck1509/ConfuserEx
modPhuserEx - https://github.com/0xFireball/ModPhuserEx
ConfuserEx Reborn - https://github.com/CubeCoders/ConfuserEx-Reborn
HoLLy-HaCKeR version - https://github.com/HoLLy-HaCKeR/ConfuserEx/
windpalme version - https://github.com/windpalme/ConfuserEx/

Thanks.

API controllers are not working

Hi there,

I am using MVC C# technology with Visual Studio. But when I secure my code(.dll files) using neo-ConfuserEx and then my APIs are not working. No one can call my API controller.

Can you please help me to fix this issue.

This is very urgent for me.

Compressor causes console application to fail

Describe the bug
The compressor causes an exception during the startup of a console application.

To Reproduce
Steps to reproduce the behavior:

  1. Create a console application
  2. Ensure that the prefer 32bit flag is set
  3. Enable the compressor in ConfuserEx, only the confuser. Other obfuscations don't impact the behaviour of this bug.
  4. Run the compressed assembly.

It will raise a Win32Exception, once it tries to read the modules of any 64 process on the system.

Expected behavior
No exception is raised.

Additional context
The exception is caused by the CheckEnvironment method that is in the Runtime for the compressor. I am not sure what the purpose of this method it, because it changes the behaviour of a console application by showing the main modules of every process on the system. Maybe this is a debugging left over?

How to remove ConfuserEx signature ?

I have replaced all occurances of ConfuserEx from the project, but still hex editor shows ConfuserEx v1.0.0-xxxxxx signature somewhere in the ex, and decompilers re able to identify it's encrypted using ConfuserEx. How can I remove this signature ? @XenocodeRCE

Reference proxy error

Describe the bug
When I trying to edit reference proxy mode to ftn, it calls error when confusing.

To Reproduce
Steps to reproduce the behavior:

  1. Create config file.
  2. Put in config file <protection id="ref proxy"> <argument name="mode" value="ftn" /> </protection>
  3. Save it
  4. Run CLI with this config file

Expected behavior
Protects without error

Screenshots
screenshot_2

Why do you do such complex and unnecessary thing to build?

I clone your repository and try to build it.
When I wait about 20 minutes (yes, 20 minutes!), VS tell me timeout and build fail. I test abount 5 times, every time I must wait about 20 minutes then failed, can I can't cancel it.

There may be a few issues, one is that : why do you download nuget.exe?

VS2017 and VS2019 can build nuget references by default.

Why do you like to download it?

Failed to resolve dependency of DLL

I am using VS2017, my Clickonce project's target framework is .Net Framework 4.5, and using ConfuserEx v1.0.0-custom now.

Now I want to publish my project as Clickonce with confusion (including all referenced file, that mean assembly).
Step for my case:

  1. Choose "Release build"
  2. Then confuse the output files (.exe and all .dll) from Release folder
  3. Select Preset as "Minimum" as rules only
  4. During the confusion, "LabCI.TA4CS.Chart.dll" must occur "Failed to resolve dependency of xx.dll" problem.

I don't know how to solve it. And I try to embed it into my .exe or make it don't be confused (But don't know whether work or not). So, Does ConfuseEX have any feature, coding or way as solution, or any other way to exclude this .dll file or embed it into .exe?

The error is shown below:
[ERROR] Failed to resolve dependency of 'LabCI.TA4CS.Chart.dll'.
Exception: dnlib.DotNet.AssemblyResolveException: Could not resolve assembly: WPFVisifire.Charts, Version=2.2.3.0, Culture=neutral, PublicKeyToken=99d724542e4db593
at dnlib.DotNet.Extensions.ResolveThrow(IAssemblyResolver self, IAssembly assembly, ModuleDef sourceModule) in C:\Gary\Project\TempFile\190416_ResearchOfConfuser\ConfuserEx-master\ConfuserEx-master\dnlib\src\DotNet\IAssemblyResolver.cs:line 114
at Confuser.Core.ConfuserEngine.Inspection(ConfuserContext context) in C:\Gary\Project\TempFile\190416_ResearchOfConfuser\ConfuserEx-master\ConfuserEx-master\Confuser.Core\ConfuserEngine.cs:line 267
Failed at 9:23 AM, 0:00 elapsed.

virus signalled when using packer: compressor

A very basic attempt produced a serious virus error about password stealing. Windows defender.
See bottom of log, occured through packer. proj is very simple (and not by anyway an end product):
Without packer this does not happen. Makes me quite unhappy.

Threat detected: PWS:MSIL/CryptInjector!MTB
Alert level: Severe
Category: Password Stealer
Details: This program is dangerous and captures user passwords.

<project outputDir="Desktop\output" baseDir="Repos\SST2\x64\Release" xmlns="http://confuser.codeplex.com"> <packer id="compressor" /> <module path="SST_Gis.exe"> <rule pattern="true" inherit="false" /> </module> </project>

[INFO] ConfuserEx v1.0.0-38-g7889971 Copyright (C) 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 11 protections, 1 packers.
[DEBUG] Resolving component dependency...
[INFO] Loading input modules...
[INFO] Loading 'SST_Gis.exe'...
[INFO] Initializing...
[DEBUG] Building pipeline...
[DEBUG] Executing 'Type scanner' phase...
[INFO] Resolving dependencies...
[DEBUG] Checking Strong Name...
[DEBUG] Creating global .cctors...
[DEBUG] Watermarking...
[DEBUG] Executing 'Type scrambler' phase...
[DEBUG] 1] Import
[DEBUG] 0] Create
[DEBUG] 1] Create
[DEBUG] 2] Create
[DEBUG] 3] Create
[DEBUG] 4] Create
[DEBUG] 5] Create
[DEBUG] 6] Create
[DEBUG] 7] Create
[DEBUG] 8] Create
[DEBUG] 9] Create
[DEBUG] 10] Create
[DEBUG] 11] Create
[DEBUG] 12] Create
[DEBUG] 13] Create
[DEBUG] 14] Create
[DEBUG] 15] Create
[DEBUG] 16] Create
[DEBUG] 17] Create
[DEBUG] 18] Create
[DEBUG] 19] Create
[DEBUG] Executing 'Name analysis' phase...
[DEBUG] Building VTables & identifier list...
[DEBUG] Analyzing...
[DEBUG] WinForms found, enabling compatibility.
[INFO] Processing module 'SST_Gis.exe'...
[DEBUG] Executing 'Invalid metadata addition' phase...
[DEBUG] Executing 'Renaming' phase...
[DEBUG] Renaming...
[DEBUG] Executing 'Anti-debug injection' phase...
[DEBUG] Executing 'Anti-dump injection' phase...
[DEBUG] Executing 'Anti-ILDasm marking' phase...
[DEBUG] Executing 'Encoding reference proxies' phase...
[DEBUG] Executing 'Constant encryption helpers injection' phase...
[DEBUG] Executing 'Resource encryption helpers injection' phase...
[DEBUG] Executing 'Constants encoding' phase...
[DEBUG] Executing 'Anti-tamper helpers injection' phase...
[DEBUG] Executing 'Control flow mangling' phase...
[DEBUG] Executing 'Post-renaming' phase...
[DEBUG] Executing 'Anti-tamper metadata preparation' phase...
[DEBUG] Executing 'Packer info extraction' phase...
[INFO] Writing module 'koi'...
[INFO] Finalizing...
[INFO] Packing...
[DEBUG] Encrypting modules...
[INFO] Protecting packer stub...
[DEBUG] Discovering plugins...
[INFO] Discovered 12 protections, 1 packers.
[DEBUG] Resolving component dependency...
[INFO] Loading input modules...
[INFO] Loading 'SST_Gis.exe'...
[INFO] Initializing...
[DEBUG] Building pipeline...
[DEBUG] Executing 'Type scanner' phase...
[DEBUG] Executing 'Module injection' phase...
[INFO] Resolving dependencies...
[DEBUG] Checking Strong Name...
[DEBUG] Creating global .cctors...
[DEBUG] Watermarking...
[DEBUG] Executing 'Type scrambler' phase...
[DEBUG] 1] Import
[DEBUG] 0] Create
[DEBUG] 1] Create
[DEBUG] 2] Create
[DEBUG] 3] Create
[DEBUG] 4] Create
[DEBUG] 5] Create
[DEBUG] 6] Create
[DEBUG] 7] Create
[DEBUG] 8] Create
[DEBUG] 9] Create
[DEBUG] 10] Create
[DEBUG] 11] Create
[DEBUG] 12] Create
[DEBUG] 13] Create
[DEBUG] 14] Create
[DEBUG] 15] Create
[DEBUG] 16] Create
[DEBUG] 17] Create
[DEBUG] 18] Create
[DEBUG] 19] Create
[DEBUG] Executing 'Name analysis' phase...
[DEBUG] Building VTables & identifier list...
[DEBUG] Analyzing...
[INFO] Processing module 'SST_Gis.exe'...
[DEBUG] Executing 'Packer info encoding' phase...
[DEBUG] Executing 'Invalid metadata addition' phase...
[DEBUG] Executing 'Renaming' phase...
[DEBUG] Renaming...
[DEBUG] Executing 'Anti-debug injection' phase...
[DEBUG] Executing 'Anti-dump injection' phase...
[DEBUG] Executing 'Anti-ILDasm marking' phase...
[DEBUG] Executing 'Encoding reference proxies' phase...
[DEBUG] Executing 'Constant encryption helpers injection' phase...
[DEBUG] Executing 'Resource encryption helpers injection' phase...
[DEBUG] Executing 'Constants encoding' phase...
[DEBUG] Executing 'Anti-tamper helpers injection' phase...
[DEBUG] Executing 'Control flow mangling' phase...
[DEBUG] Executing 'Post-renaming' phase...
[DEBUG] Executing 'Anti-tamper metadata preparation' phase...
[DEBUG] Executing 'Packer info extraction' phase...
[INFO] Writing module 'SST_Gis.exe'...
[INFO] Finalizing...
[DEBUG] Saving to 'F:\TEMP\yqhrl5pa.suw\s0qfxbzj.lsy\SST_Gis.exe'...
[DEBUG] Executing 'Export symbol map' phase...
[INFO] Finish protecting packer stub.
[ERROR] An IO error occurred, check if all input/output locations are readable/writable.
Exception: System.IO.IOException: Operation did not complete successfully because the file contains a virus or potentially unwanted software.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)
at Confuser.Core.Packer.ProtectStub(ConfuserContext context, String fileName, Byte[] module, StrongNameKey snKey, Protection prot) in C:\projects\neo-confuserex\Confuser.Core\Packer.cs:line 86
at Confuser.Protections.Compressor.Pack(ConfuserContext context, ProtectionParameters parameters) in C:\projects\neo-confuserex\Confuser.Protections\Compress\Compressor.cs:line 91
at Confuser.Core.ConfuserEngine.Pack(ConfuserContext context) in C:\projects\neo-confuserex\Confuser.Core\ConfuserEngine.cs:line 427
at Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action1 func, Func1 targets, ConfuserContext context) in C:\projects\neo-confuserex\Confuser.Core\ProtectionPipeline.cs:line 135
at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) in C:\projects\neo-confuserex\Confuser.Core\ConfuserEngine.cs:line 256
at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in C:\projects\neo-confuserex\Confuser.Core\ConfuserEngine.cs:line 175
Failed at 20:55, 0:03 elapsed.

internal const string is null when obfuscating Release build

Summary:
An internal const string returns null when compiled for Release and obfuscated. It behaves normally when compiled for Debug and obfuscated, and when compiled for Release and not obfuscated.

Description:
The code below is a portion of a shared helper library used in multiple projects. The library is compiled into a single DLL which I want to obfuscate to protect the propietary code inside, but still use it across a variety of projects. Most of the code in the library is static.

MyBuildInfo.cs:

namespace MyBuildInfo
{
  internal static class Details
  {
    internal const string AssemblyFileVersion = "1.0.13533.1000";
  }
}

Common.cs:

namespace My.Library
{
  public static class Common
  {
    public static string CommonAssemblyFileVersion()
    {
      return MyBuildInfo.Details.AssemblyFileVersion;
    }
  }
}

When used in a larger project, we often want to display build/configuration/version information about the library to the user of the outer project to aid in error reporting. As such, the library has methods like CommonAssemblyFileVersion() which report build information about the shared library. MyBuildInfo is autogenerated from the source code repository and is used in other projects (including the outer project). The library provides the method in order to avoid name collisions and confusion.

I'm using a .crproj file to control obfuscation options. I don't have any [Obfuscate] attributes in the library project. My crproj uses template "none" and at least this protection:

<protection id="constants">
  <argument name="mode" value="normal" />
  <argument name="elements" value="S" />
</protection>

When I compile for Debug, then obfuscate, CommonAssemblyFileVersion() returns the expected value. When I compile for Release, then obfuscate, the same method returns null. (Naturally, the method returns the correct value at all times when not obfuscated.)

I'm calling the library like this:

  string x = Common.CommonAssemblyConfiguration();
  txtConfiguration.Text = string.Format("{0} {1}", x.Length, x);

When this fails, I get a NullReferenceException on x.Length. (I could deal with that if it was normal, but it doesn't help me get the data I need.)

Here are the Debug and Release build configuration settings from my csproj:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>..\bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <RunCodeAnalysis>true</RunCodeAnalysis>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <DocumentationFile>..\bin\Debug\McGladrey.Library.XML</DocumentationFile>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>..\bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DocumentationFile>..\bin\Release\McGladrey.Library.XML</DocumentationFile>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>

Additional details:

  • Windows 10 version 1809
  • Visual Studio Pro 2017, version 15.9.3
  • Class Library project, targeting .NET Framework 4
  • Language version: "C# latest major version (default)"
  • The expected value is still present in the obfuscated Release build. I can see it when I decompile using ILSpy,
  • The problem with the string property is unaffected by including or excluding elements N, I, P. I haven't checked if properties of those types are similarly affected, though.
  • When I changed CommonAssemblyFileVersion() to assign the value to a local string variable, then return that, the problem may have gone away...I think. It could be this blocks certain optimizations, or it may have been that I tested that with a Debug build.
  • Marking this particular constant so it is not obfuscated is an option, but there are many other internal constants that I still want to protect.
  • To ensure the problem isn't caused by Visual Studio debug mode, I also tested by running my outer project directly. The behavior is identical.

Newtonsoft JSON deserialization not working

Hello, I have a JSON class like this:

    public class UpdateCheck
    {
        public bool UpdatesAvailable { get; set; }
        public string LinkOfNewVersion { get; set; }
    }

But the value of UpdatesAvailable and LinkOfNewVersion are null when I confuse my assembly using ConfuserEx :/

I've tried all the following:

  • Adding the [Obfuscation(Exclude = false, Feature = "-rename")] attribute above my JSON class:
    [Obfuscation(Exclude = false, Feature = "-rename")]
    public class UpdateCheck
    {
        public bool UpdatesAvailable { get; set; }
        public string LinkOfNewVersion { get; set; }
    }
  • Adding the [Serializable] attribute above my JSON class:
    [Serializable]
    public class UpdateCheck
    {
        public bool UpdatesAvailable { get; set; }
        public string LinkOfNewVersion { get; set; }
    }
  • Adding both attributes above my JSON class:
    [Serializable]
    [Obfuscation(Exclude = false, Feature = "-rename")]
    public class UpdateCheck
    {
        public bool UpdatesAvailable { get; set; }
        public string LinkOfNewVersion { get; set; }
    }

But all what I've tried failed :/

My obfuscation properties:

  <rule pattern="true" preset="maximum" inherit="false">
    <protection id="anti ildasm" />
    <protection id="anti tamper" />
    <protection id="constants" />
    <protection id="ctrl flow" />
    <protection id="anti dump" />
    <protection id="anti debug" />
    <protection id="invalid metadata" />
    <protection id="ref proxy" />
    <protection id="resources" />
    <protection id="typescramble" />
    <protection id="rename" />
  </rule>

Any help would be appreciated.

Thanks!

Problem with multilingual .NET application

Describe the bug
I have a C# Windows WPF application with multilingual interface. I use a standard approach when the translatable strings are stored in dedicated resource files, one file per language:

image

Then the program sets the current language in constructor of the main form using the following code:

string InterfaceLanguage;
/*
Here goes a routine to load the language from config file
After that we have something like this:
InterfaceLanguage = "en-US";
*/
CultureInfo culture;
try
{
	culture = new CultureInfo(InterfaceLanguage);
}
catch (Exception)
{
	culture = CultureInfo.InvariantCulture;
}
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
System.Threading.Thread.CurrentThread.CurrentCulture = culture;

Expected behavior
The interface of the program matches what is specified in CurrentUICulture. That's how the program works if ConfuserEx is not used. Instead I always see the default interface (specified by file Translations.resx).

ConfuserEx settings

<!-- This configuration file describes the protection applied to the project -->
<project outputDir=".\Confused" baseDir=".\MyProgram\bin\x64\Release" xmlns="http://confuser.codeplex.com">
  <packer id="compressor" />
  <module path="MyProgram.exe" snKey="..\..\..\MyProgram.pfx" snKeyPass="XXX">
	<rule pattern="true" preset="none" inherit="true">
		<protection id="anti debug">
			<argument name="mode" value="antinet" />
		</protection>
		<protection id="anti dump" />
		<protection id="anti ildasm" />
		<protection id="anti tamper">
			<argument name="mode" value="normal" />
			<argument name="key" value="dynamic" />
		</protection>
		<protection id="constants">
			<argument name="mode" value="dynamic" />
			<argument name="decoderCount" value="10" />
			<argument name="elements" value="SPI" />
			<argument name="cfg" value="false" />
		</protection>
		<protection id="ctrl flow">
			<argument name="type" value="switch" />
			<argument name="predicate" value="expression" />		
			<argument name="intensity" value="60" />
			<argument name="depth" value="4" />
			<argument name="junk" value="true" />
		</protection>		
		<protection id="invalid metadata" />
		<protection id="rename">
		  <argument name="mode" value="unicode" />
		  <argument name="renameArgs" value="false" />
		  <argument name="renEnum" value="false" />
		  <argument name="flatten" value="false" />
		  <argument name="renXaml" value="false" />
		</protection>
		<protection id="ref proxy">
			<argument name="mode" value="mild" />
			<argument name="encoding" value="normal" />
			<argument name="depth" value="8" />
		</protection>		
		<protection id="resources">
			<argument name="mode" value="dynamic" />
		</protection>		
	</rule>
  </module>
  <module path="Helper.dll" snKey="..\..\..\Helper.pfx" snKeyPass="XXX">
	<rule pattern="true" preset="normal" inherit="true">
	</rule>
  </module>
</project>

I tried playing with different options, but it does not help. I get the correct behavior only if I strip everything from the ConfuserEx project file and leave only the simplest basic protections like anti debug.

Building the Project the first time

Describe the bug
A clear and concise description of what the bug is.

The dnlib (unavailable) The project file or web cannot be found.

What do I need to do to compile ?

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

File (optional)
Either share a link to download the file or e-mail it to me.

Additional context
Add any other context about the problem here.

ERROR: Unkown error occurred: Exception: System.NullReferenceException

[ERROR] Unknown error occurred.
Exception: System.NullReferenceException: link to object doesn't link to instance of the object
in Confuser.Renamer.Analyzers.LdtokenEnumAnalyzer.Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) in G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Renamer\Analyzers\LdtokenEnumAnalyzer.cs:line55
in Confuser.Renamer.AnalyzePhase.Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, Boolean runAnalyzer) in G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Renamer\AnalyzePhase.cs:line 133
in Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters) in G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Renamer\AnalyzePhase.cs:line 55
in Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action1 func, Func1 targets, ConfuserContext context) in G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Core\ProtectionPipeline.cs:line 138
in Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) in G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Core\ConfuserEngine.cs:line 219
in Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Core\ConfuserEngine.cs:line 173
Failed at 20:37, 0:00 elapsed.

koivm

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

replace "MvvmLight..." with "RelayCommand"

using System;
using System.Windows.Input;

namespace ConfuserEx
{
    public class RelayCommand : RelayCommand<object>, ICommand
    { 
        public RelayCommand(Action execute)
            : base((p) => execute())
        {
        }

        public RelayCommand(Action execute, Func<bool> canExecute)
            :base((p)=>execute(),(p)=>canExecute())
        { 
        }
    }

    public class RelayCommand<T> : ICommand
    {
        #region Fields

        private Func<T, bool> _canExecute;
        private Action<T> _execute;
        private bool _IsExecuting = false;
        #endregion // Fields

        #region Constructors 
        public RelayCommand(Action<T> execute)
            : this(execute, null)
        {
        }

        public RelayCommand(Action<T> execute, Func<T, bool> canExecute)
        {
            ResetActions(execute, canExecute);
        } 
        #endregion // Constructors

        #region ICommand Members 
        public bool CanExecute(object parameter)
        {
            return _canExecute == null ? true : ((!_IsExecuting) && _canExecute((T)parameter));
        }

        public event EventHandler CanExecuteChanged
        {
            add { System.Windows.Input.CommandManager.RequerySuggested += value; }
            remove { System.Windows.Input.CommandManager.RequerySuggested -= value; }
        }

        public void Execute(object parameter)
        {
            try
            {
                if (_IsExecuting)
                    return;
                _IsExecuting = true;
                RaiseCanExecuteChanged();
                _execute((T)parameter);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                _IsExecuting = false;
                RaiseCanExecuteChanged();
            }
        }
        #endregion

        public void ResetActions(Action<T> execute, Func<T, bool> canExecute)
        {
            if (execute != null)
            {
                _execute = execute;
            }
            if (canExecute != null)
            {
                _canExecute = canExecute;
            }
        }

        public void RaiseCanExecuteChanged()
        {
            System.Windows.Input.CommandManager.InvalidateRequerySuggested();
        } 
    }
}

object name overloading

I'm migrating over to neo-ConfuserEx after using Dotfuscator for a while. I'm surprised that one of the features I liked from Dotfuscator didn't make it here.

When Dotfuscator renames objects, it combines objects of different types to the same name, so long as signatures don't overlap. For instance, you might have a namespace named "x", a class named "x", and several methods named x which all have different signatures: x(), x(string), x(int), x(string, string), x(StringBuilder, string, bool), and so on.

While long random names are hard to read, they are also unique, which lends itself to search-and-replace techniques. When you have 50 methods all named "x" that do completely unrelated things, it's a little harder to visually understand a project.

I've dabbled in reflection and types, and what I've seen makes me think .NET would already provide most of the info needed. As I understand it, .NET treats the name+signature as the complete name of any object. The internal structure for old-name vs. new-name might need to be made aware of this additional information.

V2 of this feature might further confuse things by identifying signatures that do not yet exist for a particular name, adopting some other method with the same signature, altering constants and control flow, and adding that to the mix. These additional methods could be called by dead branches of switch statements elsewhere in the code.

I'd be interested in contributing to this, though I'm not sure how.

Thanks for your work on this very useful tool!

Can someone explain what AntiMode does in AntiTamper

Can someone explain what the "anti" mode in anti tamper protection does? The documentation only describes the NormalMode and JITMode, Anti mode appears to be new and only available in neo-confuserex.

Is this meant to be hidden?

The reason I ask is all 3 modes of anti-tamper cause my executable to crash with no exception. If I debug it using dnspy and break at the entry point (or create process) I get "Exception ???" and no more information.

I will try building with debug symbols to see if I can get any more information where and why it is crashing.

FatalExecutionEngineError when using your version of ConfuserEx

I was previously using the original ConfuserEx, but could never get resource obfuscation to work, so when I saw your fork I decided to give it a shot. When I try to consume my newly confused assemblies in any of my projects I receive the following error at startup:

Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'x.vshost.exe'.

Additional information: The runtime has encountered a fatal error. The address of the error was at 0xecef57a6, on thread 0x1628. The error code is 0x80131623. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

Does ver5 means version 4.5 and above (in Confuser.Runtime/AntiTamper.JIT.cs) ?

Every thing is in the title :) Also, I would like to know:

  1. If yes, then why not use Environment.Version.Minor ?
  2. If yes, then I guess 17020 is the last revision before 4.5 ?
  3. If 2, then the fact that index in the vtable of getMethodDefFromMethod changes according to ver4, ver5, !ver4 means that for each case, the CLR (because getMethodDefFromMethod is in the CLR, yes ?) changed. So it means one could get and use the version of the CLR to make the right adjustments ?

Precision: For 3), I'm talking about the HookHandler function

Reference Proxy fails

Describe the bug
When I trying to edit reference proxy mode to strong, it calls error in protected application.

To Reproduce
Steps to reproduce the behavior:

  1. Create config file.
  2. Put in config file <protection id="ref proxy"> <argument name="mode" value="strong" /> </protection>
  3. Save it
  4. Run CLI with this config file
  5. Try to run application

Expected behavior
Application works normally

Screenshots
screenshot_3

AntiDebugWin32 closes process if it release build and not under debugger

Application closes unexpectedly if plugin (loaded assembly) was processed with anti-debug protector.

I try it at huge project and i don't have small project to reproduce the issue.
Later, i try to build it.

After a small code digging I found, application close by code

if (OutputDebugString("") > IntPtr.Size)
Environment.FailFast("String"); //I added message to identify problem at log

Windows event log confirms it -
Pic

It normally reproduces at Windows 7 x64
I tried to run at two computers - my work computer and at production.

Conditions:
Win 7 x64, .NET 4.6.1

Renamer broke types implement inherited interface

Describe the bug
An exception Unhandled Exception: System.TypeLoadException: Signature of the body and declaration in a method implementation do not match. will be thrown.

To Reproduce
Use the following project and the Normal preset to reproduce the issue.
ConsoleApp1.zip

Related code:

class C<TItem> : S<TItem>
{
	public TItem GetT(int key)=> default(TItem);
}
interface S<TItem> : I<int, TItem> { }
interface I<TKey, TItem> {
	TItem GetT(int key);
}

App doesn't work like it should after using ConfuserEx

When I use ConfuserEx on my small app, some functions are not working in app and I don't know why. Most have to do with "connecting to internet", for example I have a function which checks current time and after I use ConfuserEx on my app that doesn't work, app just does nothing or freezes. I searched around for some solution but found nothing (even tried other protectors and have problem on all versions). Any idea what could be wrong? I saw someone write that it may be because of watermark function at ConfuserEx but I was not able to remove and compile it, can only use executable version.

Not working with .net core console application dlls.

I am trying obfuscating .net core dll but it is not able to do that. It is showing an error:
[ERROR] Failed to resolve dependency of 'DemoApp.dll'.
Exception: dnlib.DotNet.AssemblyResolveException: Could not resolve assembly: System.Console, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
at dnlib.DotNet.Extensions.ResolveThrow(IAssemblyResolver self, IAssembly assembly, ModuleDef sourceModule) in G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\dnlib\src\DotNet\IAssemblyResolver.cs:line 114
at Confuser.Core.ConfuserEngine.Inspection(ConfuserContext context) in G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Core\ConfuserEngine.cs:line 267
Failed at 11:38 AM, 0:00 elapsed.

What version of dnlib do you need to build this?

Describe the bug
dnlib is not included. I cloned master dnlib but there are references to items that are no there.

To Reproduce
Steps to reproduce the behavior:

  1. clone latest neo-confuserex
  2. clone latest dnlib
  3. attempt to build
  4. See error

error CS0246: The type or namespace name 'IModuleWriterListener' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'IModuleWriterListener' could not be found (are you missing a using directive or an assembly reference?)
error CS0538: 'IModuleWriterListener' in explicit interface declaration is not an interface
error CS0246: The type or namespace name 'IImageStream' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'ImportResolver' could not be found (are you missing a using directive or an assembly reference?)
error CS0115: 'InjectHelper.InjectContext.Resolve(TypeDef)': no suitable method found to override
error CS0115: 'InjectHelper.InjectContext.Resolve(MethodDef)': no suitable method found to override
error CS0115: 'InjectHelper.InjectContext.Resolve(FieldDef)': no suitable method found to override
error CS0246: The type or namespace name 'IImageStream' could not be found (are you missing a using directive or an assembly reference?)

Expected behavior
Builds correctly.

Please put instructions on how to build, use nuget packages or include a copy of dnlib with your source.

.net core errors and missing functionality

Tried to obfuscate .NetCore app and got an error. What is about moving to the newest dnlib with stronger .Net Core support?

Exception: dnlib.DotNet.TypeResolveException: Could not resolve type: System.Runtime.CompilerServices.IAsyncStateMachine (System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
   в dnlib.DotNet.TypeRef.ResolveThrow(ModuleDef sourceModule) в G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\dnlib\src\DotNet\TypeRef.cs:строка 334
   в dnlib.DotNet.TypeRef.ResolveThrow() в G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\dnlib\src\DotNet\TypeRef.cs:строка 320
   в Confuser.Renamer.VTableStorage.GetVTable(ITypeDefOrRef type) в G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Renamer\VTable.cs:строка 342
   в Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage) в G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Renamer\VTable.cs:строка 156
   в Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type) в G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Renamer\VTable.cs:строка 332
   в Confuser.Renamer.VTableStorage.GetVTable(ITypeDefOrRef type) в G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Renamer\VTable.cs:строка 340
   в Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters) в G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Renamer\AnalyzePhase.cs:строка 45
   в Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action`1 func, Func`1 targets, ConfuserContext context) в G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Core\ProtectionPipeline.cs:строка 138
   в Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) в G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Core\ConfuserEngine.cs:строка 219
   в Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) в G:\Users\Xenocode\Source\Repos\neo-ConfuserEx\Confuser.Core\ConfuserEngine.cs:строка 173
Either share a link to download the file or e-mail it to me.

Program is quite big, and starts from async Main

public static async Task Main(string[] args)

Dynamic output directory? [CLI]

Is your feature request related to a problem? Please describe.
Yes, if possible, make the crproj file output and basedir dynamic.

Describe the solution you'd like
I am trying to make my program use yours with the crproj file, problem is, that I want to share my program so the output and basedir wont be the same. So I am suggesting to make the output dir and basedir dynamic.

Describe alternatives you've considered
I haven't considered any alternatives, if you know any, please let me know.

Additional context
Thanks in advance.

Protected file crashes on Windows 7

Describe the bug
When running a protected file on Windows 7, it crashes.

To Reproduce
Steps to reproduce the behavior:

  1. Protect a file
  2. Run it on Windows 7
  3. Witness a crash

Expected behavior
It is expected not to crash.

Additional comments
This may be due to the configuration or the program itself.

TypeScrambler fails when scrambling generic class

Describe the bug
The type scrambler causes and error together with the renaming when handling methods in a generic class, because it does not handle the generic parameters of the class itself properly.

To Reproduce
Steps to reproduce the behavior:

  1. Have an assembly that contains a class like this: https://github.com/mkaring/ConfuserEx/blob/feature/typescrambler_unittest/Tests/TypeScrambler/GenericClass.cs
  2. Try to have the type scrambler process it. Be sure that the Confuser.Rename assembly is loaded and active as well, because it's AnalyzePhase raises the error.

Expected behavior
Should work without errors.

Additional context
My best guess is that the scrambler does not consider the generic parameter of the class at this point.
The result of the UnitTest, including the error is here:
https://ci.appveyor.com/project/mkaring/confuserex/build/13#L289

Additional Methods Added During Name Protection?

Hi, I noticed some additional methods and fields being added in blank namespace after Name Protection. I've looked through the source code but I couldn't figure out where or why they're being added. Any ideas?

ConfuserEx_Problem

Screenshot is from dnSpy after using Name Protection only (debug setting). I'm wondering where those <>f__AnonymousType0<\u0001,\u0002> and <PrivateImplemenationDetails> methods come from.

The releases are not updated

Is your feature request related to a problem? Please describe.
No, but I see that there's some new commits that weren't built and uploaded in the releases of the repo. I tried to build it manually but I faced a lot of build errors.

Describe the solution you'd like
Update the releases with the new edited commits.

Obfuscated property works differently

Describe the bug
I have a property that looks like string MyProperty => (A && !B) ? "string A" : "string B";. After obfuscation it is always returning null.

To Reproduce
I have tried to produce a minimal example, but it seems that this is specific to our particular project. If I do this in a test class it works.

Here's my config:

Configuration file

  <rule preset="none" pattern="true">
    <protection id="anti debug">
      <argument name="mode" value="safe" />
    </protection>
    <protection id="anti ildasm" />
    <protection id="constants">
      <argument name="mode" value="normal" />
      <argument name="elements" value="S" />
    </protection>
    <protection id="ctrl flow">
      <argument name="type" value="switch" />
    </protection>
    <protection id="rename">
      <argument name="mode" value="ascii" />
      <argument name="renPublic" value="false" />
    </protection>
    <protection id="resources">
      <argument name="mode" value="normal" />
    </protection>
  </rule>


Expected behavior
The property to behave the same way as it is unobfuscated.

Screenshots
N/A

File (optional)
N/A

Additional context
If I add Trace.WriteLine methods to the property getter, the problem goes away, as well as using ObfuscationAttribute on it to exclude it from obfuscation. I'm happy to help with debugging this but I've spent 2 days so far on this not really knowing where to even look really. The decompiled method looks like it's a funky switch that jumps around and eventually calls <Module>.something<string>(number) with two different numbers, so it vaguely looks like my original code. I didn't prove this due to the extreme difficulty in debugging (even with anti debug off and looking at the x64 disassembly, so in a way ConfuserEx works great :) ) but the only plausible explanation for me seems that these decryptor(?) methods are the ones returning null.

Cannot run in other computer but running fine in my computer.

Describe the bug
Cant run in other computer ( trying on 4 computer ) , Iam using gui version. But running fine in my computer ( no issue ). No error and nothing, just error.

searching on other issue. #10 , but where is to disable TypeScrambler in GUI version? I cant find it.

thanks you

Random String from project is set to a field

How to reproduce this?

  1. Make a c# dll with public class and public static method Load with parameter string
  2. Make another c# internal class with method Start that assigns some random values to 3 fields
  3. Make a field of type string internal named Hash
  4. Make another c# internal class and put there internal field named Hash and internal method Init
  5. put another method inside of the Load method and in that method make new instance of both classes and assign the parameter to field hash
  6. in the Init method pop message box with value of that field
  7. Put [Obfuscation(Exclude = true)] on Load method
  8. Obfuscate code with:
  • Rename
  • Control Flow
  • Constants
  • Ref proxy
  • Anti Ildasm and Resources and enable inherit protections
  1. Call the load method using Mono and put random string as parameter
  2. the messagebox will popup as random string from the code not what you put as parameter and the popped message will change if you delete any of the obfuscations.

dnlib.DotNet.TypeResolveException: Could not resolve type: Java.Interop.IJavaPeerable

This may not be a bug but a fail on my part, but i can't seem to figure it out.
ConfuserEx is throwing an exception dnlib.DotNet.TypeResolveException: Could not resolve type: Java.Interop.IJavaPeerable`.

For context, i'm trying to obfuscate the DLL generated by a Mono.Android project. I've added probe paths to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0 and C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v7.1.

My project references I've made sure my project references Java.Interop to see if thats the issue but it hasn't changed anything.

Debug ouput from ConfuserEx:

[INFO] ConfuserEx v1.0.0 Copyright (C) Ki 2014
3>   [INFO] Running on Microsoft Windows NT 6.2.9200.0, .NET Framework v4.0.30319.42000, 64 bits
3>  [DEBUG] Discovering plugins...
3>   [INFO] Discovered 10 protections, 1 packers.
3>  [DEBUG] Resolving component dependency...
3>   [INFO] Loading input modules...
3>   [INFO] Loading 'C:\Users\ssmith\Documents\GitRepos\pokerplus\Airdice\AirdiceGame\bin\Release\DroidBaseGL.dll '...
3>   [INFO] Initializing...
3>  [DEBUG] Building pipeline...
3>   [INFO] Resolving dependencies...
3>  [DEBUG] Checking Strong Name...
3>  [DEBUG] Creating global .cctors...
3>  [DEBUG] Watermarking...
3>  [DEBUG] Executing 'Name analysis' phase...
3>  [DEBUG] Building VTables & identifier list...
3>  [ERROR] Failed to resolve a type, check if all dependencies are present in the correct version.
3>  Exception: dnlib.DotNet.TypeResolveException: Could not resolve type: Java.Interop.IJavaPeerable (Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065)
3>     at dnlib.DotNet.TypeRef.ResolveThrow(ModuleDef sourceModule) in E:\Source\Public\Confuser2\dnlib\src\DotNet\TypeRef.cs:line 333
3>     at Confuser.Renamer.VTableStorage.GetVTable(ITypeDefOrRef type) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 342
3>     at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 155
3>     at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 332
3>     at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 146
3>     at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 332
3>     at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 146
3>     at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 332
3>     at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 146
3>     at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 332
3>     at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 146
3>     at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 332
3>     at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 146
3>     at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 332
3>     at Confuser.Renamer.VTable.ConstructVTable(TypeDef typeDef, VTableStorage storage) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 146
3>     at Confuser.Renamer.VTableStorage.GetOrConstruct(TypeDef type) in e:\Source\Public\Confuser2\Confuser.Renamer\VTable.cs:line 332
3>     at Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters) in e:\Source\Public\Confuser2\Confuser.Renamer\AnalyzePhase.cs:line 46
3>     at Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action`1 func, Func`1 targets, ConfuserContext context) in e:\Source\Public\Confuser2\Confuser.Core\ProtectionPipeline.cs:line 139
3>     at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) in e:\Source\Public\Confuser2\Confuser.Core\ConfuserEngine.cs:line 221
3>     at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in e:\Source\Public\Confuser2\Confuser.Core\ConfuserEngine.cs:line 175
3>  [ERROR] ---BEGIN DEBUG INFO---
3>  [ERROR] Installed Framework Versions:
3>  [ERROR]     v2.0.50727  2.0.50727.4927
3>  [ERROR]     v3.0  3.0.30729.4926
3>  [ERROR]     v3.5  3.5.30729.4926
3>  [ERROR]     v4
3>  [ERROR]     Client  4.7.03056
3>  [ERROR]     Full  4.7.03056
3>  [ERROR]     v4.0
3>  [ERROR]     Client  4.0.0.0
3>  [ERROR]     v4.5 461808
3>  [ERROR] 
3>  [ERROR] Cached assemblies:
3>  [ERROR]     DroidBaseGL, Version=3.1.0.1, Culture=neutral, PublicKeyToken=null (C:\Users\ssmith\Documents\GitRepos\pokerplus\Airdice\AirdiceGame\bin\Release\DroidBaseGL.dll)
3>  [ERROR]         mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
3>  [ERROR]         WexelGL_Droid, Version=1.2.2.31, Culture=neutral, PublicKeyToken=null
3>  [ERROR]         OpenTK, Version=0.9.9.3, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
3>  [ERROR]         MultiGameSDK, Version=3.0.1.2, Culture=neutral, PublicKeyToken=null
3>  [ERROR]         WexelAirdiceLib, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null
3>  [ERROR]         System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]     mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\mscorlib.dll)
3>  [ERROR]     mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\mscorlib.dll)
3>  [ERROR]     Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065 (C:\Users\ssmith\Documents\GitRepos\pokerplus\Airdice\AirdiceGame\bin\Release\Mono.Android.dll)
3>  [ERROR]         mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
3>  [ERROR]         System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
3>  [ERROR]         System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]     WexelGL_Droid, Version=1.2.2.31, Culture=neutral, PublicKeyToken=null (C:\Users\ssmith\Documents\GitRepos\pokerplus\Airdice\AirdiceGame\bin\Release\WexelGL_Droid.dll)
3>  [ERROR]         mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         OpenTK, Version=0.9.9.3, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
3>  [ERROR]         Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
3>  [ERROR]         System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]     OpenTK, Version=0.9.9.3, Culture=neutral, PublicKeyToken=84e04ff9cfb79065 (C:\Users\ssmith\Documents\GitRepos\pokerplus\Airdice\AirdiceGame\bin\Release\OpenTK.dll)
3>  [ERROR]         mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
3>  [ERROR]     MultiGameSDK, Version=3.0.1.2, Culture=neutral, PublicKeyToken=null (C:\Users\ssmith\Documents\GitRepos\pokerplus\Airdice\AirdiceGame\bin\Release\MultiGameSDK.dll)
3>  [ERROR]         mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
3>  [ERROR]         System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
3>  [ERROR]     WexelAirdiceLib, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null (C:\Users\ssmith\Documents\GitRepos\pokerplus\Airdice\AirdiceGame\bin\Release\WexelAirdiceLib.dll)
3>  [ERROR]         mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
3>  [ERROR]         System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]         System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
3>  [ERROR]     System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\System.dll)
3>  [ERROR]         mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes
3>  [ERROR]     System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\System.dll)
3>  [ERROR]         mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes
3>  [ERROR]     System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\System.Core.dll)
3>  [ERROR]         mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes
3>  [ERROR]         System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes
3>  [ERROR]     System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\System.Core.dll)
3>  [ERROR]         mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes
3>  [ERROR]         System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes
3>  Failed at 11:42, 0:01 elapsed.
3>  
3>  Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
3>     at Confuser.Core.ConfuserEngine.PrintEnvironmentInfo(ConfuserContext context) in e:\Source\Public\Confuser2\Confuser.Core\ConfuserEngine.cs:line 525
3>     at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in e:\Source\Public\Confuser2\Confuser.Core\ConfuserEngine.cs:line 183
3>     at System.Threading.Tasks.Task.Execute()
3>     --- End of inner exception stack trace ---
3>     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
3>     at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
3>     at Confuser.CLI.Program.RunProject(ConfuserParameters parameters) in e:\Source\Public\Confuser2\Confuser.CLI\Program.cs:line 128
3>     at Confuser.CLI.Program.Main(String[] args) in e:\Source\Public\Confuser2\Confuser.CLI\Program.cs:line 105

Exception: System.UriFormatException: Invalid URI: The format of the URI could not be determined.

Describe the bug
Encounter this error when trying to protect an exectuable.

To Reproduce
Calling the cli program like this

var psi = new ProcessStartInfo(Path.Combine(Application.StartupPath, "Confuser.CLI.exe")) { Arguments = args, UseShellExecute = false, CreateNoWindow = false }; Process.Start(psi);

the arguments passed are
-o <my outputpath> <filename of file I want to protect
The exact arguments can be seen at the top of the screenshot

Screenshots
image

Encountered the same issue with the non-fork version of confuser too

Decodable rename protection with odd crproj outputs in strange directory.

Describe the bug
When using relative directories for baseDir and OutputDir, odd things happen with how files are written.

To Reproduce
Steps to reproduce the behavior:

  1. Have a configuration similar to:
<project outputDir=".\Licensing" baseDir=".." xmlns="http://confuser.codeplex.com">
  <rule pattern="true" preset="maximum">
    <protection id="rename">
      <argument name="mode" value="decodable" />
    </protection>
  </rule>
  <module path="Demo\DemoWinFormApp\bin\Release\Licensing.GUI.dll" snKey="Core\Licensing.GUI\Licensing.GUI.snk" />
  <module path="Demo\DemoWinFormApp\bin\Release\Licensing.dll" snKey="Core\Licensing\Licensing.snk" />
  <module path="Demo\DemoWinFormApp\bin\Release\DemoLicense.dll" />
  <module path="Demo\DemoWinFormApp\bin\Release\DemoWinFormApp.exe" />
</project>
  1. Run obfuscation using above file. (Config file is at $(SolutionDir)\ConfuserEx\DemoApp.crproj)
  2. Find symbols.map at $(SolutionDir)$(SolutionDirName)

Expected behavior
Expect to find symbols.map either next to crproj file or next to module.

Bug of ctrl flow.

test.zip

There's a very small test.exe (Only a Main method).
Run it will show OK in the console.
Protect it with ctrl flow, the output will run in infinite loop. (If not, protect it again, not 100%)

FileLoadException: Could not load file or assembly

I'm current;y using https://github.com/yck1509/ConfuserEx

I have a program with mostly managed DLL's and one native DLL ( System.Data.SQLite ). I'm using the Packer/Compressor setting to pack all managed DLLs and exe file into a single exe.

I'm deploying the native SQLite dll as a separate binary.

So my file structure looks like:
- packed_file.exe
- System.Data.SQLite.dll

It works fine on Windows 7, Windows 8.1, but on Windows 10 ( Build 10240 ) ( I have just tested on this build of windows 10 on 2 separate laptops ) it gives the following error:

System.IO.FileLoadException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.88.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Data.SQLite, Version=1.0.88.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139'
at ‪‎‍‫‬‎‍‍‍‮‏‪​​‫​‪‪​‭‎​‭‮‪‮.‫‫‭‮‮‬‪‫‍‎‌‮‮‪‌‬‌‭‏​‌‏​‍‌‮()
at -------------‫‌‌‬‎‫‬‫‬‎​‪‌‮‫‎‫‮‪‎‫‎‮()

How can I resolve this issue ? @XenocodeRCE

Databinding to public members with forceren enabled - Allow renaming of XAML/BAML references

Is your feature request related to a problem? Please describe.
If you have XAML Databinding to public members and use ForceRen (because lets assume your project is not a public library so renaming public methods is acceptable) then this will obviously break databinding.

Describe the solution you'd like
I've hacked a solution which extracts all databinding out of the XAML and makes a list of member names. It then adds these names to the list of items to not rename. My solution is very ugly but it works,

This would be great to see added as it allows a high level of obfuscation such as:

      <protection id="rename">
        <argument name="mode" value="decodable" />
        <argument name="renPublic" value="true" />
		<argument name="flatten" value="true" />
      </protection>

But it also doesn't break XAML databinding. I have a very large project and this approach hasn't failed so far.

To do this properly you would rename the XAML however where I hacked my solution in it seemed like quite a bit of work to make it also rename the XAML, instead I just disabled renaming of these members instead.

here is my function which extracts databinding from .cs files

`private void ExtractBinding(MethodDef methodDef, List<IBaseRef> dynBindings)
{
	if (methodDef == null) return;

	if (!methodDef.HasBody) return;
	if (methodDef.Body?.Instructions == null) return;

	Instruction inst0, inst1, inst2, inst3, inst4, inst5;
	for (var index = 3; index < methodDef.Body.Instructions.Count; index++)
	{
		inst0 = methodDef.Body.Instructions[index - 3];
		inst1 = methodDef.Body.Instructions[index - 2];
		inst2 = methodDef.Body.Instructions[index - 1];
		inst3 = methodDef.Body.Instructions[index];

		//Check if we are using reflection to make a dynamic binding -
		if (inst0.ToString().Contains("ldstr") && inst1.ToString().Contains("ldnull") &&
			inst2.ToString().Contains("ldtoken") && inst3.ToString().Contains("GetTypeFromHandle"))
		{
			//var fullName = inst2.Operand.ToString() + inst0.Operand.ToString();
			var dyn = new MethodRef
			{
				Name = inst0.Operand.ToString(),
				ClassFullName = inst2.Operand.ToString(),
			};
			lock(_lock) dynBindings.Add(dyn);
		}


		//Check if we are using reflection to make a dynamic binding
		if (inst0.ToString().Contains("ldstr") && inst1.ToString().Contains("ldc.i4.1") &&
			inst2.ToString().Contains("newarr") && inst2.ToString().Contains("newarr System.Type") &&
			inst3.ToString().Contains("dup"))
		{
			//var fullName = inst2.Operand.ToString() + inst0.Operand.ToString();
			var dyn = new MethodRef
			{
				Name = inst0.Operand.ToString(),
				ClassFullName = inst2.Operand.ToString(),
			};
			lock(_lock) dynBindings.Add(dyn);
		}
	}
}`

here is my code which extracts a list of databinding elements from BAML

`        public List<IBaseRef> Analyze(ModuleDefMD module, string CurrentBAMLName, byte[] data)
        {
            var dynBindings = new List<IBaseRef>();
            Debug.Assert(BitConverter.ToInt32(data, 0) == data.Length - 4);

            BamlDocument document = BamlReader.ReadDocument(new MemoryStream(data, 4, data.Length - 4));

            foreach (BamlRecord item in document)
            {
                var txt = item as StringInfoRecord;
                if (txt != null)
                {
                    dynBindings.Add(new GlobalRef{Name = txt.Value} );
                    continue;
                }

                var txt2 = item as TextRecord;
                if (txt2 != null)
                {
                    dynBindings.Add(new GlobalRef { Name = txt2.Value });
                    dynBindings.Add(new GlobalRef { Name = txt2.Value.Replace("Command", "") });
                    continue;
                }

                var txt3 = item as PropertyWithConverterRecord;
                if (txt3 != null)
                {
                    dynBindings.Add(new GlobalRef { Name = txt3.Value });
                    continue;
                }

            }
            return dynBindings;
        }

The ObfuscationAttribute is not respected as it is respected by other obfuscators

The ObfuscationAttribute should be respected as it is respected by other obfuscators like Babel or Obfuscar.

If a class is tagged with [Obfuscation] the following items should not be renamed:

  • the class itself
  • the members of the class.

At the moment it seems as if ApplyToMembers is ignored. The default value of ApplyToMembers is true!

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.