XenocodeRCE / neo-ConfuserEx

Updated ConfuserEX, an open-source, free obfuscator for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
751 stars 88 forks source link

Unknown error in dnlib, while Encrypting resources #12

Closed kirsan31 closed 5 years ago

kirsan31 commented 6 years ago

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 https://github.com/XenocodeRCE/neo-ConfuserEx/issues/12#issuecomment-412798754

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, Action`1 func, Func`1 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.
XenocodeRCE commented 6 years ago

@kirsan31 can you share sample file ? I cannot reproduce the issue

kirsan31 commented 6 years ago

@XenocodeRCE I have several app and only with one of them have this problem. I will try to compile test binary to reproduce this...

kirsan31 commented 6 years ago

Did it: tst.zip image

You need to press "protect" button until error will happen (in my case it from 1 to 8 protections). And yes, even if protection complete well from 1 run, the confused app will crush with this error in event log:

error: Application: tst.exe Framework Version: v4.0.30319 Description: The application requested process termination through System.Environment.FailFast(string message). Message: Stack: at System.Environment.FailFast(System.String) at .‍‏‬‏‫‍‪‍‫‬‎‌‮‪​‌‍‪‪‎‫‫‮(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart(System.Object)

So, it's 2 bugs in 1?

kirsan31 commented 6 years ago

@XenocodeRCE Any news?

matthias-hoste commented 5 years ago

Any news/progress on this?