From 29663c1e090cc4695dd05aa26a637bf5264c5d5f Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Fri, 16 Dec 2022 15:39:13 +0200 Subject: [PATCH 01/55] Update ProtectionContext.cs --- src/BitMono.API/Protecting/Contexts/ProtectionContext.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/BitMono.API/Protecting/Contexts/ProtectionContext.cs b/src/BitMono.API/Protecting/Contexts/ProtectionContext.cs index 46947d8b..acc5b855 100644 --- a/src/BitMono.API/Protecting/Contexts/ProtectionContext.cs +++ b/src/BitMono.API/Protecting/Contexts/ProtectionContext.cs @@ -13,10 +13,4 @@ public class ProtectionContext [AllowNull] public ModuleContext ModuleContext => ModuleCreationOptions.Context; [AllowNull] public AssemblyResolver AssemblyResolver => (AssemblyResolver)ModuleContext.AssemblyResolver; - - public void ReloadModule() - { - ModuleDefMD = ModuleDefMD.Load(ModuleDefMDOutput); - Importer = new Importer(ModuleDefMD); - } } \ No newline at end of file From 170a5986a4d23de251dc6c9e65f623b2829cdb55 Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Fri, 16 Dec 2022 15:39:16 +0200 Subject: [PATCH 02/55] Update BitMonoEngine.cs --- src/BitMono.Obfuscation/BitMonoEngine.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BitMono.Obfuscation/BitMonoEngine.cs b/src/BitMono.Obfuscation/BitMonoEngine.cs index ba7fcd46..2340d88f 100644 --- a/src/BitMono.Obfuscation/BitMonoEngine.cs +++ b/src/BitMono.Obfuscation/BitMonoEngine.cs @@ -28,7 +28,7 @@ public BitMonoEngine( m_Logger = logger.ForContext(); } - public async Task ObfuscateAsync(BitMonoContext context, IModuleCreator moduleCreator, CancellationTokenSource cancellationTokenSource = default) + public async Task ObfuscateAsync(BitMonoContext context, IModuleCreator moduleCreator, CancellationTokenSource cancellationTokenSource) { cancellationTokenSource.Token.ThrowIfCancellationRequested(); @@ -71,11 +71,11 @@ public async Task ObfuscateAsync(BitMonoContext context, IModuleCreator moduleCr .StartAsync(cancellationTokenSource); m_Logger.Information("Protected module`s saved in {0}", context.OutputDirectoryName); } - public async Task ObfuscateAsync(BitMonoContext context, byte[] data, CancellationTokenSource cancellationTokenSource = default) + public async Task ObfuscateAsync(BitMonoContext context, byte[] data, CancellationTokenSource cancellationTokenSource) { await ObfuscateAsync(context, new ModuleCreator(data), cancellationTokenSource); } - public async Task ObfuscateAsync(BitMonoContext context, string fileName, CancellationTokenSource cancellationTokenSource = default) + public async Task ObfuscateAsync(BitMonoContext context, string fileName, CancellationTokenSource cancellationTokenSource) { await ObfuscateAsync(context, new ModuleCreator(File.ReadAllBytes(fileName)), cancellationTokenSource); } From f354dbc66b0ff9b06aba293a5f219159c96b736c Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Fri, 16 Dec 2022 15:39:18 +0200 Subject: [PATCH 03/55] Update GlobalUsings.cs --- src/BitMono.Obfuscation.API/GlobalUsings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BitMono.Obfuscation.API/GlobalUsings.cs b/src/BitMono.Obfuscation.API/GlobalUsings.cs index 8f25f739..17f5777b 100644 --- a/src/BitMono.Obfuscation.API/GlobalUsings.cs +++ b/src/BitMono.Obfuscation.API/GlobalUsings.cs @@ -1,3 +1,3 @@ global using dnlib.DotNet; global using dnlib.DotNet.Writer; -global using System.Collections.Generic; +global using System.Collections.Generic; \ No newline at end of file From e813255d1369acfae66d96df293efb6bf4372208 Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Fri, 16 Dec 2022 15:39:34 +0200 Subject: [PATCH 04/55] Update Program.cs --- src/BitMono.CLI/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BitMono.CLI/Program.cs b/src/BitMono.CLI/Program.cs index de174d43..a9d6b5b0 100644 --- a/src/BitMono.CLI/Program.cs +++ b/src/BitMono.CLI/Program.cs @@ -83,7 +83,7 @@ private static async Task Main(string[] args) } new TipsNotifier(appSettingsConfiguration, logger).Notify(); - //await serviceProvider.DisposeAsync(); + await serviceProvider.DisposeAsync(); } catch (Exception ex) { From 52aae14cac09b6fa0bc55fe961c7ffb77992b2c7 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 00:28:12 +0200 Subject: [PATCH 05/55] Update HandlerLogEventSink.cs --- src/BitMono.GUI/Data/HandlerLogEventSink.cs | 39 +++++++++------------ 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/BitMono.GUI/Data/HandlerLogEventSink.cs b/src/BitMono.GUI/Data/HandlerLogEventSink.cs index f8840ca7..92e1d6e5 100644 --- a/src/BitMono.GUI/Data/HandlerLogEventSink.cs +++ b/src/BitMono.GUI/Data/HandlerLogEventSink.cs @@ -1,31 +1,24 @@ -using Serilog.Core; -using Serilog.Events; -using Serilog.Formatting; -using Serilog.Formatting.Display; -using System.Collections.Concurrent; +namespace BitMono.GUI.Data; -namespace BitMono.GUI.Data +internal class HandlerLogEventSink : ILogEventSink { - internal class HandlerLogEventSink : ILogEventSink - { - public event Action OnEnqueued; - private readonly ITextFormatter m_TextFormatter; + public event Action OnEnqueued; + private readonly ITextFormatter m_TextFormatter; - public HandlerLogEventSink() - { - m_TextFormatter = new MessageTemplateTextFormatter("{Timestamp} [{Level}] {Message}{Exception}"); - Queue = new ConcurrentQueue(); - } + public HandlerLogEventSink() + { + m_TextFormatter = new MessageTemplateTextFormatter("{Timestamp} [{Level}] {Message}{Exception}"); + Queue = new ConcurrentQueue(); + } - public ConcurrentQueue Queue { get; } + public ConcurrentQueue Queue { get; } - void ILogEventSink.Emit(LogEvent logEvent) - { - var renderSpace = new StringWriter(); - m_TextFormatter.Format(logEvent, renderSpace); - Queue.Enqueue(renderSpace.ToString()); - OnEnqueued?.Invoke(); - } + void ILogEventSink.Emit(LogEvent logEvent) + { + var renderSpace = new StringWriter(); + m_TextFormatter.Format(logEvent, renderSpace); + Queue.Enqueue(renderSpace.ToString()); + OnEnqueued?.Invoke(); } } \ No newline at end of file From 927fdb877e2b5acaa61b77b9663beade7e6adca7 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 00:28:15 +0200 Subject: [PATCH 06/55] Update StoringProtections.cs --- src/BitMono.GUI/Data/StoringProtections.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/BitMono.GUI/Data/StoringProtections.cs b/src/BitMono.GUI/Data/StoringProtections.cs index c347cf37..e47e4b5c 100644 --- a/src/BitMono.GUI/Data/StoringProtections.cs +++ b/src/BitMono.GUI/Data/StoringProtections.cs @@ -1,18 +1,11 @@ -using BitMono.API.Configuration; -using BitMono.Core.Extensions.Configuration; -using BitMono.GUI.API; -using BitMono.Shared.Models; -using Microsoft.Extensions.Configuration; +namespace BitMono.GUI.Data; -namespace BitMono.GUI.Data +internal class StoringProtections : IStoringProtections { - internal class StoringProtections : IStoringProtections + public StoringProtections(IBitMonoProtectionsConfiguration configuration) { - public StoringProtections(IBitMonoProtectionsConfiguration configuration) - { - Protections = configuration.GetProtectionSettings(); - } - - public List Protections { get; } + Protections = configuration.GetProtectionSettings(); } + + public List Protections { get; } } \ No newline at end of file From 1b08c9a84d27ec0b5362212a9de7ac002132b792 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 00:28:19 +0200 Subject: [PATCH 07/55] Update GlobalUsings.cs --- src/BitMono.GUI/GlobalUsings.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/BitMono.GUI/GlobalUsings.cs b/src/BitMono.GUI/GlobalUsings.cs index cd4e97bc..e120bf2d 100644 --- a/src/BitMono.GUI/GlobalUsings.cs +++ b/src/BitMono.GUI/GlobalUsings.cs @@ -1,14 +1,29 @@ -global using BitMono.API.Configuration; +global using Autofac; +global using Autofac.Extensions.DependencyInjection; +global using BitMono.API.Configuration; global using BitMono.API.Protecting; global using BitMono.API.Protecting.Resolvers; global using BitMono.API.Protecting.Writers; +global using BitMono.Core.Extensions.Configuration; global using BitMono.GUI.API; +global using BitMono.GUI.Data; global using BitMono.GUI.Modules; global using BitMono.GUI.Shared.Alerting; global using BitMono.GUI.Shared.Inputs; +global using BitMono.GUI.Utilities.Extensions; +global using BitMono.Host.Modules; global using BitMono.Obfuscation; +global using BitMono.Shared.Models; global using dnlib.DotNet; global using Microsoft.AspNetCore.Components; global using Microsoft.AspNetCore.Components.Forms; +global using Microsoft.JSInterop; global using Serilog; +global using Serilog.Core; +global using Serilog.Events; +global using Serilog.Formatting; +global using Serilog.Formatting.Display; +global using System.Collections.Concurrent; +global using System.Reflection; +global using static BitMono.Utilities.Extensions.Collections.CollectionExtensions; global using ILogger = Serilog.ILogger; \ No newline at end of file From 7e1d13c82afbe831ee7d11dcc11ea6b700096c2a Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 00:28:22 +0200 Subject: [PATCH 08/55] Update MauiProgram.cs --- src/BitMono.GUI/MauiProgram.cs | 66 +++++++++++++++------------------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/src/BitMono.GUI/MauiProgram.cs b/src/BitMono.GUI/MauiProgram.cs index f814e929..e099b59c 100644 --- a/src/BitMono.GUI/MauiProgram.cs +++ b/src/BitMono.GUI/MauiProgram.cs @@ -1,51 +1,41 @@ -using Autofac; -using Autofac.Extensions.DependencyInjection; -using BitMono.GUI.API; -using BitMono.GUI.Data; -using BitMono.GUI.Shared.Alerting; -using BitMono.Host.Modules; -using Serilog; -using System.Reflection; +namespace BitMono.GUI; -namespace BitMono.GUI +public static class MauiProgram { - public static class MauiProgram + public static MauiApp CreateMauiApp() { - public static MauiApp CreateMauiApp() - { - var builder = MauiApp.CreateBuilder(); - builder - .UseMauiApp() - .ConfigureFonts(fonts => - { - fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); - }); + var builder = MauiApp.CreateBuilder(); + builder + .UseMauiApp() + .ConfigureFonts(fonts => + { + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + }); - builder.Services.AddMauiBlazorWebView(); + builder.Services.AddMauiBlazorWebView(); #if DEBUG - builder.Services.AddBlazorWebViewDeveloperTools(); + builder.Services.AddBlazorWebViewDeveloperTools(); #endif #if WINDOWS - builder.Services.AddTransient(); + builder.Services.AddTransient(); #endif - builder.Services.AddScoped(); - builder.Services.AddSingleton(); - var handlerLogEventSink = new HandlerLogEventSink(); - builder.Services.AddSingleton(handlerLogEventSink); + builder.Services.AddScoped(); + builder.Services.AddSingleton(); + var handlerLogEventSink = new HandlerLogEventSink(); + builder.Services.AddSingleton(handlerLogEventSink); - const string ProtectionsFile = "BitMono.Protections.dll"; - Assembly.LoadFrom(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ProtectionsFile)); - builder.ConfigureContainer(new AutofacServiceProviderFactory(), configure => + const string ProtectionsFile = "BitMono.Protections.dll"; + Assembly.LoadFrom(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ProtectionsFile)); + builder.ConfigureContainer(new AutofacServiceProviderFactory(), configure => + { + configure.RegisterModule(new BitMonoModule(configureLogger => { - configure.RegisterModule(new BitMonoModule(configureLogger => + configureLogger.WriteTo.Async(configure => { - configureLogger.WriteTo.Async(configure => - { - configure.Sink(handlerLogEventSink); - }); - })); - }); - return builder.Build(); - } + configure.Sink(handlerLogEventSink); + }); + })); + }); + return builder.Build(); } } \ No newline at end of file From 6982f91626de06a7a80fd38b53ca1db875c74403 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 00:28:25 +0200 Subject: [PATCH 09/55] Update Protections.razor.cs --- .../Pages/Obfuscation/Protections.razor.cs | 65 ++++++++----------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/src/BitMono.GUI/Pages/Obfuscation/Protections.razor.cs b/src/BitMono.GUI/Pages/Obfuscation/Protections.razor.cs index 983936cf..343a4cbc 100644 --- a/src/BitMono.GUI/Pages/Obfuscation/Protections.razor.cs +++ b/src/BitMono.GUI/Pages/Obfuscation/Protections.razor.cs @@ -1,48 +1,39 @@ -using BitMono.API.Protecting; -using BitMono.GUI.API; -using BitMono.GUI.Utilities.Extensions; -using BitMono.Shared.Models; -using Microsoft.AspNetCore.Components; -using Microsoft.JSInterop; -using static BitMono.Utilities.Extensions.Collections.CollectionExtensions; +namespace BitMono.GUI.Pages.Obfuscation; -namespace BitMono.GUI.Pages.Obfuscation +public partial class Protections { - public partial class Protections - { - [Inject] public IJSRuntime JSRuntime { get; set; } - [Inject] public ICollection RegisteredProtections { get; set; } - [Inject] public IStoringProtections StoringProtections { get; set; } + [Inject] public IJSRuntime JSRuntime { get; set; } + [Inject] public ICollection RegisteredProtections { get; set; } + [Inject] public IStoringProtections StoringProtections { get; set; } - protected override async Task OnAfterRenderAsync(bool firstRender) - { - await JSRuntime.AddTooltipsAsync(); - } + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await JSRuntime.AddTooltipsAsync(); + } - public void EnableAll() - { - foreach (var protectionSettings in StoringProtections.Protections) - { - protectionSettings.Enable(); - } - } - public void DisableAll() - { - foreach (var protectionSettings in StoringProtections.Protections) - { - protectionSettings.Disable(); - } - } - public void MoveUp(ProtectionSettings protectionSetting) + public void EnableAll() + { + foreach (var protectionSettings in StoringProtections.Protections) { - var index = StoringProtections.Protections.IndexOf(protectionSetting); - StoringProtections.Protections.Swap(index, index - 1); + protectionSettings.Enable(); } - public void MoveDown(ProtectionSettings protectionSetting) + } + public void DisableAll() + { + foreach (var protectionSettings in StoringProtections.Protections) { - var index = StoringProtections.Protections.IndexOf(protectionSetting); - StoringProtections.Protections.Swap(index, index + 1); + protectionSettings.Disable(); } } + public void MoveUp(ProtectionSettings protectionSetting) + { + var index = StoringProtections.Protections.IndexOf(protectionSetting); + StoringProtections.Protections.Swap(index, index - 1); + } + public void MoveDown(ProtectionSettings protectionSetting) + { + var index = StoringProtections.Protections.IndexOf(protectionSetting); + StoringProtections.Protections.Swap(index, index + 1); + } } \ No newline at end of file From 05f301342e167f4e3f0e82532c7b95d4868d4628 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 00:28:28 +0200 Subject: [PATCH 10/55] Update Alerts.cs --- src/BitMono.GUI/Shared/Alerting/Alerts.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/BitMono.GUI/Shared/Alerting/Alerts.cs b/src/BitMono.GUI/Shared/Alerting/Alerts.cs index f02b23e1..8386fab8 100644 --- a/src/BitMono.GUI/Shared/Alerting/Alerts.cs +++ b/src/BitMono.GUI/Shared/Alerting/Alerts.cs @@ -1,11 +1,10 @@ -namespace BitMono.GUI.Shared.Alerting +namespace BitMono.GUI.Shared.Alerting; + +public enum Alerts { - public enum Alerts - { - Primary, - Danger, - Warning, - Success, - Info - } + Primary, + Danger, + Warning, + Success, + Info } \ No newline at end of file From 9ebeef340e98538647774fa7d8e5830a1781501d Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 00:28:30 +0200 Subject: [PATCH 11/55] Update BitMono.Unturned-RocketMod-Crackme.csproj --- .../BitMono.Unturned-RocketMod-Crackme.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/BitMono.Unturned-RocketMod-Crackme/BitMono.Unturned-RocketMod-Crackme.csproj b/src/BitMono.Unturned-RocketMod-Crackme/BitMono.Unturned-RocketMod-Crackme.csproj index 6be03024..f1b135ec 100644 --- a/src/BitMono.Unturned-RocketMod-Crackme/BitMono.Unturned-RocketMod-Crackme.csproj +++ b/src/BitMono.Unturned-RocketMod-Crackme/BitMono.Unturned-RocketMod-Crackme.csproj @@ -3,8 +3,7 @@ net48 BitMono.Unturned_RocketMod_Crackme - disable - disable + 10.0 From 4eeb65dc92dfd5a13591a3706d7727d96da1fe92 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 00:28:34 +0200 Subject: [PATCH 12/55] Create GlobalUsings.cs --- src/BitMono.Unturned-RocketMod-Crackme/GlobalUsings.cs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/BitMono.Unturned-RocketMod-Crackme/GlobalUsings.cs diff --git a/src/BitMono.Unturned-RocketMod-Crackme/GlobalUsings.cs b/src/BitMono.Unturned-RocketMod-Crackme/GlobalUsings.cs new file mode 100644 index 00000000..f927056f --- /dev/null +++ b/src/BitMono.Unturned-RocketMod-Crackme/GlobalUsings.cs @@ -0,0 +1,2 @@ +global using Rocket.Core.Plugins; +global using System; \ No newline at end of file From aca3e89f8f64d8982eb5deb5e9f116fdf8b92c3e Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 00:28:36 +0200 Subject: [PATCH 13/55] Update Plugin.cs --- .../Plugin.cs | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/BitMono.Unturned-RocketMod-Crackme/Plugin.cs b/src/BitMono.Unturned-RocketMod-Crackme/Plugin.cs index 40d572e0..deb69c09 100644 --- a/src/BitMono.Unturned-RocketMod-Crackme/Plugin.cs +++ b/src/BitMono.Unturned-RocketMod-Crackme/Plugin.cs @@ -1,19 +1,15 @@ -using Rocket.Core.Plugins; -using System; +namespace BitMono.Unturned_RocketMod_Crackme; -namespace BitMono.Unturned_RocketMod_Crackme +public class Plugin : RocketPlugin { - public class Plugin : RocketPlugin + protected override void Load() { - protected override void Load() - { - Console.WriteLine("CW: Hello world"); - Log("Hello world"); - } + Console.WriteLine("CW: Hello world"); + Log("Hello world"); + } - public static void Log(string message) - { - Rocket.Core.Logging.Logger.LogWarning("Log: " + message); - } + public static void Log(string message) + { + Rocket.Core.Logging.Logger.LogWarning("Log: " + message); } } \ No newline at end of file From 5d5d7e4f1c0eb31681e990f2ac8ee4676f88d91e Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:28 +0200 Subject: [PATCH 14/55] Delete IFieldRemover.cs --- .../Protecting/Injection/FieldDefs/IFieldRemover.cs | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 src/BitMono.API/Protecting/Injection/FieldDefs/IFieldRemover.cs diff --git a/src/BitMono.API/Protecting/Injection/FieldDefs/IFieldRemover.cs b/src/BitMono.API/Protecting/Injection/FieldDefs/IFieldRemover.cs deleted file mode 100644 index d9cebe97..00000000 --- a/src/BitMono.API/Protecting/Injection/FieldDefs/IFieldRemover.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BitMono.API.Protecting.Injection.FieldDefs; - -public interface IFieldRemover -{ - bool Remove(string name, ModuleDefMD moduleDefMD); -} \ No newline at end of file From 59ffe0ec62e6599215e4e864d5500eab38418e02 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:30 +0200 Subject: [PATCH 15/55] Delete IMethodDefRemover.cs --- .../Protecting/Injection/MethodDefs/IMethodDefRemover.cs | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/BitMono.API/Protecting/Injection/MethodDefs/IMethodDefRemover.cs diff --git a/src/BitMono.API/Protecting/Injection/MethodDefs/IMethodDefRemover.cs b/src/BitMono.API/Protecting/Injection/MethodDefs/IMethodDefRemover.cs deleted file mode 100644 index b31ab293..00000000 --- a/src/BitMono.API/Protecting/Injection/MethodDefs/IMethodDefRemover.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace BitMono.API.Protecting.Injection.MethodDefs; - -public interface IMethodDefRemover -{ - bool Remove(ModuleDefMD moduleDefMD, string name); - bool Remove(TypeDef typeDef, string name); -} \ No newline at end of file From dd061e078db191593873abc9107e0c01ab0a58ad Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:32 +0200 Subject: [PATCH 16/55] Delete IFieldSearcher.cs --- .../Protecting/Injection/FieldDefs/IFieldSearcher.cs | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/BitMono.API/Protecting/Injection/FieldDefs/IFieldSearcher.cs diff --git a/src/BitMono.API/Protecting/Injection/FieldDefs/IFieldSearcher.cs b/src/BitMono.API/Protecting/Injection/FieldDefs/IFieldSearcher.cs deleted file mode 100644 index 291b67e0..00000000 --- a/src/BitMono.API/Protecting/Injection/FieldDefs/IFieldSearcher.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace BitMono.API.Protecting.Injection.FieldDefs; - -public interface IFieldSearcher -{ - FieldDef Find(string name, ModuleDefMD moduleDefMD); - FieldDef FindInGlobalNestedTypes(string name, ModuleDefMD moduleDefMD); -} \ No newline at end of file From a9835487c8c16b6c46e36379f0f102ffb9ffe30f Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:33 +0200 Subject: [PATCH 17/55] Delete IMethodDefSearcher.cs --- .../Protecting/Injection/MethodDefs/IMethodDefSearcher.cs | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 src/BitMono.API/Protecting/Injection/MethodDefs/IMethodDefSearcher.cs diff --git a/src/BitMono.API/Protecting/Injection/MethodDefs/IMethodDefSearcher.cs b/src/BitMono.API/Protecting/Injection/MethodDefs/IMethodDefSearcher.cs deleted file mode 100644 index d40e00da..00000000 --- a/src/BitMono.API/Protecting/Injection/MethodDefs/IMethodDefSearcher.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BitMono.API.Protecting.Injection.MethodDefs; - -public interface IMethodDefSearcher -{ - MethodDef Find(string name, ModuleDefMD moduleDefMD); -} \ No newline at end of file From c0b9c6f93357198ae7efff83371fe3d03f1ed849 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:36 +0200 Subject: [PATCH 18/55] Delete ITypeDefRemover.cs --- .../Protecting/Injection/TypeDefs/ITypeDefRemover.cs | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 src/BitMono.API/Protecting/Injection/TypeDefs/ITypeDefRemover.cs diff --git a/src/BitMono.API/Protecting/Injection/TypeDefs/ITypeDefRemover.cs b/src/BitMono.API/Protecting/Injection/TypeDefs/ITypeDefRemover.cs deleted file mode 100644 index 76801863..00000000 --- a/src/BitMono.API/Protecting/Injection/TypeDefs/ITypeDefRemover.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BitMono.API.Protecting.Injection.TypeDefs; - -public interface ITypeDefRemover -{ - bool Remove(string name, ModuleDefMD moduleDefMD); -} \ No newline at end of file From f115b502f978746c0b48fcef33793708682fdcd7 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:38 +0200 Subject: [PATCH 19/55] Delete ITypeDefSearcher.cs --- .../Protecting/Injection/TypeDefs/ITypeDefSearcher.cs | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/BitMono.API/Protecting/Injection/TypeDefs/ITypeDefSearcher.cs diff --git a/src/BitMono.API/Protecting/Injection/TypeDefs/ITypeDefSearcher.cs b/src/BitMono.API/Protecting/Injection/TypeDefs/ITypeDefSearcher.cs deleted file mode 100644 index 4a36682a..00000000 --- a/src/BitMono.API/Protecting/Injection/TypeDefs/ITypeDefSearcher.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace BitMono.API.Protecting.Injection.TypeDefs; - -public interface ITypeDefSearcher -{ - TypeDef Find(string name, ModuleDefMD moduleDefMD); - TypeDef FindInGlobalNestedTypes(string name, ModuleDefMD moduleDefMD); -} \ No newline at end of file From b16f65ea2e66c54b4dae1ce9a5523d5fb2138cad Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:39 +0200 Subject: [PATCH 20/55] Delete IDataWriter.cs --- src/BitMono.API/Protecting/Writers/IDataWriter.cs | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 src/BitMono.API/Protecting/Writers/IDataWriter.cs diff --git a/src/BitMono.API/Protecting/Writers/IDataWriter.cs b/src/BitMono.API/Protecting/Writers/IDataWriter.cs deleted file mode 100644 index 7665d338..00000000 --- a/src/BitMono.API/Protecting/Writers/IDataWriter.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BitMono.API.Protecting.Writers; - -public interface IDataWriter -{ - Task WriteAsync(string outputFile, byte[] outputBuffer); -} \ No newline at end of file From aca2d9803307b6a2688063644c0f61ee437197a6 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:41 +0200 Subject: [PATCH 21/55] Update GlobalUsings.cs --- src/BitMono.CLI/GlobalUsings.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/BitMono.CLI/GlobalUsings.cs b/src/BitMono.CLI/GlobalUsings.cs index 41e6ee55..41212bee 100644 --- a/src/BitMono.CLI/GlobalUsings.cs +++ b/src/BitMono.CLI/GlobalUsings.cs @@ -2,14 +2,12 @@ global using BitMono.API.Configuration; global using BitMono.API.Protecting; global using BitMono.API.Protecting.Resolvers; -global using BitMono.API.Protecting.Writers; global using BitMono.CLI.Modules; global using BitMono.Core.Extensions.Configuration; global using BitMono.Host; global using BitMono.Host.Modules; global using BitMono.Obfuscation; global using BitMono.Shared.Models; -global using dnlib.DotNet; global using Microsoft.Extensions.Configuration; global using NullGuard; global using Serilog; From 472199e394bbac97fe30362993451723ce688f4c Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:43 +0200 Subject: [PATCH 22/55] Update CLIDataWriter.cs --- src/BitMono.CLI/Modules/CLIDataWriter.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/BitMono.CLI/Modules/CLIDataWriter.cs b/src/BitMono.CLI/Modules/CLIDataWriter.cs index 2afa49a6..9bb48227 100644 --- a/src/BitMono.CLI/Modules/CLIDataWriter.cs +++ b/src/BitMono.CLI/Modules/CLIDataWriter.cs @@ -1,4 +1,6 @@ -namespace BitMono.CLI.Modules; +using BitMono.Obfuscation.API; + +namespace BitMono.CLI.Modules; internal class CLIDataWriter : IDataWriter { From 108f6c8d5b17975667f7b7551e0896c1e6451c5c Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:45 +0200 Subject: [PATCH 23/55] Update GlobalUsings.cs --- src/BitMono.Core/GlobalUsings.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/BitMono.Core/GlobalUsings.cs b/src/BitMono.Core/GlobalUsings.cs index a5d9d83e..f8a1936c 100644 --- a/src/BitMono.Core/GlobalUsings.cs +++ b/src/BitMono.Core/GlobalUsings.cs @@ -3,9 +3,6 @@ global using BitMono.API.Protecting.Analyzing; global using BitMono.API.Protecting.Contexts; global using BitMono.API.Protecting.Injection; -global using BitMono.API.Protecting.Injection.FieldDefs; -global using BitMono.API.Protecting.Injection.MethodDefs; -global using BitMono.API.Protecting.Injection.TypeDefs; global using BitMono.API.Protecting.Renaming; global using BitMono.API.Protecting.Resolvers; global using BitMono.Core.Extensions.Configuration; @@ -27,7 +24,6 @@ global using System.Reflection; global using System.Runtime.CompilerServices; global using System.Threading; -global using System.Threading.Tasks; global using System.Xml.Serialization; global using FieldAttributes = dnlib.DotNet.FieldAttributes; global using TypeAttributes = dnlib.DotNet.TypeAttributes; From 203aa0477ca019e053930579b44e3de2c86e8d4b Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:47 +0200 Subject: [PATCH 24/55] Create TypeDefAttributeCriticalAnalyzer.cs --- .../TypeDefAttributeCriticalAnalyzer.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/BitMono.Core/Protecting/Analyzing/TypeDefs/TypeDefAttributeCriticalAnalyzer.cs diff --git a/src/BitMono.Core/Protecting/Analyzing/TypeDefs/TypeDefAttributeCriticalAnalyzer.cs b/src/BitMono.Core/Protecting/Analyzing/TypeDefs/TypeDefAttributeCriticalAnalyzer.cs new file mode 100644 index 00000000..ddf90ad9 --- /dev/null +++ b/src/BitMono.Core/Protecting/Analyzing/TypeDefs/TypeDefAttributeCriticalAnalyzer.cs @@ -0,0 +1,32 @@ +namespace BitMono.Core.Protecting.Analyzing.TypeDefs; + +public class TypeDefAttributeCriticalAnalyzer : ICriticalAnalyzer +{ + private readonly IAttemptAttributeResolver m_AttemptAttributeResolver; + + public TypeDefAttributeCriticalAnalyzer(IAttemptAttributeResolver attemptAttributeResolver) + { + m_AttemptAttributeResolver = attemptAttributeResolver; + } + + public bool NotCriticalToMakeChanges(IHasCustomAttribute customAttribute) + { + if (m_AttemptAttributeResolver.TryResolve(customAttribute, null, null, out _)) + { + return false; + } + if (m_AttemptAttributeResolver.TryResolve(customAttribute, null, null, out _)) + { + return false; + } + if (m_AttemptAttributeResolver.TryResolve(customAttribute, null, null, out _)) + { + return false; + } + if (m_AttemptAttributeResolver.TryResolve(customAttribute, null, null, out _)) + { + return false; + } + return false; + } +} \ No newline at end of file From 6dc5ecd4796807e5a107a41215bf6b7be8017428 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:53 +0200 Subject: [PATCH 25/55] Delete TypeDefModelCriticalAnalyzer.cs --- .../TypeDefs/TypeDefModelCriticalAnalyzer.cs | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/BitMono.Core/Protecting/Analyzing/TypeDefs/TypeDefModelCriticalAnalyzer.cs diff --git a/src/BitMono.Core/Protecting/Analyzing/TypeDefs/TypeDefModelCriticalAnalyzer.cs b/src/BitMono.Core/Protecting/Analyzing/TypeDefs/TypeDefModelCriticalAnalyzer.cs deleted file mode 100644 index bdf4813b..00000000 --- a/src/BitMono.Core/Protecting/Analyzing/TypeDefs/TypeDefModelCriticalAnalyzer.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace BitMono.Core.Protecting.Analyzing.TypeDefs; - -public class TypeDefModelCriticalAnalyzer : ICriticalAnalyzer -{ - private readonly IAttemptAttributeResolver m_AttemptAttributeResolver; - - public TypeDefModelCriticalAnalyzer(IAttemptAttributeResolver attemptAttributeResolver) - { - m_AttemptAttributeResolver = attemptAttributeResolver; - } - - public bool NotCriticalToMakeChanges(IHasCustomAttribute from) - { - if (m_AttemptAttributeResolver.TryResolve(from, null, null, out _)) - { - return false; - } - if (m_AttemptAttributeResolver.TryResolve(from, null, null, out _)) - { - return false; - } - if (m_AttemptAttributeResolver.TryResolve(from, null, null, out _)) - { - return false; - } - if (m_AttemptAttributeResolver.TryResolve(from, null, null, out _)) - { - return false; - } - return false; - } -} \ No newline at end of file From 370ac6cd174b5c076f481127bcbb2227637371e9 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:55 +0200 Subject: [PATCH 26/55] Update ProtectionNameAttribute.cs --- .../Protecting/Attributes/ProtectionNameAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BitMono.Core/Protecting/Attributes/ProtectionNameAttribute.cs b/src/BitMono.Core/Protecting/Attributes/ProtectionNameAttribute.cs index 31c534ef..77549cc7 100644 --- a/src/BitMono.Core/Protecting/Attributes/ProtectionNameAttribute.cs +++ b/src/BitMono.Core/Protecting/Attributes/ProtectionNameAttribute.cs @@ -1,6 +1,6 @@ namespace BitMono.Core.Protecting.Attributes; -[AttributeUsage(AttributeTargets.Class)] +[AttributeUsage(AttributeTargets.Class, Inherited = false)] public class ProtectionNameAttribute : Attribute { public ProtectionNameAttribute(string name) From 1b8b33fb2530d7fc6db22aa0c2ee2e57e03ffa99 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:57 +0200 Subject: [PATCH 27/55] Delete FieldDefRemover.cs --- .../Injection/FieldDefs/FieldDefRemover.cs | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 src/BitMono.Core/Protecting/Injection/FieldDefs/FieldDefRemover.cs diff --git a/src/BitMono.Core/Protecting/Injection/FieldDefs/FieldDefRemover.cs b/src/BitMono.Core/Protecting/Injection/FieldDefs/FieldDefRemover.cs deleted file mode 100644 index 8b2ba3de..00000000 --- a/src/BitMono.Core/Protecting/Injection/FieldDefs/FieldDefRemover.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace BitMono.Core.Protecting.Injection.FieldDefs; - -public class FieldDefRemover : IFieldRemover -{ - public bool Remove(string name, ModuleDefMD module) - { - foreach (TypeDef typeDef in module.Types) - { - foreach (var fieldDef in typeDef.Fields) - { - if (fieldDef.Name.Equals(name)) - { - typeDef.Fields.Remove(fieldDef); - return true; - } - } - } - return false; - } -} \ No newline at end of file From 5fe00aa572f76e4b10c40537df0fae5237ae0509 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:39:59 +0200 Subject: [PATCH 28/55] Delete FieldDefSearcher.cs --- .../Injection/FieldDefs/FieldDefSearcher.cs | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 src/BitMono.Core/Protecting/Injection/FieldDefs/FieldDefSearcher.cs diff --git a/src/BitMono.Core/Protecting/Injection/FieldDefs/FieldDefSearcher.cs b/src/BitMono.Core/Protecting/Injection/FieldDefs/FieldDefSearcher.cs deleted file mode 100644 index 43fd83b2..00000000 --- a/src/BitMono.Core/Protecting/Injection/FieldDefs/FieldDefSearcher.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace BitMono.Core.Protecting.Injection.FieldDefs; - -public class FieldDefSearcher : IFieldSearcher -{ - [return: AllowNull] - public FieldDef Find(string name, ModuleDefMD moduleDefMD) - { - foreach (var typeDef in moduleDefMD.Types) - { - foreach (var fieldDef in typeDef.Fields) - { - if (fieldDef.Name.Equals(name)) - { - return fieldDef; - } - } - } - return null; - } - [return: AllowNull] - public FieldDef FindInGlobalNestedTypes(string name, ModuleDefMD moduleDefMD) - { - foreach (var type in moduleDefMD.GlobalType.NestedTypes) - { - if (type.HasFields) - { - foreach (var childField in type.Fields) - { - if (childField.Name.Equals(name)) - { - return childField; - } - } - } - } - return null; - } -} \ No newline at end of file From 6575e06fb4b4f8233959964ef46246ddd0894b84 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:01 +0200 Subject: [PATCH 29/55] Delete MethodDefsRemover.cs --- .../Injection/MethodDefs/MethodDefsRemover.cs | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/BitMono.Core/Protecting/Injection/MethodDefs/MethodDefsRemover.cs diff --git a/src/BitMono.Core/Protecting/Injection/MethodDefs/MethodDefsRemover.cs b/src/BitMono.Core/Protecting/Injection/MethodDefs/MethodDefsRemover.cs deleted file mode 100644 index b4fd70e2..00000000 --- a/src/BitMono.Core/Protecting/Injection/MethodDefs/MethodDefsRemover.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace BitMono.Core.Protecting.Injection.MethodDefs; - -public class MethodDefsRemover : IMethodDefRemover -{ - public bool Remove(ModuleDefMD moduleDefMD, string name) - { - foreach (var typeDef in moduleDefMD.GetTypes().ToArray()) - { - foreach (var methodDef in typeDef.Methods) - { - if (typeDef.Name.Equals(name)) - { - typeDef.Methods.Remove(methodDef); - return true; - } - } - } - return false; - } - public bool Remove(TypeDef typeDef, string name) - { - foreach (var methodDef in typeDef.Methods.ToArray()) - { - if (methodDef.Name.Equals(name)) - { - typeDef.Methods.Remove(methodDef); - return true; - } - } - return false; - } -} \ No newline at end of file From 7310afae32b3bc845c10c29b24ad708849a27913 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:03 +0200 Subject: [PATCH 30/55] Delete MethodDefsSearcher.cs --- .../MethodDefs/MethodDefsSearcher.cs | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 src/BitMono.Core/Protecting/Injection/MethodDefs/MethodDefsSearcher.cs diff --git a/src/BitMono.Core/Protecting/Injection/MethodDefs/MethodDefsSearcher.cs b/src/BitMono.Core/Protecting/Injection/MethodDefs/MethodDefsSearcher.cs deleted file mode 100644 index e3cbe5e3..00000000 --- a/src/BitMono.Core/Protecting/Injection/MethodDefs/MethodDefsSearcher.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace BitMono.Core.Protecting.Injection.MethodDefs; - -public class MethodDefsSearcher : IMethodDefSearcher -{ - [return: AllowNull] - public MethodDef Find(string name, ModuleDefMD moduleDefMD) - { - foreach (var typeDef in moduleDefMD.GetTypes()) - { - foreach (var methodDef in typeDef.Methods) - { - if (methodDef.Name.Equals(name)) - { - return methodDef; - } - } - } - return null; - } -} \ No newline at end of file From e9868276b2340af202c36f339932ca1bf434e6b3 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:06 +0200 Subject: [PATCH 31/55] Delete TypeDefRemover.cs --- .../Injection/TypeDefs/TypeDefRemover.cs | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 src/BitMono.Core/Protecting/Injection/TypeDefs/TypeDefRemover.cs diff --git a/src/BitMono.Core/Protecting/Injection/TypeDefs/TypeDefRemover.cs b/src/BitMono.Core/Protecting/Injection/TypeDefs/TypeDefRemover.cs deleted file mode 100644 index 00d12455..00000000 --- a/src/BitMono.Core/Protecting/Injection/TypeDefs/TypeDefRemover.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace BitMono.Core.Protecting.Injection.TypeDefs; - -public class TypeDefRemover : ITypeDefRemover -{ - public bool Remove(string name, ModuleDefMD module) - { - foreach (var typeDef in module.GetTypes().ToArray()) - { - if (typeDef.Name.Equals(name)) - { - if (typeDef.IsNested) - { - typeDef.NestedTypes.Remove(typeDef); - } - else - { - module.Types.Remove(typeDef); - } - return true; - } - } - return false; - } -} \ No newline at end of file From cd8c4e5103732d124fdd3d65311cace3c59890d8 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:08 +0200 Subject: [PATCH 32/55] Delete TypeDefSearcher.cs --- .../Injection/TypeDefs/TypeDefSearcher.cs | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 src/BitMono.Core/Protecting/Injection/TypeDefs/TypeDefSearcher.cs diff --git a/src/BitMono.Core/Protecting/Injection/TypeDefs/TypeDefSearcher.cs b/src/BitMono.Core/Protecting/Injection/TypeDefs/TypeDefSearcher.cs deleted file mode 100644 index 7c6a2e07..00000000 --- a/src/BitMono.Core/Protecting/Injection/TypeDefs/TypeDefSearcher.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace BitMono.Core.Protecting.Injection.TypeDefs; - -public class TypeDefSearcher : ITypeDefSearcher -{ - [return: AllowNull] - public TypeDef Find(string name, ModuleDefMD moduleDefMD) - { - foreach (var typeDef in moduleDefMD.GetTypes().ToArray()) - { - if (typeDef.Name.Equals(name)) - { - return typeDef; - } - } - return null; - } - [return: AllowNull] - public TypeDef FindInGlobalNestedTypes(string name, ModuleDefMD moduleDefMD) - { - foreach (var typeDef in moduleDefMD.GlobalType.NestedTypes.ToArray()) - { - if (typeDef.Name.Equals(name)) - { - return typeDef; - } - } - return null; - } -} \ No newline at end of file From 7e0a5cd7025afa732a9009ca6badd2dbffdc8122 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:10 +0200 Subject: [PATCH 33/55] Update GlobalUsings.cs --- src/BitMono.GUI/GlobalUsings.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BitMono.GUI/GlobalUsings.cs b/src/BitMono.GUI/GlobalUsings.cs index e120bf2d..cd5b74a5 100644 --- a/src/BitMono.GUI/GlobalUsings.cs +++ b/src/BitMono.GUI/GlobalUsings.cs @@ -3,7 +3,6 @@ global using BitMono.API.Configuration; global using BitMono.API.Protecting; global using BitMono.API.Protecting.Resolvers; -global using BitMono.API.Protecting.Writers; global using BitMono.Core.Extensions.Configuration; global using BitMono.GUI.API; global using BitMono.GUI.Data; From 11cf62d6b5dbfb4dc62068c4f374455cec91d8d8 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:12 +0200 Subject: [PATCH 34/55] Update GUIDataWriter.cs --- src/BitMono.GUI/Modules/GUIDataWriter.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/BitMono.GUI/Modules/GUIDataWriter.cs b/src/BitMono.GUI/Modules/GUIDataWriter.cs index 469b8e5d..855f7c0e 100644 --- a/src/BitMono.GUI/Modules/GUIDataWriter.cs +++ b/src/BitMono.GUI/Modules/GUIDataWriter.cs @@ -1,4 +1,6 @@ -namespace BitMono.GUI.Modules; +using BitMono.Obfuscation.API; + +namespace BitMono.GUI.Modules; internal class GUIDataWriter : IDataWriter { From b0cabb12dd8641be3235fcfc5db6663464641416 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:14 +0200 Subject: [PATCH 35/55] Update GlobalUsings.cs --- src/BitMono.Host/GlobalUsings.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/BitMono.Host/GlobalUsings.cs b/src/BitMono.Host/GlobalUsings.cs index ce39b67e..865a3bd7 100644 --- a/src/BitMono.Host/GlobalUsings.cs +++ b/src/BitMono.Host/GlobalUsings.cs @@ -6,16 +6,10 @@ global using BitMono.API.Protecting; global using BitMono.API.Protecting.Analyzing; global using BitMono.API.Protecting.Injection; -global using BitMono.API.Protecting.Injection.FieldDefs; -global using BitMono.API.Protecting.Injection.MethodDefs; -global using BitMono.API.Protecting.Injection.TypeDefs; global using BitMono.API.Protecting.Pipeline; global using BitMono.API.Protecting.Renaming; global using BitMono.API.Protecting.Resolvers; global using BitMono.Core.Protecting.Injection; -global using BitMono.Core.Protecting.Injection.FieldDefs; -global using BitMono.Core.Protecting.Injection.MethodDefs; -global using BitMono.Core.Protecting.Injection.TypeDefs; global using BitMono.Core.Protecting.Renaming; global using BitMono.Core.Protecting.Resolvers; global using BitMono.Host.Configuration; From 66dabd75f313a4c2e4d1f687bc3c050b25e9c6c3 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:15 +0200 Subject: [PATCH 36/55] Update BitMonoModule.cs --- src/BitMono.Host/Modules/BitMonoModule.cs | 30 ----------------------- 1 file changed, 30 deletions(-) diff --git a/src/BitMono.Host/Modules/BitMonoModule.cs b/src/BitMono.Host/Modules/BitMonoModule.cs index fd5f0f92..1d91145c 100644 --- a/src/BitMono.Host/Modules/BitMonoModule.cs +++ b/src/BitMono.Host/Modules/BitMonoModule.cs @@ -68,36 +68,6 @@ protected override void Load(ContainerBuilder containerBuilder) .OwnedByLifetimeScope() .SingleInstance(); - containerBuilder.RegisterType() - .As() - .OwnedByLifetimeScope() - .SingleInstance(); - - containerBuilder.RegisterType() - .As() - .OwnedByLifetimeScope() - .SingleInstance(); - - containerBuilder.RegisterType() - .As() - .OwnedByLifetimeScope() - .SingleInstance(); - - containerBuilder.RegisterType() - .As() - .OwnedByLifetimeScope() - .SingleInstance(); - - containerBuilder.RegisterType() - .As() - .OwnedByLifetimeScope() - .SingleInstance(); - - containerBuilder.RegisterType() - .As() - .OwnedByLifetimeScope() - .SingleInstance(); - containerBuilder.RegisterType() .As() .OwnedByLifetimeScope() From 65b5a1a0a855ceaefe063e31849d19d03d3665db Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:18 +0200 Subject: [PATCH 37/55] Update GlobalUsings.cs --- src/BitMono.Obfuscation.API/GlobalUsings.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BitMono.Obfuscation.API/GlobalUsings.cs b/src/BitMono.Obfuscation.API/GlobalUsings.cs index 8f25f739..d536e6d4 100644 --- a/src/BitMono.Obfuscation.API/GlobalUsings.cs +++ b/src/BitMono.Obfuscation.API/GlobalUsings.cs @@ -1,3 +1,4 @@ global using dnlib.DotNet; global using dnlib.DotNet.Writer; global using System.Collections.Generic; +global using System.Threading.Tasks; \ No newline at end of file From 5ebaef435582992427edf2678c3b3e71893d33b4 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:20 +0200 Subject: [PATCH 38/55] Create IDataWriter.cs --- src/BitMono.Obfuscation.API/IDataWriter.cs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/BitMono.Obfuscation.API/IDataWriter.cs diff --git a/src/BitMono.Obfuscation.API/IDataWriter.cs b/src/BitMono.Obfuscation.API/IDataWriter.cs new file mode 100644 index 00000000..61e7f8cc --- /dev/null +++ b/src/BitMono.Obfuscation.API/IDataWriter.cs @@ -0,0 +1,6 @@ +namespace BitMono.Obfuscation.API; + +public interface IDataWriter +{ + Task WriteAsync(string outputFile, byte[] outputBuffer); +} \ No newline at end of file From 0e6f22178075136d007c977a7fba0d7bf030656d Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:22 +0200 Subject: [PATCH 39/55] Update GlobalUsings.cs --- src/BitMono.Obfuscation/GlobalUsings.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BitMono.Obfuscation/GlobalUsings.cs b/src/BitMono.Obfuscation/GlobalUsings.cs index 58af42a8..196c78a3 100644 --- a/src/BitMono.Obfuscation/GlobalUsings.cs +++ b/src/BitMono.Obfuscation/GlobalUsings.cs @@ -3,7 +3,6 @@ global using BitMono.API.Protecting.Contexts; global using BitMono.API.Protecting.Pipeline; global using BitMono.API.Protecting.Resolvers; -global using BitMono.API.Protecting.Writers; global using BitMono.Core.Extensions.Protections; global using BitMono.Core.Protecting.Resolvers; global using BitMono.Obfuscation.API; From f5d3dfdbf4b85846d1e4364694de63003f45c812 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:24 +0200 Subject: [PATCH 40/55] Update DotNetHook.cs --- src/BitMono.Protections/DotNetHook.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/BitMono.Protections/DotNetHook.cs b/src/BitMono.Protections/DotNetHook.cs index 45c7b6f7..f29f3a71 100644 --- a/src/BitMono.Protections/DotNetHook.cs +++ b/src/BitMono.Protections/DotNetHook.cs @@ -4,23 +4,18 @@ public class DotNetHook : IStageProtection { private readonly IInjector m_Injector; - private readonly IMethodDefSearcher m_MethodDefSearcher; private readonly IRenamer m_Renamer; private readonly ILogger m_Logger; - private readonly List m_InstructionsToBeTokensUpdated; private readonly Random m_Random; public DotNetHook( IInjector injector, - IMethodDefSearcher methodDefSearcher, IRenamer renamer, ILogger logger) { m_Injector = injector; - m_MethodDefSearcher = methodDefSearcher; m_Renamer = renamer; m_Logger = logger.ForContext(); - m_InstructionsToBeTokensUpdated = new List(); m_Random = new Random(); } From e56a4a2bfc1fb92211db79b248e14231febd5059 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:26 +0200 Subject: [PATCH 41/55] Update FullRenamer.cs --- src/BitMono.Protections/FullRenamer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BitMono.Protections/FullRenamer.cs b/src/BitMono.Protections/FullRenamer.cs index 29b209eb..a1b7746a 100644 --- a/src/BitMono.Protections/FullRenamer.cs +++ b/src/BitMono.Protections/FullRenamer.cs @@ -4,13 +4,13 @@ public class FullRenamer : IProtection { private readonly DnlibDefCriticalAnalyzer m_DnlibDefCriticalAnalyzer; - private readonly TypeDefModelCriticalAnalyzer m_TypeDefModelCriticalAnalyzer; + private readonly TypeDefAttributeCriticalAnalyzer m_TypeDefModelCriticalAnalyzer; private readonly IRenamer m_Renamer; private readonly ILogger m_Logger; public FullRenamer( DnlibDefCriticalAnalyzer dnlibDefCriticalAnalyzer, - TypeDefModelCriticalAnalyzer typeDefModelCriticalAnalyzer, + TypeDefAttributeCriticalAnalyzer typeDefModelCriticalAnalyzer, IRenamer renamer, ILogger logger) { From 4e48b9458d88a3c15b8515676f3566ce84309b39 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:29 +0200 Subject: [PATCH 42/55] Update GlobalUsings.cs --- src/BitMono.Protections/GlobalUsings.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/BitMono.Protections/GlobalUsings.cs b/src/BitMono.Protections/GlobalUsings.cs index 3d6778e3..4e2e353a 100644 --- a/src/BitMono.Protections/GlobalUsings.cs +++ b/src/BitMono.Protections/GlobalUsings.cs @@ -1,8 +1,6 @@ global using BitMono.API.Protecting; global using BitMono.API.Protecting.Contexts; global using BitMono.API.Protecting.Injection; -global using BitMono.API.Protecting.Injection.FieldDefs; -global using BitMono.API.Protecting.Injection.MethodDefs; global using BitMono.API.Protecting.Pipeline; global using BitMono.API.Protecting.Renaming; global using BitMono.Core.Protecting.Analyzing.DnlibDefs; From 3b943480f431400a7a7b133b66220a8751eb1b4f Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:40:32 +0200 Subject: [PATCH 43/55] Update StringsEncryption.cs --- src/BitMono.Protections/StringsEncryption.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/BitMono.Protections/StringsEncryption.cs b/src/BitMono.Protections/StringsEncryption.cs index 926042f7..752d1bf8 100644 --- a/src/BitMono.Protections/StringsEncryption.cs +++ b/src/BitMono.Protections/StringsEncryption.cs @@ -4,23 +4,17 @@ public class StringsEncryption : IProtection { private readonly IInjector m_Injector; - private readonly IFieldSearcher m_FieldSearcher; - private readonly IMethodDefSearcher m_MethodSearcher; private readonly DnlibDefCriticalAnalyzer m_DnlibDefCriticalAnalyzer; private readonly IRenamer m_Renamer; private readonly ILogger m_Logger; public StringsEncryption( IInjector injector, - IFieldSearcher fieldSearcher, - IMethodDefSearcher methodSearcher, DnlibDefCriticalAnalyzer dnlibDefCriticalAnalyzer, IRenamer renamer, ILogger logger) { m_Injector = injector; - m_FieldSearcher = fieldSearcher; - m_MethodSearcher = methodSearcher; m_DnlibDefCriticalAnalyzer = dnlibDefCriticalAnalyzer; m_Renamer = renamer; m_Logger = logger.ForContext(); From 0ca5c0b47e5b448f67a9e1cff5b7b1a744fddbe9 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:41:00 +0200 Subject: [PATCH 44/55] Update GlobalUsings.cs --- src/BitMono.CLI/GlobalUsings.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BitMono.CLI/GlobalUsings.cs b/src/BitMono.CLI/GlobalUsings.cs index 41212bee..46451a5e 100644 --- a/src/BitMono.CLI/GlobalUsings.cs +++ b/src/BitMono.CLI/GlobalUsings.cs @@ -7,6 +7,7 @@ global using BitMono.Host; global using BitMono.Host.Modules; global using BitMono.Obfuscation; +global using BitMono.Obfuscation.API; global using BitMono.Shared.Models; global using Microsoft.Extensions.Configuration; global using NullGuard; From d0f629b040f311528d7c2cf8c040878b3459b796 Mon Sep 17 00:00:00 2001 From: sunnamed <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 12:41:03 +0200 Subject: [PATCH 45/55] Update CLIDataWriter.cs --- src/BitMono.CLI/Modules/CLIDataWriter.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/BitMono.CLI/Modules/CLIDataWriter.cs b/src/BitMono.CLI/Modules/CLIDataWriter.cs index 9bb48227..2afa49a6 100644 --- a/src/BitMono.CLI/Modules/CLIDataWriter.cs +++ b/src/BitMono.CLI/Modules/CLIDataWriter.cs @@ -1,6 +1,4 @@ -using BitMono.Obfuscation.API; - -namespace BitMono.CLI.Modules; +namespace BitMono.CLI.Modules; internal class CLIDataWriter : IDataWriter { From 8ae64e7bf64d176ad567fbe910d86048db92f8ec Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 14:28:57 +0200 Subject: [PATCH 46/55] Fix StringsEncryption Protection --- src/BitMono.Protections/StringsEncryption.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/BitMono.Protections/StringsEncryption.cs b/src/BitMono.Protections/StringsEncryption.cs index 752d1bf8..9a337ad0 100644 --- a/src/BitMono.Protections/StringsEncryption.cs +++ b/src/BitMono.Protections/StringsEncryption.cs @@ -6,18 +6,15 @@ public class StringsEncryption : IProtection private readonly IInjector m_Injector; private readonly DnlibDefCriticalAnalyzer m_DnlibDefCriticalAnalyzer; private readonly IRenamer m_Renamer; - private readonly ILogger m_Logger; public StringsEncryption( IInjector injector, DnlibDefCriticalAnalyzer dnlibDefCriticalAnalyzer, - IRenamer renamer, - ILogger logger) + IRenamer renamer) { m_Injector = injector; m_DnlibDefCriticalAnalyzer = dnlibDefCriticalAnalyzer; m_Renamer = renamer; - m_Logger = logger.ForContext(); } public Task ExecuteAsync(ProtectionContext context, ProtectionParameters parameters, CancellationToken cancellationToken = default) @@ -37,7 +34,6 @@ public Task ExecuteAsync(ProtectionContext context, ProtectionParameters paramet { if (methodDef.HasBody && m_DnlibDefCriticalAnalyzer.NotCriticalToMakeChanges(methodDef)) { - methodDef.Body.KeepOldMaxStack = true; for (var i = 0; i < methodDef.Body.Instructions.Count(); i++) { if (methodDef.Body.Instructions[i].OpCode == OpCodes.Ldstr From 117ffb6b542c115f2e065fe2e2a97533c21ed9ca Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 14:29:08 +0200 Subject: [PATCH 47/55] Fix BitMethodDotnet Protection --- src/BitMono.Protections/BitMethodDotnet.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BitMono.Protections/BitMethodDotnet.cs b/src/BitMono.Protections/BitMethodDotnet.cs index d8b70adc..a66993d8 100644 --- a/src/BitMono.Protections/BitMethodDotnet.cs +++ b/src/BitMono.Protections/BitMethodDotnet.cs @@ -44,9 +44,9 @@ public Task ExecuteAsync(ProtectionContext context, ProtectionParameters paramet _ => throw new ArgumentOutOfRangeException(), }; - methodDef.Body.Instructions.Insert(randomMethodDefBodyIndex, new Instruction(OpCodes.Nop)); + methodDef.Body.Instructions.Insert(randomMethodDefBodyIndex, Instruction.Create(OpCodes.Nop)); methodDef.Body.Instructions.Insert(randomMethodDefBodyIndex + 1, randomPrefixInstruction); - methodDef.Body.Instructions[randomMethodDefBodyIndex] = new Instruction(OpCodes.Br_S, methodDef.Body.Instructions[randomMethodDefBodyIndex + 2]); + methodDef.Body.Instructions[randomMethodDefBodyIndex].ReplaceWith(OpCodes.Br_S, methodDef.Body.Instructions[randomMethodDefBodyIndex + 2]); } } } From 10a3b37ce935e9dafc1484814bb8c6418bb383ec Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 14:29:12 +0200 Subject: [PATCH 48/55] Update MethodDefExtensions.cs --- .../Extensions/dnlib/MethodDefExtensions.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/BitMono.Utilities/Extensions/dnlib/MethodDefExtensions.cs b/src/BitMono.Utilities/Extensions/dnlib/MethodDefExtensions.cs index fe266f60..2f935377 100644 --- a/src/BitMono.Utilities/Extensions/dnlib/MethodDefExtensions.cs +++ b/src/BitMono.Utilities/Extensions/dnlib/MethodDefExtensions.cs @@ -40,9 +40,4 @@ public static bool HasParameters(this MethodDef source) { return source.Parameters.Any(); } - public static MethodDef SetDeclaringTypeToNull(this MethodDef source) - { - source.DeclaringType = null; - return source; - } } \ No newline at end of file From 1a6d4faa2d77c1f3aca83404d9af5dbcac21d612 Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 14:29:18 +0200 Subject: [PATCH 49/55] Update GlobalUsings.cs --- src/BitMono.Obfuscation.API/GlobalUsings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BitMono.Obfuscation.API/GlobalUsings.cs b/src/BitMono.Obfuscation.API/GlobalUsings.cs index 7835dc90..d536e6d4 100644 --- a/src/BitMono.Obfuscation.API/GlobalUsings.cs +++ b/src/BitMono.Obfuscation.API/GlobalUsings.cs @@ -1,4 +1,4 @@ global using dnlib.DotNet; global using dnlib.DotNet.Writer; global using System.Collections.Generic; -global using System.Threading.Tasks \ No newline at end of file +global using System.Threading.Tasks; \ No newline at end of file From b4d3e2d7d16255191764ad609075b67c4dbd774b Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 14:43:53 +0200 Subject: [PATCH 50/55] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a688f53..4b53e163 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Credits **[Gazzi](https://github.com/GazziFX)** for his help that [me](https://github.com/sunnamed434) asked a lot! -**[Elliesaur](https://github.com/Elliesaur)** for his acquaintance in **[DotNetHook](https://github.com/Elliesaur/DotNetHook)** that hides methods execution. +**[Elliesaur](https://github.com/Elliesaur)** for his acquaintance in **[DotNetHook](https://github.com/Elliesaur/DotNetHook)** that hooks methods. **[Weka](https://github.com/sasharumega)** for his advices, help and motivation From 6431e2dc6a16e10e9e1b2f18ff39eae0cc362a91 Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 14:55:35 +0200 Subject: [PATCH 51/55] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b53e163..563b0801 100644 --- a/README.md +++ b/README.md @@ -68,4 +68,6 @@ Credits **[Weka](https://github.com/sasharumega)** for his advices, help and motivation -**[ConfuserEx and their Forks](https://github.com/yck1509/ConfuserEx)** for most things that I watched for the architecture of BitMono and the obfuscator engine as an application and solving plenty of User solutions which I would be knew in the very long future after much fail usage of BitMono and reports by other Users. Day-by-day I'm looking for something interesting there to improve myself in knowledge and BitMono also. \ No newline at end of file +**[ConfuserEx and their Forks](https://github.com/yck1509/ConfuserEx)** for most things that I watched for the architecture of BitMono and the obfuscator engine as an application and solving plenty of User solutions which I would be knew in the very long future after much fail usage of BitMono and reports by other Users. Day-by-day I'm looking for something interesting there to improve myself in knowledge and BitMono also. + +**[Kao and his blogs](https://lifeinhex.com/) thanks a lot of these blogs \ No newline at end of file From e251ee4b70cd4414742f79d346f35f6816ecb05f Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 14:55:45 +0200 Subject: [PATCH 52/55] Update BitMonoObfuscator.cs --- src/BitMono.Obfuscation/BitMonoObfuscator.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/BitMono.Obfuscation/BitMonoObfuscator.cs b/src/BitMono.Obfuscation/BitMonoObfuscator.cs index 70575c3f..9d93b2f6 100644 --- a/src/BitMono.Obfuscation/BitMonoObfuscator.cs +++ b/src/BitMono.Obfuscation/BitMonoObfuscator.cs @@ -32,6 +32,13 @@ public async Task StartAsync(CancellationTokenSource cancellationTokenSource) var cancellationToken = cancellationTokenSource.Token; cancellationToken.ThrowIfCancellationRequested(); + foreach (var methodDef in m_ProtectionContext.ModuleDefMD.FindDefinitions().OfType()) + { + methodDef.Body.Instructions.SimplifyMacros(methodDef.Body.Variables, methodDef.Parameters); + methodDef.Body.Instructions.OptimizeMacros(); + + } + foreach (var protection in m_Protections) { cancellationToken.ThrowIfCancellationRequested(); From 1757ba01fa51494461bd27a1efc10c25b4a5327a Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 14:55:59 +0200 Subject: [PATCH 53/55] Update GlobalUsings.cs --- src/BitMono.Obfuscation/GlobalUsings.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BitMono.Obfuscation/GlobalUsings.cs b/src/BitMono.Obfuscation/GlobalUsings.cs index 196c78a3..360a1d47 100644 --- a/src/BitMono.Obfuscation/GlobalUsings.cs +++ b/src/BitMono.Obfuscation/GlobalUsings.cs @@ -20,4 +20,5 @@ global using System.Text; global using System.Threading; global using System.Threading.Tasks; -global using ILogger = Serilog.ILogger; \ No newline at end of file +global using ILogger = Serilog.ILogger; +global using dnlib.DotNet.Emit; \ No newline at end of file From af848466de2c1407e9bba75ff33c6460ad4cb7b7 Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 14:59:33 +0200 Subject: [PATCH 54/55] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 563b0801..360dfd98 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,8 @@ Credits **[Elliesaur](https://github.com/Elliesaur)** for his acquaintance in **[DotNetHook](https://github.com/Elliesaur/DotNetHook)** that hooks methods. -**[Weka](https://github.com/sasharumega)** for his advices, help and motivation +**[Weka](https://github.com/sasharumega)** for his advices, help and motivation. **[ConfuserEx and their Forks](https://github.com/yck1509/ConfuserEx)** for most things that I watched for the architecture of BitMono and the obfuscator engine as an application and solving plenty of User solutions which I would be knew in the very long future after much fail usage of BitMono and reports by other Users. Day-by-day I'm looking for something interesting there to improve myself in knowledge and BitMono also. -**[Kao and his blogs](https://lifeinhex.com/) thanks a lot of these blogs \ No newline at end of file +**[Kao and his blogs](https://lifeinhex.com/) thanks a lot of these blogs. \ No newline at end of file From b3060b4003e7da41445a5efd8a99e57712058e3c Mon Sep 17 00:00:00 2001 From: sunnamed434 <65300126+sunnamed434@users.noreply.github.com> Date: Sat, 17 Dec 2022 14:59:37 +0200 Subject: [PATCH 55/55] Update CHANGELOG.md --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f3c1ec0..c3d9e58e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ | Versions: | | - | +| [v0.5.0-alpha](#v050-alpha14) | | [v0.4.4-alpha](#v044-alpha13) | | [v0.4.3-alpha](#v043-alpha12) | | [v0.4.2-alpha](#v042-alpha11) | @@ -16,6 +17,15 @@ | [v0.1.0](#v010) | --- +### v0.5.0-alpha.14: +#### Added: +* Before obfuscation optmizes all method bodies (macros) + +#### Fixed: +* BitMethodDotnet Protection +* StringsEncryption Protection + + ### v0.4.4-alpha.13: #### Fixed: * DotNetHook Protection