Delete BMFuscator directory

This commit is contained in:
Bouletmarc 2023-04-25 03:36:11 -04:00 committed by GitHub
parent fbf9ab75c6
commit 160e7948b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
105 changed files with 0 additions and 5612 deletions

Binary file not shown.

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

View File

@ -1,102 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0FE687CD-6631-428E-A054-8039A20E6F6E}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>BMDevs</RootNamespace>
<AssemblyName>BMFuscator</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>lock_3x_XqK_icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>BMDevs.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="dnlib, Version=1.5.0.1500, Culture=neutral, PublicKeyToken=50e96378b6e77999, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>libs\dnlib.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Protections\AntiDbg.cs" />
<Compile Include="Protections\AntiDe4dotProtection.cs" />
<Compile Include="Mutations\BoolsToModuleReference.cs" />
<Compile Include="Mutations\BytesToModuleReference.cs" />
<Compile Include="Protections\AntiILDasmProtection.cs" />
<Compile Include="Protections\ConstantsEncoding.cs" />
<Compile Include="Protections\ControlFlow\Block.cs" />
<Compile Include="Protections\ControlFlow\BlockParser.cs" />
<Compile Include="Protections\ControlFlow\ControlFlowObfuscation.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="Helpers\ReferenceProxyHelper.cs" />
<Compile Include="IObfuscation.cs" />
<Compile Include="Logger.cs" />
<Compile Include="Protections\JunkProtection.cs" />
<Compile Include="Protections\ModuleRenaming.cs" />
<Compile Include="Mutations\Funcs.cs" />
<Compile Include="Mutations\iMutation.cs" />
<Compile Include="Mutations\MutationObf.cs" />
<Compile Include="Mutations\NumbersToModuleReference.cs" />
<Compile Include="OwnRandom.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Protections\HiddenNamespace.cs" />
<Compile Include="Protections\ReferenceProxy.cs" />
<Compile Include="Protections\RenameObfuscation.cs" />
<Compile Include="Runtime\BoolsToModule.cs" />
<Compile Include="Runtime\Constants.cs" />
<Compile Include="Runtime\FuncMutation.cs" />
<Compile Include="Runtime\BytesToModule.cs" />
<Compile Include="Runtime\NumbersToModule.cs" />
<Compile Include="Runtime\RefProxy.cs" />
<Compile Include="Runtime\Renamer.cs" />
<Compile Include="Runtime\RuntimeHelper.cs" />
<Compile Include="Utils.cs" />
<Compile Include="Worker.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="FilesInfos.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="lock_3x_XqK_icon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,18 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs
{
public static class Extensions
{
public static string Base64Representation(this string str)
{
return Convert.ToBase64String(Encoding.Default.GetBytes(str));
}
}
}

View File

@ -1,245 +0,0 @@
Binary_Files.cs
Binary_File_FREE.cs
Binary_File_PLAYGAME.cs
Class10.cs
Class11.cs
Class12.cs
Class13.cs
Class15.cs
Class16.cs
Class17.cs
Class18.cs
Class1.cs
Class3.cs
Class20.cs
Class21.cs
Class22.cs
Class24.cs
Class25.cs
Class27.cs
Class28.cs
Class29.cs
Class2.cs
Class30.cs
Class31.cs
Class32.cs
Class33.cs
Class5.cs
Class7.cs
Class8.cs
Class8.cs
Class9.cs
Class9.cs
ctrlAdvGraph.cs
ctrlAdvTable.cs
ctrlBatteryOffset.cs
CtrlGrid.cs
CtrlInputSelector.cs
CtrlLedDisplay.cs
ctrlMapGraph.cs
CtrlMapGraph3D.cs
CtrlOutputSelector.cs
ctrlOvrlSensor.cs
CtrlSensorGrid.cs
ctrlSpecialSensor.cs
DASM_Bytes.cs
DisplayItemsStripped.cs
Enum4.cs
Enum6.cs
frmAboutBox.cs
frmAccelTimeSetting.cs
frmActiveDatalog.cs
frmAdvancedGraph.cs
frmAdvTableAdd.cs
frmBaseMap.cs
frmBaseromConvert.cs
frmBinTool.cs
frmBluetooth.cs
frmBoostTableSetup.cs
frmBurner.cs
frmChangelog.cs
frmChartTemplates.cs
frmConsole.cs
frmConvert.cs
frmCopyMaps.cs
frmCopyright.cs
FrmDataDisplay.cs
frmDataGrid.cs
frmDatalogGraphs.cs
frmDatalogMenu.cs
frmDebug.cs
frmDownloadBaserom.cs
frmDownloadUpdate.cs
frmDynoControl.cs
frmDynoSetup.cs
frmEbcDutyErrorInput.cs
frmErrorCodes.cs
frmGaugesEditor.cs
frmGearLearn.cs
FrmGridChart.cs
frmGridSelectionAdj.cs
frmHC05.cs
frmIgnCutModWarning.cs
frmIgnitionSync.cs
frmInjectorOverallCalc.cs
frmLivePlot.cs
frmLivePSetting.cs
frmLoading.cs
FrmMain.cs
frmMapScalar.cs
frmOBD2Scan.cs
frmOnboard.cs
frmOstrichInfo.cs
frmParameters.cs
frmPassword.cs
frmQuickAdjust.cs
frmQuickSaveDesc.cs
frmQuickSaveMain.cs
frmReg.cs
frmReset.cs
frmSensorSetup.cs
frmSettings.cs
frmShortKeys.cs
frmUploadBaserom.cs
InjectorsLoading.cs
Mtss.cs
parmAc.cs
parmAntiLag.cs
parmAntiStart.cs
parmBoostCut.cs
parmBoostMapSensor.cs
parmBoostSettings.cs
parmBstManual.cs
parmBurnOut.cs
parmCloseLoop.cs
parmComments.cs
parmCrankFuel.cs
parmCylCorr.cs
parmDualMap.cs
parmDwell.cs
parmEbcCloseloop.cs
parmEbcCompensation.cs
parmEbcDutyLook.cs
parmEbcSettings.cs
parmEctCorr.cs
parmEctProtection.cs
parmFanControl.cs
parmFileProtection.cs
parmFlexFuel.cs
parmFtl.cs
parmFts.cs
parmFuelCut.cs
parmGearCorr.cs
parmGPO1_a.cs
parmGPO1_a.resx
parmGPO1_if.cs
parmGPO1_if.resx
parmGPO2_a.cs
parmGPO2_a.resx
parmGPO2_if.cs
parmGPO2_if.resx
parmGPO3_a.cs
parmGPO3_a.resx
parmGPO3_if.cs
parmGPO3_if.resx
parmIAB.cs
parmIAB.resx
parmIATcorr.cs
parmIATcorr.resx
parmIdleIgnCorr.cs
parmIdleIgnCorr.resx
parmIdleMain.cs
parmIdleMain.resx
parmInjector.cs
parmInjector.resx
parmLeanProtection.cs
parmLeanProtection.resx
parmMap.cs
parmMap.resx
parmMilShift.cs
parmMilShift.resx
parmPopcorn.cs
parmPopcorn.resx
parmRevLimit.cs
parmRevLimit.resx
parmRomOptions.cs
parmRomOptions.resx
parmSCC.cs
parmSCC.resx
parmTipInOut.cs
parmTipInOut.resx
parmTpsRetard.cs
parmTpsRetard.resx
parmTpsSensor.cs
parmTpsSensor.resx
parmTransmission.cs
parmTransmission.resx
parmVtec.cs
parmVtec.resx
Struct12.cs
Struct15.cs
Struct16.cs
Struct17.cs
Struct18.cs
Struct19.cs
Struct20.cs
Struct22.cs
Struct23.cs
Struct24.cs
CtrlDisplayItemText.cs
CtrlDisplayItemText.resx
ctrlLogGraph.cs
ctrlLogGraph.resx
ctrlMapSensor.cs
ctrlMapSensor.resx
ctrlMapValue.cs
ctrlMapValue.resx
ctrlPlotGraph.cs
ctrlPlotGraph.resx
TunerAnalogGrid.cs
SettingsFile.cs
SettingsFormatException.cs
SettingsKey.cs
AdvTableType.cs
AirFuelUnits.cs
AnalogInputs.cs
BMTuneVersions.cs
ChartCollection.cs
ChartSetup.cs
ChartTemplate.cs
CorrectionUnits.cs
DatalogButtonsTypes.cs
DatalogDisplayTypes.cs
DataloggingMode.cs
DataloggingState.cs
DataloggingTable.cs
DatalogLedTypes.cs
DoNotObfuscate.cs
EmulatorMoatesType.cs
EmulatorMode.cs
EmulatorState.cs
EmulatorVendorDemon.cs
EmulatorVendorOstrich.cs
FuelDisplayMode.cs
MapGraphSelect.cs
MapGraphType.cs
MapSensorUnits.cs
OverlayDisplaySelected.cs
QuickSaveItem.cs
QuickSaveListObjects.cs
SelectedTable.cs
SensorsX.cs
TableOverlay.cs
TemperatureUnits.cs
TunerAfrGrid.cs
TunerSmartTrack.cs
VoltUnits.cs
VssUnits.cs
WBinput.cs
Wideband_Serial.cs
frmHelp.cs
frmHelp.resx
parmHelpNew.cs
parmHelpNew.resx
Resources.Designer.cs
Resources.resx

View File

@ -1,55 +0,0 @@
using dnlib.DotNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static BMDevs.Renamer;
namespace BMDevs.Helpers
{
public class ReferenceProxyHelper
{
public static TypeDef CreateDelegateType(MethodSig sig, ModuleDef target, MethodDef original)
{
TypeDef ret = new TypeDefUser("BMDevs", Renamer.GetEndName(RenameMode.Base64, 3, 20), target.CorLibTypes.GetTypeRef("System", "MulticastDelegate"));
ret.Attributes = original.DeclaringType.Attributes;
var ctor = new MethodDefUser(".ctor", MethodSig.CreateInstance(target.CorLibTypes.Void, target.CorLibTypes.Object, target.CorLibTypes.IntPtr));
ctor.Attributes = MethodAttributes.Assembly | MethodAttributes.HideBySig | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName;
ctor.ImplAttributes = MethodImplAttributes.Runtime;
ret.Methods.Add(ctor);
var clone = sig.Clone();
var invoke = new MethodDefUser("Invoke", clone);
invoke.MethodSig.HasThis = true;
invoke.Attributes = MethodAttributes.Assembly | MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.NewSlot | MethodAttributes.Public;
invoke.ImplAttributes = MethodImplAttributes.Runtime;
ret.Methods.Add(invoke);
target.Types.Add(ret);
return ret;
}
public static MethodSig CreateProxySignature(IMethod method, ModuleDef target)
{
List<TypeSig> paramTypes = method.MethodSig.Params.ToList();
if (method.MethodSig.HasThis && !method.MethodSig.ExplicitThis)
{
TypeDef declType = method.DeclaringType.ResolveTypeDefThrow();
paramTypes.Insert(0, Import(target, declType).ToTypeSig());
}
TypeSig retType = method.MethodSig.RetType;
if (retType.IsClassSig)
retType = target.CorLibTypes.Object;
return MethodSig.CreateStatic(retType, paramTypes.ToArray());
}
public static ITypeDefOrRef Import(ModuleDef module, TypeDef typeDef)
{
ITypeDefOrRef retTypeRef = new Importer(module, ImporterOptions.TryToUseTypeDefs).Import(typeDef);
return retTypeRef;
}
}
}

View File

@ -1,14 +0,0 @@
using dnlib.DotNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs
{
public interface IObfuscation
{
void Execute(ModuleDefMD md);
}
}

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs
{
public class Logger
{
public static void LogMessage(string pre, string past, ConsoleColor PastColor)
{
Console.Write(pre);
Console.ForegroundColor = PastColor;
Console.WriteLine(past);
Console.ForegroundColor = ConsoleColor.White;
}
}
}

View File

@ -1,69 +0,0 @@
using BMDevs.Runtime;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using dnlib.PE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Mutations
{
public class BoolsToModuleReference : IObfuscation
{
public ModuleDef Module { get; set; }
public Dictionary<bool, FieldDef> Numbers { get; set; }
public void Execute(ModuleDefMD md)
{
Numbers = new Dictionary<bool, FieldDef>();
Module = md;
foreach (var type in md.Types.Where(x => x != md.GlobalType))
foreach (var method in type.Methods.Where(x => !x.IsConstructor && x.HasBody && x.Body.HasInstructions))
ExecuteMethod(method);
}
public FieldDef AddNumberField(int num)
{
var cstype = RuntimeHelper.GetRuntimeType("BMDevs.Runtime.BoolsToModule");
FieldDef field = cstype.FindField("val");
Renamer.Rename(field, Renamer.RenameMode.Invalid2, 2);
//Renamer.Rename(field, Renamer.RenameMode.Base64, 2);
field.DeclaringType = null;
Module.GlobalType.Fields.Add(field);
var method = Module.GlobalType.FindOrCreateStaticConstructor();
method.Body.Instructions.Insert(0, new Instruction(OpCodes.Ldc_I4, num));
method.Body.Instructions.Insert(1, new Instruction(OpCodes.Stsfld, field));
return field;
}
//thanks to mighty
public void ExecuteMethod(MethodDef method)
{
for (int i = 0; i < method.Body.Instructions.Count; i++)
{
var instr = method.Body.Instructions[i];
if (instr.IsLdcI4())
{
if (Module.GlobalType.Fields.Count < 65000)
{
var val = instr.GetLdcI4Value();
FieldDef fld;
bool bufbool = false;
if (val == 1) bufbool = true;
if (!Numbers.TryGetValue(bufbool, out fld))
{
fld = AddNumberField(val);
Numbers.Add(bufbool, fld);
}
instr.OpCode = OpCodes.Ldsfld;
instr.Operand = fld;
}
}
}
}
}
}

View File

@ -1,74 +0,0 @@
using BMDevs.Runtime;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using dnlib.PE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Mutations
{
public class BytesToModuleReference : IObfuscation
{
public ModuleDef Module { get; set; }
public Dictionary<long, FieldDef> Numbers { get; set; }
public void Execute(ModuleDefMD md)
{
Numbers = new Dictionary<long, FieldDef>();
Module = md;
foreach (var type in md.Types.Where(x => x != md.GlobalType))
foreach (var method in type.Methods.Where(x => !x.IsConstructor && x.HasBody && x.Body.HasInstructions))
ExecuteMethod(method);
}
public FieldDef AddNumberField(long num)
{
var cstype = RuntimeHelper.GetRuntimeType("BMDevs.Runtime.BytesToModule");
FieldDef field = cstype.FindField("val");
Renamer.Rename(field, Renamer.RenameMode.Invalid2, 2);
//Renamer.Rename(field, Renamer.RenameMode.Base64, 2);
field.DeclaringType = null;
Module.GlobalType.Fields.Add(field);
var method = Module.GlobalType.FindOrCreateStaticConstructor();
method.Body.Instructions.Insert(0, new Instruction(OpCodes.Ldc_I4, num));
method.Body.Instructions.Insert(1, new Instruction(OpCodes.Stsfld, field));
return field;
}
//thanks to mighty
public void ExecuteMethod(MethodDef method)
{
for (int i = 0; i < method.Body.Instructions.Count; i++)
{
var instr = method.Body.Instructions[i];
//if (instr.IsLdloc())
//{
if (Module.GlobalType.Fields.Count < 65000)
{
var val = instr.GetLdcI4Value();
if (val != -1)
{
if (val.GetType() == typeof(long))
{
FieldDef fld;
if (!Numbers.TryGetValue((long)val, out fld))
{
fld = AddNumberField((long)val);
Numbers.Add((long)val, fld);
Console.WriteLine("ByteModule: " + val);
}
instr.OpCode = OpCodes.Ldsfld;
instr.Operand = fld;
}
}
}
//}
}
}
}
}

View File

@ -1,386 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BMDevs.Runtime;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
namespace BMDevs.Mutations
{
public class Add : iMutation
{
public void Prepare(TypeDef type) { }
public void Process(MethodDef method, ref int index)
{
var defvalue = method.Body.Instructions[index].GetLdcI4Value();
var inda = RuntimeHelper.Random.Next((int)((double)defvalue / 1.5));
method.Body.Instructions[index].OpCode = OpCodes.Ldc_I4;
method.Body.Instructions[index].Operand = defvalue - inda;
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldc_I4, inda));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Add));
}
public bool Supported(Instruction instr)
{
return Utils.CheckArithmetic(instr);
}
}
public class Sub : iMutation
{
public void Prepare(TypeDef type) { }
public void Process(MethodDef method, ref int index)
{
var defvalue = method.Body.Instructions[index].GetLdcI4Value();
var two = RuntimeHelper.Random.Next((int)((double)defvalue / 1.5));
method.Body.Instructions[index].OpCode = OpCodes.Ldc_I4;
method.Body.Instructions[index].Operand = defvalue + two;
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldc_I4, two));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Sub));
}
public bool Supported(Instruction instr)
{
return Utils.CheckArithmetic(instr);
}
}
public class Mul : iMutation
{
public void Prepare(TypeDef type) { }
public void Process(MethodDef method, ref int index)
{
var defvalue = method.Body.Instructions[index].GetLdcI4Value();
var two = RuntimeHelper.Random.Next(1, (int)((double)defvalue / 1.5));
var one = defvalue / two;
//ERROR HERE DONT USE THIS WHILE LOOP
while (two * one != defvalue)
{
two = RuntimeHelper.Random.Next(1, (int)((double)defvalue / 1.5));
one = defvalue / two;
}
method.Body.Instructions[index].OpCode = OpCodes.Ldc_I4;
method.Body.Instructions[index].Operand = one;
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldc_I4, two));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Mul));
index += 1;
}
public bool Supported(Instruction instr)
{
return Utils.CheckArithmetic(instr);
}
}
public class Div : iMutation
{
public void Prepare(TypeDef type) { }
public void Process(MethodDef method, ref int index)
{
var defvalue = method.Body.Instructions[index].GetLdcI4Value();
var two = RuntimeHelper.Random.Next(1, 5);
method.Body.Instructions[index].OpCode = OpCodes.Ldc_I4;
method.Body.Instructions[index].Operand = defvalue * two;
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldc_I4, two));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Div));
}
public bool Supported(Instruction instr)
{
return Utils.CheckArithmetic(instr);
}
}
public class Abs : iMutation
{
public void Prepare(TypeDef type) { }
public void Process(MethodDef method, ref int index)
{
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Call, method.Module.Import(typeof(Math).GetMethod("Abs", new Type[] { typeof(int) }))));
}
public bool Supported(Instruction instr)
{
return Utils.CheckArithmetic(instr);
}
}
public class StringLen : iMutation
{
public void Prepare(TypeDef type) { }
public void Process(MethodDef method, ref int index)
{
if (method.DeclaringType == method.Module.GlobalType)
{
index--;
return;
}
int defval = method.Body.Instructions[index].GetLdcI4Value();
int needed = RuntimeHelper.Random.Next(4, 15);
//string ch = Renamer.GetFuckedString(needed);
string ch = Renamer.GetFuckedString2(needed);
method.Body.Instructions[index].OpCode = OpCodes.Ldc_I4;
method.Body.Instructions[index].Operand = defval - needed;
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldstr, ch));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Call, method.Module.Import(typeof(string).GetMethod("get_Length"))));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Add));
}
public bool Supported(Instruction instr)
{
return Utils.CheckArithmetic(instr);
}
}
public class Func : iMutation
{
public FieldDef Decryptor { get; set; }
public void Process(MethodDef method, ref int index)
{
int nde = method.Body.Instructions[index].GetLdcI4Value();
method.Body.Instructions[index].OpCode = OpCodes.Ldsfld;
method.Body.Instructions[index].Operand = Decryptor;
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldc_I4, nde));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Callvirt, method.Module.Import(typeof(Func<int, int>).GetMethod("Invoke"))));
index -= 2;
}
public FieldDef CreateProperField(TypeDef type)
{
var cotype = RuntimeHelper.GetRuntimeType("BMDevs.Runtime.FuncMutation");
FieldDef field = cotype.Fields.FirstOrDefault(x => x.Name == "prao");
Renamer.Rename(field, Renamer.RenameMode.Base64, 3);
field.DeclaringType = null;
type.Fields.Add(field);
MethodDef funcmethod = cotype.FindMethod("RET");
funcmethod.DeclaringType = null;
Renamer.Rename(funcmethod, Renamer.RenameMode.Base64, 3);
type.Methods.Add(funcmethod);
var cctor = type.FindOrCreateStaticConstructor();
cctor.Body.Instructions.Insert(0, new Instruction(OpCodes.Ldnull));
cctor.Body.Instructions.Insert(1, new Instruction(OpCodes.Ldftn, funcmethod));
cctor.Body.Instructions.Insert(2, new Instruction(OpCodes.Newobj, type.Module.Import(typeof(Func<int, int>).GetConstructors().First())));
cctor.Body.Instructions.Insert(3, new Instruction(OpCodes.Stsfld, field));
cctor.Body.Instructions.Insert(4, new Instruction(OpCodes.Nop));
return field;
}
public void Prepare(TypeDef type)
{
Decryptor = CreateProperField(type);
}
public bool Supported(Instruction instr)
{
return Utils.CheckArithmetic(instr);
}
}
//thanks to TheProxy#5615 for explanation
public class CharMutations : iMutation
{
public MethodDef Converter { get; set; }
public void Prepare(TypeDef type)
{
var cotype = RuntimeHelper.GetRuntimeType("BMDevs.Runtime.FuncMutation");
MethodDef todef = cotype.FindMethod("CharToInt");
todef.Name = Renamer.GetRandomName().Base64Representation();
todef.DeclaringType = null;
type.Methods.Add(todef);
Converter = todef;
}
public void Process(MethodDef method, ref int index)
{
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Call, Converter));
}
public bool Supported(Instruction instr)
{
return Utils.CheckArithmetic(instr);
}
}
public class VariableMutation : iMutation
{
public void Prepare(TypeDef type) { }
public void Process(MethodDef method, ref int index)
{
var value = method.Body.Instructions[index].GetLdcI4Value();
Local lcl = new Local(method.Module.CorLibTypes.Int32);
method.Body.Variables.Add(lcl);
method.Body.Instructions.Insert(0, new Instruction(OpCodes.Stloc, lcl));
method.Body.Instructions.Insert(0, new Instruction(OpCodes.Ldc_I4, value));
index += 2;
method.Body.Instructions[index] = new Instruction(OpCodes.Ldloc, lcl);
}
public bool Supported(Instruction instr)
{
return Utils.CheckArithmetic(instr);
}
}
public class ComparerMutation : iMutation
{
public void Prepare(TypeDef type)
{
if (type != type.Module.GlobalType)
for (int i = 0; i < type.Methods.Count; i++)
{
var mDef = type.Methods[i];
if (!mDef.HasBody || mDef.IsConstructor) continue;
mDef.Body.SimplifyBranches();
for (int x = 0; x < mDef.Body.Instructions.Count; x++)
{
if (Utils.CheckArithmetic(mDef.Body.Instructions[x]))
{
Execute(mDef, ref x);
}
}
}
}
public void Execute(MethodDef method, ref int index)
{
if (method.Body.Instructions[index].OpCode != OpCodes.Call)
{
var value = method.Body.Instructions[index].GetLdcI4Value();
Local lcl = new Local(method.Module.CorLibTypes.Int32);
Local lcl2 = new Local(method.Module.CorLibTypes.Int32);
method.Body.Variables.Add(lcl);
method.Body.Variables.Add(lcl2);
var initial = RuntimeHelper.Random.Next();
var ifstate = RuntimeHelper.Random.Next();
int initial2;
bool shouldBeEqual = Convert.ToBoolean(RuntimeHelper.Random.Next(2));
if (shouldBeEqual)
initial2 = ifstate - initial;
else
{
initial2 = RuntimeHelper.Random.Next();
while (initial2 + initial == ifstate)
initial2 = RuntimeHelper.Random.Next();
}
method.Body.Instructions[index] = Instruction.CreateLdcI4(initial);
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Stloc, lcl));
method.Body.Instructions.Insert(++index, Instruction.CreateLdcI4(initial2));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Stloc, lcl2));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldloc, lcl));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldloc, lcl2));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Add));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldc_I4, ifstate));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ceq));
Instruction nop = OpCodes.Nop.ToInstruction();
method.Body.Instructions.Insert(++index, new Instruction(shouldBeEqual ? OpCodes.Brfalse : OpCodes.Brtrue, nop));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Nop));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldc_I4, value));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Stloc, lcl));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Nop));
Instruction ldloc = OpCodes.Ldloc_S.ToInstruction(lcl);
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Br, ldloc));
method.Body.Instructions.Insert(++index, nop);
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldc_I4, RuntimeHelper.Random.Next()));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Stloc, lcl));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Nop));
method.Body.Instructions.Insert(++index, ldloc);
}
}
public void Process(MethodDef method, ref int index) { }
public static void InsertInstructions(IList<Instruction> instructions, Dictionary<Instruction, int> keyValuePairs)
{
foreach (KeyValuePair<Instruction, int> kv in keyValuePairs)
{
Instruction instruction = kv.Key;
int index = kv.Value;
instructions.Insert(index, instruction);
}
}
public bool Supported(Instruction instr)
{
return Utils.CheckArithmetic(instr);
}
}
public class MulToShift : iMutation
{
public void Prepare(TypeDef type) { }
//this shit converts expressions like num * 5 into num + num << 1 + num << 2
public void Process(MethodDef method, ref int index)
{
if (method.Body.Instructions[index - 1].IsLdcI4() && method.Body.Instructions[index - 2].IsLdcI4())
{
var wl = method.Body.Instructions[index - 2].GetLdcI4Value();
var val = method.Body.Instructions[index - 1].GetLdcI4Value();
if (val >= 3)
{
Local lcl = new Local(method.Module.CorLibTypes.Int32);
method.Body.Variables.Add(lcl);
method.Body.Instructions.Insert(0, new Instruction(OpCodes.Stloc, lcl));
method.Body.Instructions.Insert(0, new Instruction(OpCodes.Ldc_I4, wl));
index += 2;
method.Body.Instructions[index - 2].OpCode = OpCodes.Ldloc;
method.Body.Instructions[index - 2].Operand = lcl;
//now we have lcl * val
method.Body.Instructions[index - 1].OpCode = OpCodes.Nop;
method.Body.Instructions[index].OpCode = OpCodes.Nop;
int count = 0;
int curval = val;
while (curval > 0)
{
// check for set bit and left
// shift n, count times
if ((curval & 1) == 1)
{
if (count != 0)
{
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldloc, lcl));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldc_I4, count));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Shl));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Add));
}
}
count++;
curval = curval >> 1;
}
if ((val & 1) == 0)
{
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Ldloc, lcl));
method.Body.Instructions.Insert(++index, new Instruction(OpCodes.Sub));
}
}
}
}
public bool Supported(Instruction instr)
{
return instr.OpCode == OpCodes.Mul;
}
}
}

View File

@ -1,58 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BMDevs.Runtime;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
namespace BMDevs.Mutations
{
public class MutationObf : IObfuscation
{
public ModuleDef Module { get; set; }
List<iMutation> Tasks = new List<iMutation>()
{
//new Add(),
//new Sub(),
//new Div(),
//Issue: Mul mutation takes a lot of time because of `While` loop. Funcs.cs#61
//new Mul(),
new StringLen(),
//new Abs(),
//new Func(),
//new CharMutations(),
//new VariableMutation(),
//new ComparerMutation(),
//new MulToShift()
};
public void Execute(ModuleDefMD md)
{
Module = md;
foreach (TypeDef tDef in md.Types)
{
foreach (var mutation in Tasks)
mutation.Prepare(tDef);
for (int i = 0; i < tDef.Methods.Count; i++)
{
var mDef = tDef.Methods[i];
if (!mDef.HasBody || mDef.IsConstructor) continue;
mDef.Body.SimplifyBranches();
for (int x = 0; x < mDef.Body.Instructions.Count; x++)
{
var rndshit = Tasks[RuntimeHelper.Random.Next(Tasks.Count)];
if (rndshit.Supported(mDef.Body.Instructions[x]))
{
rndshit.Process(mDef, ref x);
}
}
}
}
}
}
}

View File

@ -1,68 +0,0 @@
using BMDevs.Runtime;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using dnlib.PE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Mutations
{
public class NumbersToModuleReference : IObfuscation
{
public ModuleDef Module { get; set; }
public Dictionary<int, FieldDef> Numbers { get; set; }
public void Execute(ModuleDefMD md)
{
Numbers = new Dictionary<int, FieldDef>();
Module = md;
foreach (var type in md.Types.Where(x => x != md.GlobalType))
foreach (var method in type.Methods.Where(x => !x.IsConstructor && x.HasBody && x.Body.HasInstructions))
ExecuteMethod(method);
}
public FieldDef AddNumberField(int num)
{
var cstype = RuntimeHelper.GetRuntimeType("BMDevs.Runtime.NumbersToModule");
FieldDef field = cstype.FindField("val");
Renamer.Rename(field, Renamer.RenameMode.Invalid2, 2);
//Renamer.Rename(field, Renamer.RenameMode.Base64, 2);
field.DeclaringType = null;
Module.GlobalType.Fields.Add(field);
var method = Module.GlobalType.FindOrCreateStaticConstructor();
method.Body.Instructions.Insert(0, new Instruction(OpCodes.Ldc_I4, num));
method.Body.Instructions.Insert(1, new Instruction(OpCodes.Stsfld, field));
return field;
}
//thanks to mighty
public void ExecuteMethod(MethodDef method)
{
for (int i = 0; i < method.Body.Instructions.Count; i++)
{
var instr = method.Body.Instructions[i];
if (instr.IsLdcI4())
{
if (Module.GlobalType.Fields.Count < 65000)
{
var val = instr.GetLdcI4Value();
FieldDef fld;
if (!Numbers.TryGetValue(val, out fld))
{
fld = AddNumberField(val);
Numbers.Add(val, fld);
//Console.WriteLine("NumberModule: " + val);
}
instr.OpCode = OpCodes.Ldsfld;
instr.Operand = fld;
}
}
}
}
}
}

View File

@ -1,13 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System.Collections.Generic;
namespace BMDevs.Mutations
{
public interface iMutation
{
void Process(MethodDef method, ref int index);
void Prepare(TypeDef type);
bool Supported(Instruction instr);
}
}

View File

@ -1,67 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs
{
public class OwnRandom : RandomNumberGenerator
{
private static RandomNumberGenerator r;
public OwnRandom()
{
r = RandomNumberGenerator.Create();
}
public override void GetBytes(byte[] buffer)
{
r.GetBytes(buffer);
}
public double NextDouble()
{
byte[] b = new byte[4];
r.GetBytes(b);
return (double)BitConverter.ToUInt32(b, 0) / UInt32.MaxValue;
}
public int Next(int minValue, int maxValue)
{
return (int)Math.Floor(NextDouble() * (maxValue - minValue)) + minValue;
}
public int Next()
{
return Next(0, Int32.MaxValue);
}
public int Next(int maxValue)
{
return Next(0, maxValue);
}
public byte NextByte()
{
return (Byte)Next(Byte.MaxValue);
}
public uint NextUInt32()
{
return (uint)Next() * 2;
}
public void Shuffle<T>(IList<T> list)
{
for (int i = list.Count - 1; i > 1; i--)
{
int k = Next(i + 1);
T tmp = list[k];
list[k] = list[i];
list[i] = tmp;
}
}
}
}

View File

@ -1,140 +0,0 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs
{
class Program
{
public static Worker Worker { get; set; }
public static string path = "";
public static void Main(string[] args)
{
FileInfo info;
//path = @"C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\BMTune_Encrypter\bin\Debug\BMTune.exe";
//path = @"C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\bin\Debug\BMTune.exe";
//path = @"C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2_Crypted\bin\Debug\BMTune.exe";
//if (path != "") DoLoop();
for (int i = 0; i < args.Length; i++)
{
//Console.WriteLine(args[i]);
info = new FileInfo(args[i]);
if (((info.Extension == ".exe")) && info.Exists)
{
path = args[i];
DoLoop();
}
}
if (path == "")
{
bool TestReload = true;
int ObCount = 0;
while (TestReload)
{
Console.WriteLine("BMDevs Obfuscator.");
if (path == "")
{
Console.Write("Input an assembly: ");
path = Console.ReadLine();
}
Worker = new Worker(path);
Console.WriteLine("Choose options to obfuscate: ");
for (int i = 0; i < Worker.Obfuscations.Count; i++) Console.WriteLine(i + 1 + ") " + Worker.Obfuscations[i]);
string opts = Console.ReadLine();
Worker.ExecuteObfuscations(opts);
//Worker.Save();
//Console.ReadLine();
ObCount++;
Console.WriteLine("Do you want to reload: y\\n?");
string CommandContinu = Console.ReadLine();
if (CommandContinu == "n") TestReload = false;
}
Worker.Save();
}
//Console.ReadLine();
}
public static void RemakeNameToOriginal()
{
if (File.Exists(path))
{
if (!path.Contains("_BMFuscator")) path = path.Substring(0, path.Length - 4) + "_BMFuscator.exe";
string TFile = path;
string Name = path.Substring(0, path.Length - 15) + ".exe";
File.Create(Name).Dispose();
File.WriteAllBytes(Name, File.ReadAllBytes(TFile));
File.Delete(TFile);
}
}
public static void DoLoop()
{
Worker = new Worker(path);
DoSingle("ControlFlowObfuscation");
//DoSingle("JunkProtection");
//DoSingle("BoolsToModuleReference"); //Little Slow
//DoSingle("BytesToModuleReference"); //Little Slow
//DoSingle("NumbersToModuleReference"); //Little Slow
//DoSingle("ConstantsEncoding"); //Create very big delay
DoSingle("MutationObf");
//DoSingle("ReferenceProxy"); //app doesnt start
//DoSingle("HiddenNamespace");
DoSingle("RenameObfuscation");
//DoSingle("ModuleRenaming");
DoSingle("NumbersToModuleReference"); //Little Slow
//DoSingle("AntiDe4dotProtection");
//DoSingle("AntiILDasmProtection");
Worker.Save();
Worker = null;
//RemakeNameToOriginal();
}
public static void DoSingle(string opts)
{
/*1) ConstantsEncoding
2) ModuleRenaming
3) HiddenNamespace
4) ReferenceProxy
5) RenameObfuscation
6) MutationObf
7) NumbersToModuleReference
8) JunkProtection
9) ControlFlowObfuscation*/
Worker.ExecuteObfuscations(opts);
/*int retrunr = 0;
if (opts == "ConstantsEncoding") retrunr = 1;
if (opts == "ModuleRenaming") retrunr = 2;
if (opts == "HiddenNamespace") retrunr = 3;
if (opts == "ReferenceProxy") retrunr = 4;
if (opts == "RenameObfuscation") retrunr = 5;
if (opts == "MutationObf") retrunr = 6;
if (opts == "NumbersToModuleReference") retrunr = 7;
if (opts == "JunkProtection") retrunr = 8;
if (opts == "ControlFlowObfuscation") retrunr = 9;
if (opts == "BoolsToModuleReference") retrunr = 10;
if (opts == "BytesToModuleReference") retrunr = 11;
Worker.ExecuteObfuscations(retrunr.ToString());*/
}
}
}

View File

@ -1,32 +0,0 @@

/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using dnlib;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using Krawk.Helpers;
namespace Krawk_Protector.Protections
{
class AntiDbg : IObfuscation
{
public void Execute(ModuleDefMD ManifestModule)
{
ModuleDefMD typeModule = ModuleDefMD.Load(typeof(Krawk.Runtime.AntiDebug).Module);
TypeDef typeDef = typeModule.ResolveTypeDef(MDToken.ToRID(typeof(Krawk.Runtime.AntiDebug).MetadataToken));
IEnumerable<IDnlibDef> members = InjectHelper.Inject(typeDef, krawk.GlobalType, krawk.ManifestModule);
decryptmethod = (MethodDef)members.Single(method => method.Name == "StartAntiDebug");
}
public void ProtectionPhase(Context krawk)
{
int cctorbdycount = krawk.cctor.Body.Instructions.Count;
krawk.cctor.Body.Instructions.Insert(cctorbdycount - 1, Instruction.Create(OpCodes.Call, decryptmethod));
}
}
}*/

View File

@ -1,65 +0,0 @@
using dnlib.DotNet;
namespace BMDevs.Protections
{
class AntiDe4dotProtection : IObfuscation
{
public void Execute(ModuleDefMD md)
{
InterfaceImpl interfaceM = new InterfaceImplUser(md.GlobalType);
TypeDef typeDef1 = new TypeDefUser("", "Form", md.CorLibTypes.GetTypeRef("System", "Attribute"));
InterfaceImpl item1 = new InterfaceImplUser(typeDef1);
md.Types.Add(typeDef1);
typeDef1.Interfaces.Add(item1);
TypeDef typeDef2 = new TypeDefUser("", "Program", md.CorLibTypes.GetTypeRef("System", "Attribute"));
InterfaceImpl item2 = new InterfaceImplUser(typeDef2);
md.Types.Add(typeDef2);
typeDef2.Interfaces.Add(item2);
for (int i = 1; i < 55; i++)
{
typeDef1 = new TypeDefUser("", "Form" + i.ToString(), md.CorLibTypes.GetTypeRef("System", "Attribute"));
item1 = new InterfaceImplUser(typeDef1);
md.Types.Add(typeDef1);
typeDef1.Interfaces.Add(item1);
}
for (int i = 1; i < 34; i++)
{
typeDef1 = new TypeDefUser("", "class" + i.ToString(), md.CorLibTypes.GetTypeRef("System", "Attribute"));
item1 = new InterfaceImplUser(typeDef1);
md.Types.Add(typeDef1);
typeDef1.Interfaces.Add(item1);
}
for (int i = 1; i < 70; i++)
{
typeDef1 = new TypeDefUser("", "parm" + i.ToString(), md.CorLibTypes.GetTypeRef("System", "Attribute"));
item1 = new InterfaceImplUser(typeDef1);
md.Types.Add(typeDef1);
typeDef1.Interfaces.Add(item1);
}
for (int i = 1; i < 10; i++)
{
typeDef1 = new TypeDefUser("", "struct" + i.ToString(), md.CorLibTypes.GetTypeRef("System", "Attribute"));
item1 = new InterfaceImplUser(typeDef1);
md.Types.Add(typeDef1);
typeDef1.Interfaces.Add(item1);
}
for (int i = 1; i < 20; i++)
{
typeDef1 = new TypeDefUser("", "ctrl" + i.ToString(), md.CorLibTypes.GetTypeRef("System", "Attribute"));
item1 = new InterfaceImplUser(typeDef1);
md.Types.Add(typeDef1);
typeDef1.Interfaces.Add(item1);
}
for (int i = 1; i < 40; i++)
{
typeDef1 = new TypeDefUser("", "Data" + i.ToString(), md.CorLibTypes.GetTypeRef("System", "Attribute"));
item1 = new InterfaceImplUser(typeDef1);
md.Types.Add(typeDef1);
typeDef1.Interfaces.Add(item1);
}
}
}
}

View File

@ -1,45 +0,0 @@
using dnlib.DotNet;
namespace BMDevs.Protections
{
class AntiILDasmProtection : IObfuscation
{
public void Execute(ModuleDefMD ManifestModule)
{
TypeRef supressref = ManifestModule.CorLibTypes.GetTypeRef("System.Runtime.CompilerServices", "SuppressIldasmAttribute");
var ctorRef = new MemberRefUser(ManifestModule, ".ctor", MethodSig.CreateInstance(ManifestModule.CorLibTypes.Void), supressref);
var supressattribute = new CustomAttribute(ctorRef);
ManifestModule.CustomAttributes.Add(supressattribute);
TypeRef supressref2 = ManifestModule.CorLibTypes.GetTypeRef("System.Runtime.CompilerServices", "UnsafeValueTypeAttribute");
var ctorRef2 = new MemberRefUser(ManifestModule, ".ctor", MethodSig.CreateInstance(ManifestModule.CorLibTypes.Void), supressref2);
var supressattribute2 = new CustomAttribute(ctorRef2);
ManifestModule.CustomAttributes.Add(supressattribute2);
TypeRef supressref3 = ManifestModule.CorLibTypes.GetTypeRef("System.Runtime.CompilerServices", "RuntimeWrappedException");
var ctorRef3 = new MemberRefUser(ManifestModule, ".ctor", MethodSig.CreateInstance(ManifestModule.CorLibTypes.Void), supressref3);
var supressattribute3 = new CustomAttribute(ctorRef3);
ManifestModule.CustomAttributes.Add(supressattribute3);
TypeRef supressref4 = ManifestModule.CorLibTypes.GetTypeRef("System.Runtime.CompilerServices", "UnverifiableCodeAttribute");
var ctorRef4 = new MemberRefUser(ManifestModule, ".ctor", MethodSig.CreateInstance(ManifestModule.CorLibTypes.Void), supressref4);
var supressattribute4 = new CustomAttribute(ctorRef4);
ManifestModule.CustomAttributes.Add(supressattribute4);
TypeRef supressref5 = ManifestModule.CorLibTypes.GetTypeRef("System.Runtime.CompilerServices", "SuppressUnmanagedCodeSecurity");
var ctorRef5 = new MemberRefUser(ManifestModule, ".ctor", MethodSig.CreateInstance(ManifestModule.CorLibTypes.Void), supressref5);
var supressattribute5 = new CustomAttribute(ctorRef5);
ManifestModule.CustomAttributes.Add(supressattribute5);
TypeRef supressref6 = ManifestModule.CorLibTypes.GetTypeRef("System.Runtime.CompilerServices", "ProtectedByBMDevs");
var ctorRef6 = new MemberRefUser(ManifestModule, ".ctor", MethodSig.CreateInstance(ManifestModule.CorLibTypes.Void), supressref6);
var supressattribute6 = new CustomAttribute(ctorRef6);
ManifestModule.CustomAttributes.Add(supressattribute6);
/*TypeRef supressref7 = ManifestModule.CorLibTypes.GetTypeRef("System.Runtime.CompilerServices", "BMDevsProperties");
var ctorRef7 = new MemberRefUser(ManifestModule, ".ctor", MethodSig.CreateInstance(ManifestModule.CorLibTypes.Void), supressref7);
var supressattribute7 = new CustomAttribute(ctorRef7);
ManifestModule.CustomAttributes.Add(supressattribute7);*/
}
}
}

View File

@ -1,124 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using Krawk_Protector.Utils;
using Krawk.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Krawk.Helpers;
namespace Krawk_Protector.Protections
{
class CalliProtection : IProtector
{
string IProtector.Name => "CalliProtection";
private MethodDef decryptionmethod;
void IProtector.InjectPhase(Context krawk) {
ModuleDefMD typeModule = ModuleDefMD.Load(typeof(CalliRuntime).Module);
TypeDef typeDef = typeModule.ResolveTypeDef(MDToken.ToRID(typeof(CalliRuntime).MetadataToken));
IEnumerable<IDnlibDef> members = InjectHelper.Inject(typeDef, krawk.GlobalType, krawk.ManifestModule);
decryptionmethod = (MethodDef)members.Single(method => method.Name == "ResolveToken");
}
public static int token2 = 0;
public static List<MemberRef> listmember = new List<MemberRef>();
public static List<int> listtoken = new List<int>();
void IProtector.ProtectionPhase(Context krawk)
{
var module = krawk.ManifestModule;
foreach (TypeDef type in module.Types.ToArray())
{
if (type.Namespace.Contains(".My")) continue;
foreach (MethodDef method in type.Methods.ToArray())
{
if (method.Equals(decryptionmethod))
{
}
else
{
if (type.IsGlobalModuleType) continue;
if (method.ToString().Contains("Program")) continue;
if (method.HasBody)
{
if (method.Body.HasInstructions)
{
for (int i = 0; i < method.Body.Instructions.Count - 1; i++)
{
try
{
if (method.Body.Instructions[i].OpCode == OpCodes.Call || method.Body.Instructions[i].OpCode == OpCodes.Callvirt || method.Body.Instructions[i].OpCode == OpCodes.Ldloc_S)
{
try
{
MemberRef membertocalli = (MemberRef)method.Body.Instructions[i].Operand;
token2 = membertocalli.MDToken.ToInt32();
if (!membertocalli.ToString().Contains("ResolveToken"))
{
if (!membertocalli.HasThis)
{
if (listmember.Contains(membertocalli))
{
method.Body.Instructions[i].OpCode = OpCodes.Calli;
method.Body.Instructions[i].Operand = listmember[listmember.IndexOf(membertocalli)].MethodSig;
method.Body.Instructions.Insert(i, Instruction.Create(OpCodes.Call, decryptionmethod));
method.Body.Instructions.Insert(i, Instruction.Create(OpCodes.Ldc_I8, (long)(listtoken[listmember.IndexOf(membertocalli)])));
}
else
{
MethodSig MethodSign = membertocalli.MethodSig;
method.Body.Instructions[i].OpCode = OpCodes.Calli;
method.Body.Instructions[i].Operand = MethodSign;
method.Body.Instructions.Insert(i, Instruction.Create(OpCodes.Call, decryptionmethod));
method.Body.Instructions.Insert(i, Instruction.Create(OpCodes.Ldc_I8,(long)token2));
listmember.Add(membertocalli);
listtoken.Add(token2);
}
}
}
}
catch (Exception ex)
{
string str = ex.Message;
}
}
}
catch
{
}
}
}
else
{
}
}
}
}
foreach (MethodDef md in module.GlobalType.Methods)
{
if (md.Name == ".ctor")
{
module.GlobalType.Remove(md);
break;
}
}
}
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,83 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using Krawk_Protector.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Constants
{
class ConstantsMelt : IProtector
{
string IProtector.Name => "ConstantsMelt";
private CilBody body;
void IProtector.InjectPhase(Context krawk) { }
void IProtector.ProtectionPhase(Context krawk)
{
foreach (ModuleDef module in krawk.Assembly.Modules)
{
foreach (TypeDef type in module.Types)
{
foreach (MethodDef method in type.Methods)
{
if (!method.HasBody) continue;
if (method.HasBody) if (!method.Body.HasInstructions) continue;
body = method.Body;
for (int i = 0; i < body.Instructions.Count; i++)
{
if (method.Body.Instructions[i].OpCode == OpCodes.Ldstr)
{
Mutate(krawk, method, i, "String");
i += 2;
}
if(method.Body.Instructions[i].IsLdcI4())
{
Mutate(krawk, method, i, "Int");
}
}
body.SimplifyBranches();
body.OptimizeBranches();
}
}
}
}
private void Mutate(Context krawk, MethodDef method, int i, string type)
{
{
//faltou umas local!
Local local = null;
if (type == "String")
{
local = new Local(krawk.ManifestModule.CorLibTypes.String);
}
else if (type == "Int")
{
local = new Local(krawk.ManifestModule.CorLibTypes.Int32);
}
method.Body.Variables.Add(local);
method.Body.Instructions.Insert(i + 1, Instruction.Create(OpCodes.Stloc_S, local));
method.Body.Instructions.Insert(i + 2, Instruction.Create(OpCodes.Ldloc_S, local));
//Inicio
//
}
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,65 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using Krawk_Protector.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Constants
{
class NumbersMutation : IProtector
{
string IProtector.Name => "NumbersMutation";
private CilBody body;
void IProtector.InjectPhase(Context krawk) { }
void IProtector.ProtectionPhase(Context krawk)
{
foreach (ModuleDef module in krawk.Assembly.Modules)
{
foreach (TypeDef type in module.Types)
{
if (type.Namespace.Contains(".My")) continue;
foreach (MethodDef method in type.Methods)
{
if (!method.HasBody) continue;
if (method.Name.Contains("Krawk_Protector_N")) continue;
if (method.HasBody) if (!method.Body.HasInstructions) continue;
body = method.Body;
for (int i = 0; i < body.Instructions.Count; i++)
{
if (body.Instructions[i].OpCode == OpCodes.Ldc_I4)
{
Mutate(krawk, method, i);
i += 2;
}
}
body.SimplifyBranches();
body.OptimizeBranches();
}
}
}
}
private void Mutate(Context krawk, MethodDef method, int i)
{
body = method.Body;
int rndkey = Utils.Generator.RandomInt(0, int.MaxValue);
int newoperand = body.Instructions[i].GetLdcI4Value() + rndkey;
body.Instructions[i] = Instruction.CreateLdcI4(newoperand);
body.Instructions.Insert(i + 1, Instruction.CreateLdcI4(rndkey));
body.Instructions.Insert(i + 2, OpCodes.Sub.ToInstruction());
}
}
}

View File

@ -1,154 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using Krawk_Protector.Utils;
using System;
namespace Krawk_Protector.Protections.Constants
{
class SizeofProtection : IProtector
{
string IProtector.Name => "SizeofProtection";
private CilBody body;
private static Random rndx = new Random();
void IProtector.InjectPhase(Context krawk) { }
void IProtector.ProtectionPhase(Context krawk)
{
foreach (ModuleDef module in krawk.Assembly.Modules)
{
foreach (TypeDef type in module.Types)
{
if (type.Namespace.Contains(".My")) continue;
foreach (MethodDef method in type.Methods)
{
if (method.HasBody && method.Body.HasInstructions)
{
if (method.Name.Contains("Krawk_Protector_N")) continue;
for (int i = 0; i < method.Body.Instructions.Count; i++)
{
if (method.Body.Instructions[i].OpCode == OpCodes.Ldc_I4)
{
body = method.Body;
int atual = body.Instructions[i].GetLdcI4Value();
int sub = rndx.Next(1, 3);
int calculado = atual - sub;
body.Instructions[i].Operand = calculado;
Start(i, sub, calculado, krawk, method);
}
}
}
}
}
}
}
private void Start(int i, int sub, int calculado, Context krawk, MethodDef method)
{
switch (sub)
{
case 1:
//CORRECT
Local local_1 = new Local(krawk.ManifestModule.CorLibTypes.Object);
Local local_2 = new Local(krawk.ManifestModule.CorLibTypes.Object);
Local local_3 = new Local(krawk.ManifestModule.CorLibTypes.Object);
Local local_4 = new Local(krawk.ManifestModule.CorLibTypes.Object);
method.Body.Variables.Add(local_1);
method.Body.Variables.Add(local_2);
method.Body.Variables.Add(local_3);
method.Body.Variables.Add(local_4);
body.Instructions.Insert(i + 1, new Instruction(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(GCNotificationStatus))));
body.Instructions.Insert(i + 2, new Instruction(OpCodes.Stloc_S, local_1));
body.Instructions.Insert(i + 3, new Instruction(OpCodes.Ldloc_S, local_1));
body.Instructions.Insert(i + 4, OpCodes.Add.ToInstruction());
body.Instructions.Insert(i + 5, new Instruction(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(SByte))));
body.Instructions.Insert(i + 6, new Instruction(OpCodes.Stloc_S, local_2));
body.Instructions.Insert(i + 7, new Instruction(OpCodes.Ldloc_S, local_2));
body.Instructions.Insert(i + 8, OpCodes.Sub.ToInstruction());
body.Instructions.Insert(i + 9, new Instruction(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(SByte))));
body.Instructions.Insert(i + 10, new Instruction(OpCodes.Stloc_S, local_3));
body.Instructions.Insert(i + 11, new Instruction(OpCodes.Ldloc_S, local_3));
body.Instructions.Insert(i + 12, OpCodes.Sub.ToInstruction());
body.Instructions.Insert(i + 13, new Instruction(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(SByte))));
body.Instructions.Insert(i + 14, new Instruction(OpCodes.Stloc_S, local_4));
body.Instructions.Insert(i + 15, new Instruction(OpCodes.Ldloc_S, local_4));
body.Instructions.Insert(i + 16, OpCodes.Sub.ToInstruction());
break;
case 2:
//CORRECT
local_1 = new Local(krawk.ManifestModule.CorLibTypes.Object);
method.Body.Variables.Add(local_1);
body.Instructions.Insert(i +1, new Instruction(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(char))));
body.Instructions.Insert(i +2, new Instruction(OpCodes.Stloc_S, local_1));
body.Instructions.Insert(i + 3, new Instruction(OpCodes.Ldloc_S, local_1));
body.Instructions.Insert(i + 4, OpCodes.Add.ToInstruction());
break;
case 3:
local_1 = new Local(krawk.ManifestModule.CorLibTypes.Object);
local_2 = new Local(krawk.ManifestModule.CorLibTypes.Object);
method.Body.Variables.Add(local_1);
method.Body.Variables.Add(local_2);
body.Instructions.Insert(i + 1, Instruction.Create(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(System.Int32))));
body.Instructions.Insert(i + 2, new Instruction(OpCodes.Stloc_S, local_1));
body.Instructions.Insert(i + 3, new Instruction(OpCodes.Ldloc_S, local_1));
body.Instructions.Insert(i + 4, Instruction.Create(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(byte))));
body.Instructions.Insert(i + 5, new Instruction(OpCodes.Stloc_S, local_2));
body.Instructions.Insert(i + 6, new Instruction(OpCodes.Ldloc_S, local_2));
body.Instructions.Insert(i + 7, Instruction.Create(OpCodes.Sub));
body.Instructions.Insert(i + 8, Instruction.Create(OpCodes.Add));
break;
case 4:
local_1 = new Local(krawk.ManifestModule.CorLibTypes.Object);
local_2 = new Local(krawk.ManifestModule.CorLibTypes.Object);
local_3 = new Local(krawk.ManifestModule.CorLibTypes.Object);
local_4 = new Local(krawk.ManifestModule.CorLibTypes.Object);
method.Body.Variables.Add(local_1);
method.Body.Variables.Add(local_2);
method.Body.Variables.Add(local_3);
method.Body.Variables.Add(local_4);
body.Instructions.Insert(i + 1, Instruction.Create(OpCodes.Add));
body.Instructions.Insert(i + 2, Instruction.Create(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(System.Decimal))));
body.Instructions.Insert(i + 3, new Instruction(OpCodes.Stloc_S, local_1));
body.Instructions.Insert(i + 4, new Instruction(OpCodes.Ldloc_S, local_1));
body.Instructions.Insert(i + 5, Instruction.Create(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(System.GCCollectionMode))));
body.Instructions.Insert(i + 6, new Instruction(OpCodes.Stloc_S, local_2));
body.Instructions.Insert(i + 7, new Instruction(OpCodes.Ldloc_S, local_2));
body.Instructions.Insert(i + 8, Instruction.Create(OpCodes.Sub));
body.Instructions.Insert(i + 9, Instruction.Create(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(System.Int32))));
body.Instructions.Insert(i + 10, new Instruction(OpCodes.Stloc_S, local_3));
body.Instructions.Insert(i + 11, new Instruction(OpCodes.Ldloc_S, local_3));
body.Instructions.Insert(i + 12, Instruction.Create(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(byte))));
body.Instructions.Insert(i + 13, new Instruction(OpCodes.Stloc_S, local_4));
body.Instructions.Insert(i + 14, new Instruction(OpCodes.Ldloc_S, local_4));
body.Instructions.Insert(i + 15, Instruction.Create(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(byte))));
body.Instructions.Insert(i + 16, new Instruction(OpCodes.Stloc_S, local_1));
body.Instructions.Insert(i + 17, new Instruction(OpCodes.Ldloc_S, local_1));
body.Instructions.Insert(i + 18, Instruction.Create(OpCodes.Sub));
body.Instructions.Insert(i + 19, Instruction.Create(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(byte))));
body.Instructions.Insert(i + 20, new Instruction(OpCodes.Stloc_S, local_2));
body.Instructions.Insert(i + 21, new Instruction(OpCodes.Ldloc_S, local_2));
body.Instructions.Insert(i + 22, Instruction.Create(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(byte))));
body.Instructions.Insert(i + 23, new Instruction(OpCodes.Stloc_S, local_2));
body.Instructions.Insert(i + 24, new Instruction(OpCodes.Ldloc_S, local_2));
body.Instructions.Insert(i + 25, Instruction.Create(OpCodes.Add));
break;
case 5:
local_1 = new Local(krawk.ManifestModule.CorLibTypes.Object);
local_2 = new Local(krawk.ManifestModule.CorLibTypes.Object);
method.Body.Variables.Add(local_1);
method.Body.Variables.Add(local_2);
body.Instructions.Insert(i + 1, new Instruction(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(System.EnvironmentVariableTarget))));
body.Instructions.Insert(i + 2, Instruction.Create(OpCodes.Stloc_S, local_1));
body.Instructions.Insert(i + 3, Instruction.Create(OpCodes.Ldloc_S, local_1));
body.Instructions.Insert(i + 4, OpCodes.Add.ToInstruction());
body.Instructions.Insert(i + 5, new Instruction(OpCodes.Sizeof, krawk.ManifestModule.Import(typeof(SByte))));
body.Instructions.Insert(i + 6, Instruction.Create(OpCodes.Stloc_S, local_2));
body.Instructions.Insert(i + 7, Instruction.Create(OpCodes.Ldloc_S, local_2));
body.Instructions.Insert(i + 9, OpCodes.Add.ToInstruction());
break;
}
}
}
}

View File

@ -1,33 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using Microsoft.VisualBasic;
using Krawk.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.VisualBasic;
using Krawk_Protector.Utils;
namespace Krawk_Protector.Protections.Constants
{
class StringProtection : IProtector
{
string IProtector.Name => "StringProtection";
public void InjectPhase(Context Krawk)
{
}
public void ProtectionPhase(Context Krawk)
{
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,176 +0,0 @@
using BMDevs.Runtime;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using dnlib.PE;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Text;
namespace BMDevs
{
public class ConstantsEncoding : IObfuscation
{
public int CurrentIndex { get; set; } = 0;
public MethodDef Decryptor { get; set; }
public List<byte> array = new List<byte>();
public Dictionary<RVA, List<Tuple<int, int, int>>> Keys = new Dictionary<RVA, List<Tuple<int, int, int>>>();
public void Execute(ModuleDefMD md)
{
var consttype = RuntimeHelper.GetRuntimeType("BMDevs.Runtime.Constants");
//var consttype = RuntimeHelper.GetRuntimeType("AsStrongAsFuck.Runtime.Constants");
FieldDef field = consttype.FindField("array");
Renamer.Rename(field, Renamer.RenameMode.Invalid2, 2);
//Renamer.Rename(field, Renamer.RenameMode.Base64, 2);
field.DeclaringType = null;
foreach (TypeDef type in md.Types)
foreach (MethodDef method in type.Methods)
if (method.HasBody && method.Body.HasInstructions)
ExtractStrings(method);
md.GlobalType.Fields.Add(field);
MethodDef todef = consttype.FindMethod("Get");
todef.DeclaringType = null;
todef.Body.Instructions[59].Operand = field;
Renamer.Rename(todef, Renamer.RenameMode.Invalid2);
//Renamer.Rename(todef, Renamer.RenameMode.Logical);
md.GlobalType.Methods.Add(todef);
MethodDef init = consttype.FindMethod("Initialize");
MethodDef add = consttype.FindMethod("Set");
init.DeclaringType = null;
init.Body.Instructions[3].Operand = field;
List<Instruction> insts = new List<Instruction>(add.Body.Instructions);
insts[1].Operand = field;
insts[insts.Count - 1].OpCode = OpCodes.Nop;
insts.RemoveAt(0);
insts[1].OpCode = OpCodes.Ldc_I4;
insts[2].OpCode = OpCodes.Ldc_I4;
var compressed = Compress(array.ToArray());
for (int i = 0; i < compressed.Length; i++)
{
insts[1].Operand = i;
insts[2].Operand = Convert.ToInt32(compressed[i]);
for (int x = insts.Count - 1; x >= 0; x--)
{
init.Body.Instructions.Insert(4, new Instruction(insts[x].OpCode, insts[x].Operand));
}
}
init.Body.Instructions[init.Body.Instructions.Count - 1 - 1].Operand = field;
init.Body.Instructions[init.Body.Instructions.Count - 1 - 99].Operand = field;
Renamer.Rename(init, Renamer.RenameMode.Invalid2, 2);
//Renamer.Rename(init, Renamer.RenameMode.Base64, 2);
md.GlobalType.Methods.Add(init);
Decryptor = todef;
MethodDef cctor = md.GlobalType.FindOrCreateStaticConstructor();
cctor.Body = new CilBody();
cctor.Body.Instructions.Add(new Instruction(OpCodes.Ldc_I4, compressed.Length));
cctor.Body.Instructions.Add(new Instruction(OpCodes.Call, init));
cctor.Body.Instructions.Add(new Instruction(OpCodes.Ret));
foreach (TypeDef type2 in md.Types)
foreach (MethodDef method2 in type2.Methods)
if (method2.HasBody && method2.Body.HasInstructions)
ReferenceReplace(method2);
}
public void ReferenceReplace(MethodDef method)
{
method.Body.SimplifyBranches();
if (Keys.ContainsKey(method.RVA))
{
List<Tuple<int, int, int>> keys = Keys[method.RVA];
keys.Reverse();
foreach (Tuple<int, int, int> v in keys)
{
method.Body.Instructions[v.Item1].Operand = "BMDevs Protected Property";
//method.Body.Instructions[v.Item1].Operand = "AsStrongAsFuck - Obfuscator by Charter (vk.com/violent_0)";
method.Body.Instructions.Insert(v.Item1 + 1, new Instruction(OpCodes.Ldc_I4, v.Item2));
method.Body.Instructions.Insert(v.Item1 + 2, new Instruction(OpCodes.Ldc_I4, v.Item3));
method.Body.Instructions.Insert(v.Item1 + 3, new Instruction(OpCodes.Call, Decryptor));
}
}
method.Body.OptimizeBranches();
}
public void ExtractStrings(MethodDef method)
{
List<Tuple<int, int, int>> shit = new List<Tuple<int, int, int>>();
foreach (Instruction instr in method.Body.Instructions)
{
bool flag = instr.OpCode == OpCodes.Ldstr;
if (flag)
{
string code = (string)instr.Operand;
byte[] bytes = Encoding.UTF8.GetBytes(code);
foreach (byte v in bytes)
{
array.Add(v);
}
var curname = Encoding.Default.GetBytes(method.Name);
const int p = 16777619;
int hash = -2128831035;
for (int i = 0; i < curname.Length; i++)
hash = (hash ^ curname[i]) * p;
hash += hash << 13;
hash ^= hash >> 7;
shit.Add(new Tuple<int, int, int>(method.Body.Instructions.IndexOf(instr), CurrentIndex - hash, bytes.Length));
CurrentIndex += bytes.Length;
}
}
if (!Keys.ContainsKey(method.RVA))
Keys.Add(method.RVA, shit);
}
public static byte[] Compress(byte[] data)
{
MemoryStream ms = new MemoryStream();
DeflateStream ds = new DeflateStream(ms, CompressionMode.Compress);
ds.Write(data, 0, data.Length);
ds.Flush();
ds.Close();
return ms.ToArray();
}
public static byte[] Decompress(byte[] data)
{
const int BUFFER_SIZE = 256;
byte[] tempArray = new byte[BUFFER_SIZE];
List<byte[]> tempList = new List<byte[]>();
int count = 0, length = 0;
MemoryStream ms = new MemoryStream(data);
DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress);
while ((count = ds.Read(tempArray, 0, BUFFER_SIZE)) > 0)
{
if (count == BUFFER_SIZE)
{
tempList.Add(tempArray);
tempArray = new byte[BUFFER_SIZE];
}
else
{
byte[] temp = new byte[count];
Array.Copy(tempArray, 0, temp, 0, count);
tempList.Add(temp);
}
length += count;
}
byte[] retVal = new byte[length];
count = 0;
foreach (byte[] temp in tempList)
{
Array.Copy(temp, 0, retVal, count, temp.Length);
count += temp.Length;
}
return retVal;
}
}
}

View File

@ -1,21 +0,0 @@
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.ControlFlow
{
public class Block
{
public Block()
{
Instructions = new List<Instruction>();
}
public List<Instruction> Instructions { get; set; }
public int Number { get; set; }
public int Next { get; set; }
}
}

View File

@ -1,62 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.ControlFlow
{
public class BlockParser
{
public static List<Block> ParseMethod(MethodDef method)
{
List<Block> blocks = new List<Block>();
List<Instruction> body = new List<Instruction>(method.Body.Instructions);
//splitting into blocks (Thanks to CodeOfDark#6320)
Block block = new Block();
int Id = 0;
int usage = 0;
block.Number = Id;
block.Instructions.Add(Instruction.Create(OpCodes.Nop));
blocks.Add(block);
block = new Block();
Stack<ExceptionHandler> handlers = new Stack<ExceptionHandler>();
foreach (Instruction instruction in method.Body.Instructions)
{
foreach (var eh in method.Body.ExceptionHandlers)
{
if (eh.HandlerStart == instruction || eh.TryStart == instruction || eh.FilterStart == instruction)
handlers.Push(eh);
}
foreach (var eh in method.Body.ExceptionHandlers)
{
if (eh.HandlerEnd == instruction || eh.TryEnd == instruction)
handlers.Pop();
}
int stacks, pops;
instruction.CalculateStackUsage(out stacks, out pops);
block.Instructions.Add(instruction);
usage += stacks - pops;
if (stacks == 0)
{
if (instruction.OpCode != OpCodes.Nop)
{
if ((usage == 0 || instruction.OpCode == OpCodes.Ret) && handlers.Count == 0)
{
block.Number = ++Id;
blocks.Add(block);
block = new Block();
}
}
}
}
return blocks;
}
}
}

View File

@ -1,35 +0,0 @@
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.ControlFlow
{
public class Block
{
public int ID = 0;
public int nextBlock = 0;
public List<Instruction> instructions = new List<Instruction>();
}
public class Blocks
{
public List<Block> blocks = new List<Block>();
private static Random generator = new Random();
public Block getBlock(int id)
{
return blocks.Single(block => block.ID == id);
}
public void Scramble(out Blocks incGroups)
{
Blocks groups = new Blocks();
foreach (var group in blocks)
groups.blocks.Insert(generator.Next(0, groups.blocks.Count), group);
incGroups = groups;
}
}
}

View File

@ -1,75 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.ControlFlow
{
public class CFHelper
{
private static Random generator = new Random();
public bool HasUnsafeInstructions(MethodDef methodDef)
{
if (methodDef.HasBody)
{
if (methodDef.Body.HasVariables)
return methodDef.Body.Variables.Any(x => x.Type.IsPointer);
}
return false;
}
public Blocks GetBlocks(MethodDef method)
{
Blocks blocks = new Blocks();
Block block = new Block();
int Id = 0;
int usage = 0;
block.ID = Id;
Id++;
block.nextBlock = block.ID + 1;
block.instructions.Add(Instruction.Create(OpCodes.Nop));
blocks.blocks.Add(block);
block = new Block();
foreach (Instruction instruction in method.Body.Instructions)
{
int pops = 0;
int stacks;
instruction.CalculateStackUsage(out stacks, out pops);
block.instructions.Add(instruction);
usage += stacks - pops;
if (stacks == 0)
{
if (instruction.OpCode != OpCodes.Nop)
{
if (usage == 0 || instruction.OpCode == OpCodes.Ret)
{
block.ID = Id;
Id++;
block.nextBlock = block.ID + 1;
blocks.blocks.Add(block);
block = new Block();
}
}
}
}
return blocks;
}
public List<Instruction> Calc(int value)
{
List<Instruction> instructions = new List<Instruction>();
int num = generator.Next(0,10000);
bool once = Convert.ToBoolean(generator.Next(10000));
int num1 = generator.Next(10000);
instructions.Add(Instruction.Create(OpCodes.Ldc_I4, value - num + (once ? (0 - num1) : num1)));
instructions.Add(Instruction.Create(OpCodes.Ldc_I4, num));
instructions.Add(Instruction.Create(OpCodes.Add));
instructions.Add(Instruction.Create(OpCodes.Ldc_I4, num1));
instructions.Add(Instruction.Create(once ? OpCodes.Add : OpCodes.Sub));
return instructions;
}
}
}

View File

@ -1,195 +0,0 @@
using Krawk_Protector.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Krawk_Protector.Utils;
namespace Krawk_Protector.Protections.ControlFlow
{
public class ControlFlow : IProtector
{
string IProtector.Name => "ControlFlow";
void IProtector.InjectPhase(Context krawk) { }
void IProtector.ProtectionPhase(Context mode)
{
Executer(mode, mode);
}
void Executer(Context mode, Context krawk)
{
CFHelper cFHelper = new CFHelper();
foreach (TypeDef type in krawk.ManifestModule.Types)
{
if (type.IsGlobalModuleType) continue;
foreach (MethodDef method in type.Methods)
{
if (method.HasBody && method.Body.Instructions.Count > 0 && !method.IsConstructor)
{
if (!cFHelper.HasUnsafeInstructions(method))
{
if (DnlibUtils.Simplify(method))
{
Blocks blocks = cFHelper.GetBlocks(method);
if (blocks.blocks.Count != 1)
{
toDoBody(cFHelper, method, blocks, krawk);
}
}
DnlibUtils.Optimize(method);
}
}
}
}
}
void toDoBody(CFHelper cFHelper, MethodDef method, Blocks blocks, Context pandaContext)
{
blocks.Scramble(out blocks);
method.Body.Instructions.Clear();
Local local = new Local(pandaContext.ManifestModule.CorLibTypes.Int32);
method.Body.Variables.Add(local);
Instruction target = Instruction.Create(OpCodes.Nop);
Instruction instr = Instruction.Create(OpCodes.Br, target);
foreach (Instruction instruction in cFHelper.Calc(0))
method.Body.Instructions.Add(instruction);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Stloc, local));
method.Body.Instructions.Add(Instruction.Create(OpCodes.Br, instr));
method.Body.Instructions.Add(target);
foreach (Block block in blocks.blocks)
{
if (block != blocks.getBlock((blocks.blocks.Count - 1)))
{
method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldloc, local));
foreach (Instruction instruction in cFHelper.Calc(block.ID))
method.Body.Instructions.Add(instruction);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Ceq));
Instruction instruction4 = Instruction.Create(OpCodes.Nop);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Brfalse, instruction4));
foreach (Instruction instruction in block.instructions)
method.Body.Instructions.Add(instruction);
foreach (Instruction instruction in cFHelper.Calc(block.nextBlock))
method.Body.Instructions.Add(instruction);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Stloc, local));
method.Body.Instructions.Add(instruction4);
}
}
method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldloc, local));
foreach (Instruction instruction in cFHelper.Calc(blocks.blocks.Count - 1))
method.Body.Instructions.Add(instruction);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Ceq));
method.Body.Instructions.Add(Instruction.Create(OpCodes.Brfalse, instr));
method.Body.Instructions.Add(Instruction.Create(OpCodes.Br, blocks.getBlock((blocks.blocks.Count - 1)).instructions[0]));
method.Body.Instructions.Add(instr);
foreach (Instruction lastBlock in blocks.getBlock((blocks.blocks.Count - 1)).instructions)
method.Body.Instructions.Add(lastBlock);
}
}
public class ObfuscationMethodUtil
{
public static bool canObfuscate(MethodDef methodDef)
{
if (!methodDef.HasBody)
return false;
if (!methodDef.Body.HasInstructions)
return false;
if (methodDef.DeclaringType.IsGlobalModuleType)
return false;
return true;
}
}
class DnlibUtils
{
public static IEnumerable<IDnlibDef> FindDefinitions(ModuleDef module)
{
yield return module;
foreach (TypeDef type in module.GetTypes())
{
yield return type;
foreach (MethodDef method in type.Methods)
yield return method;
foreach (FieldDef field in type.Fields)
yield return field;
foreach (PropertyDef prop in type.Properties)
yield return prop;
foreach (EventDef evt in type.Events)
yield return evt;
}
}
public static IEnumerable<IDnlibDef> FindDefinitions(TypeDef typeDef)
{
yield return typeDef;
foreach (TypeDef nestedType in typeDef.NestedTypes)
yield return nestedType;
foreach (MethodDef method in typeDef.Methods)
yield return method;
foreach (FieldDef field in typeDef.Fields)
yield return field;
foreach (PropertyDef prop in typeDef.Properties)
yield return prop;
foreach (EventDef evt in typeDef.Events)
yield return evt;
}
public static bool IsDelegate(TypeDef type)
{
if (type.BaseType == null)
return false;
string fullName = type.BaseType.FullName;
return fullName == "System.Delegate" || fullName == "System.MulticastDelegate";
}
public static bool HasInstructions(MethodDef method)
{
if (method == null)
new ArgumentNullException("method is null");
if (method.Body.HasInstructions)
return true;
else
return false;
}
public static bool HasVariables(MethodDef method)
{
if (method == null)
new ArgumentNullException("method is null");
if (method.Body.HasVariables)
return true;
else
return false;
}
public static bool Simplify(MethodDef methodDef)
{
if (methodDef.Parameters == null)
return false;
methodDef.Body.SimplifyMacros(methodDef.Parameters);
return true;
}
public static bool Optimize(MethodDef methodDef)
{
if (methodDef.Body == null)
return false;
methodDef.Body.OptimizeMacros();
methodDef.Body.OptimizeBranches();
return true;
}
public static bool hasExceptionHandlers(MethodDef methodDef)
{
if (methodDef.Body.HasExceptionHandlers)
return true;
return false;
}
}
}

View File

@ -1,99 +0,0 @@
using BMDevs.Runtime;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System.Collections.Generic;
using System.Linq;
namespace BMDevs.ControlFlow
{
public class ControlFlowObfuscation : IObfuscation
{
public ModuleDef Module { get; set; }
public void Execute(ModuleDefMD md)
{
Module = md;
for (int x = 0; x < md.Types.Count; x++)
{
var tDef = md.Types[x];
if (tDef != md.GlobalType)
for (int i = 0; i < tDef.Methods.Count; i++)
{
var mDef = tDef.Methods[i];
if (!mDef.Name.StartsWith("get_") && !mDef.Name.StartsWith("set_"))
{
if (!mDef.HasBody || mDef.IsConstructor) continue;
mDef.Body.SimplifyBranches();
ExecuteMethod(mDef);
}
}
}
}
public void ExecuteMethod(MethodDef method)
{
method.Body.SimplifyMacros(method.Parameters);
List<Block> blocks = BlockParser.ParseMethod(method);
blocks = Randomize(blocks);
method.Body.Instructions.Clear();
Local local = new Local(Module.CorLibTypes.Int32);
method.Body.Variables.Add(local);
Instruction target = Instruction.Create(OpCodes.Nop);
Instruction instr = Instruction.Create(OpCodes.Br, target);
foreach (Instruction instruction in Calc(0))
method.Body.Instructions.Add(instruction);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Stloc, local));
method.Body.Instructions.Add(Instruction.Create(OpCodes.Br, instr));
method.Body.Instructions.Add(target);
foreach (Block block in blocks)
{
if (block != blocks.Single(x => x.Number == blocks.Count - 1))
{
method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldloc, local));
foreach (Instruction instruction in Calc(block.Number))
method.Body.Instructions.Add(instruction);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Ceq));
Instruction instruction4 = Instruction.Create(OpCodes.Nop);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Brfalse, instruction4));
foreach (Instruction instruction in block.Instructions)
method.Body.Instructions.Add(instruction);
foreach (Instruction instruction in Calc(block.Number + 1))
method.Body.Instructions.Add(instruction);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Stloc, local));
method.Body.Instructions.Add(instruction4);
}
}
method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldloc, local));
foreach (Instruction instruction in Calc(blocks.Count - 1))
method.Body.Instructions.Add(instruction);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Ceq));
method.Body.Instructions.Add(Instruction.Create(OpCodes.Brfalse, instr));
method.Body.Instructions.Add(Instruction.Create(OpCodes.Br, blocks.Single(x => x.Number == blocks.Count - 1).Instructions[0]));
method.Body.Instructions.Add(instr);
foreach (Instruction lastBlock in blocks.Single(x => x.Number == blocks.Count - 1).Instructions)
method.Body.Instructions.Add(lastBlock);
}
public List<Block> Randomize(List<Block> input)
{
List<Block> ret = new List<Block>();
foreach (var group in input)
ret.Insert(RuntimeHelper.Random.Next(0, ret.Count), group);
return ret;
}
public List<Instruction> Calc(int value)
{
List<Instruction> instructions = new List<Instruction>();
instructions.Add(Instruction.Create(OpCodes.Ldc_I4, value));
return instructions;
}
public void AddJump(IList<Instruction> instrs, Instruction target)
{
instrs.Add(Instruction.Create(OpCodes.Br, target));
}
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using dnlib.DotNet;
namespace BMDevs
{
public class HiddenNamespace : IObfuscation
{
public void Execute(ModuleDefMD md)
{
foreach (var type in md.Types)
{
type.Namespace = "";
}
}
}
}

View File

@ -1,72 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BMDevs.Runtime;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using static BMDevs.Renamer;
namespace BMDevs.Protections
{
public class JunkProtection : IObfuscation
{
public void Execute(ModuleDefMD md)
{
List<uint> junkclasses = new List<uint>();
int classnumber = RuntimeHelper.Random.Next(30, 100);
for (int i = 0; i < classnumber; i++)
{
TypeDefUser newtype = new TypeDefUser(Renamer.GetEndName(RenameMode.Invalid2, 3), Renamer.GetEndName(RenameMode.Invalid2, 3));
//TypeDefUser newtype = new TypeDefUser(Renamer.GetEndName(RenameMode.Base64, 3), Renamer.GetEndName(RenameMode.Base64, 3));
md.Types.Add(newtype);
int methodcount = RuntimeHelper.Random.Next(10, 30);
for (int x = 0; x < methodcount; x++)
{
MethodDefUser newmethod = new MethodDefUser(Renamer.GetEndName(RenameMode.Invalid2, 3), new MethodSig(CallingConvention.Default, 0, md.CorLibTypes.Void), MethodAttributes.Public | MethodAttributes.Static);
//MethodDefUser newmethod = new MethodDefUser(Renamer.GetEndName(RenameMode.Base64, 3), new MethodSig(CallingConvention.Default, 0, md.CorLibTypes.Void), MethodAttributes.Public | MethodAttributes.Static);
newtype.Methods.Add(newmethod);
newmethod.Body = new CilBody();
int localcount = RuntimeHelper.Random.Next(5, 15);
for (int j = 0; j < localcount; j++)
{
Local lcl = new Local(md.CorLibTypes.Int32);
newmethod.Body.Variables.Add(lcl);
//newmethod.Body.Instructions.Add(new Instruction(OpCodes.Ldc_I4, Renamer.GetEndName(RenameMode.Invalid2, 3)));
newmethod.Body.Instructions.Add(new Instruction(OpCodes.Ldc_I4, RuntimeHelper.Random.Next()));
newmethod.Body.Instructions.Add(new Instruction(OpCodes.Stloc, lcl));
}
newmethod.Body.Instructions.Add(new Instruction(OpCodes.Ret));
}
junkclasses.Add(newtype.Rid);
}
Console.WriteLine($"Added {classnumber} junk classes.");
foreach (var type in md.Types)
{
if (!junkclasses.Contains(type.Rid))
{
int methodcount = RuntimeHelper.Random.Next(10, 30);
for (int x = 0; x < methodcount; x++)
{
MethodDefUser newmethod = new MethodDefUser(Renamer.GetEndName(RenameMode.Invalid2, 3), new MethodSig(CallingConvention.Default, 0, md.CorLibTypes.Void), MethodAttributes.Public | MethodAttributes.Static);
//MethodDefUser newmethod = new MethodDefUser(Renamer.GetEndName(RenameMode.Base64, 3), new MethodSig(CallingConvention.Default, 0, md.CorLibTypes.Void), MethodAttributes.Public | MethodAttributes.Static);
type.Methods.Add(newmethod);
newmethod.Body = new CilBody();
int localcount = RuntimeHelper.Random.Next(5, 15);
for (int j = 0; j < localcount; j++)
{
Local lcl = new Local(md.CorLibTypes.Int32);
newmethod.Body.Variables.Add(lcl);
newmethod.Body.Instructions.Add(new Instruction(OpCodes.Ldc_I4, RuntimeHelper.Random.Next()));
newmethod.Body.Instructions.Add(new Instruction(OpCodes.Stloc, lcl));
}
newmethod.Body.Instructions.Add(new Instruction(OpCodes.Ret));
}
}
}
}
}
}

View File

@ -1,118 +0,0 @@
using Krawk_Protector.Protections.Math.Functions;
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Krawk_Protector.Utils;
namespace Krawk_Protector.Protections.Math
{
public class MathProtection : IProtector
{
string IProtector.Name => "MathProtection";
void IProtector.InjectPhase(Context krawk) { }
void IProtector.ProtectionPhase(Context krawk)
{
Generator.Generator generator = new Generator.Generator();
foreach (TypeDef tDef in krawk.ManifestModule.Types)
{
foreach (MethodDef mDef in tDef.Methods)
{
if (!mDef.HasBody) continue;
for (int i = 0; i < mDef.Body.Instructions.Count; i++)
{
if (ArithmeticUtils.CheckArithmetic(mDef.Body.Instructions[i]))
{
if (mDef.Body.Instructions[i].GetLdcI4Value() < 0)
{
iFunction iFunction = Tasks[generator.Next(5)];
List<Instruction> lstInstr = GenerateBody(iFunction.Arithmetic(mDef.Body.Instructions[i], krawk.ManifestModule), krawk);
if (lstInstr == null) continue;
mDef.Body.Instructions[i].OpCode = OpCodes.Nop;
foreach (Instruction instr in lstInstr)
{
mDef.Body.Instructions.Insert(i + 1, instr);
i++;
}
}
else
{
iFunction iFunction = Tasks[generator.Next(Tasks.Count)];
List<Instruction> lstInstr = GenerateBody(iFunction.Arithmetic(mDef.Body.Instructions[i], krawk.ManifestModule),krawk);
if (lstInstr == null) continue;
mDef.Body.Instructions[i].OpCode = OpCodes.Nop;
foreach (Instruction instr in lstInstr)
{
mDef.Body.Instructions.Insert(i + 1, instr);
i++;
}
}
}
}
}
}
}
private static List<iFunction> Tasks = new List<iFunction>()
{
new Add(),
new Sub(),
new Div(),
new Mul(),
new Xor(),
new Functions.Maths.Abs(),
new Functions.Maths.Log(),
new Functions.Maths.Log10(),
new Functions.Maths.Sin(),
new Functions.Maths.Cos(),
new Functions.Maths.Floor(),
new Functions.Maths.Round(),
new Functions.Maths.Tan(),
new Functions.Maths.Tanh(),
new Functions.Maths.Sqrt(),
new Functions.Maths.Ceiling(),
new Functions.Maths.Truncate()
};
private static List<Instruction> GenerateBody(ArithmeticVT arithmeticVTs, Context Krawk)
{
List<Instruction> instructions = new List<Instruction>();
if (IsArithmetic(arithmeticVTs.GetArithmetic()))
{
instructions.Add(new Instruction(OpCodes.Ldc_R8, arithmeticVTs.GetValue().GetX()));
instructions.Add(new Instruction(OpCodes.Ldc_R8, arithmeticVTs.GetValue().GetY()));
if (arithmeticVTs.GetToken().GetOperand() != null)
{
instructions.Add(new Instruction(OpCodes.Call, arithmeticVTs.GetToken().GetOperand()));
}
instructions.Add(new Instruction(arithmeticVTs.GetToken().GetOpCode()));
instructions.Add(new Instruction(OpCodes.Call, Krawk.ManifestModule.Import(typeof(Convert).GetMethod("ToInt32", new Type[] { typeof(double) }))));
//instructions.Add(new Instruction(OpCodes.Conv_I4));
}
else if (IsXor(arithmeticVTs.GetArithmetic()))
{
instructions.Add(new Instruction(OpCodes.Ldc_I4, (int)arithmeticVTs.GetValue().GetX()));
instructions.Add(new Instruction(OpCodes.Ldc_I4, (int)arithmeticVTs.GetValue().GetY()));
instructions.Add(new Instruction(arithmeticVTs.GetToken().GetOpCode()));
instructions.Add(new Instruction(OpCodes.Conv_I4));
}
return instructions;
}
private static bool IsArithmetic(ArithmeticTypes arithmetic)
{
return arithmetic == ArithmeticTypes.Add || arithmetic == ArithmeticTypes.Sub || arithmetic == ArithmeticTypes.Div || arithmetic == ArithmeticTypes.Mul ||
arithmetic == ArithmeticTypes.Abs || arithmetic == ArithmeticTypes.Log || arithmetic == ArithmeticTypes.Log10 || arithmetic == ArithmeticTypes.Truncate ||
arithmetic == ArithmeticTypes.Sin || arithmetic == ArithmeticTypes.Cos || arithmetic == ArithmeticTypes.Floor || arithmetic == ArithmeticTypes.Round ||
arithmetic == ArithmeticTypes.Tan || arithmetic == ArithmeticTypes.Tanh || arithmetic == ArithmeticTypes.Sqrt || arithmetic == ArithmeticTypes.Ceiling;
}
private static bool IsXor(ArithmeticTypes arithmetic)
{
return arithmetic == ArithmeticTypes.Xor;
}
}
}

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
namespace Krawk_Protector.Protections.Math.Functions
{
public class Add : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Add;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(), arithmeticEmulator.GetY()), new Token(OpCodes.Add), ArithmeticTypes));
}
}
}

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
namespace Krawk_Protector.Protections.Math.Functions
{
public class Div : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Div;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(), arithmeticEmulator.GetY()), new Token(OpCodes.Div), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Abs : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Abs;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Ceiling : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Ceiling;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Cos : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Cos;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Floor : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Floor;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Log : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Log;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Log10 : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Log10;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Round : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Round;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Sin : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Sin;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Sqrt : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Sqrt;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Tan : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Tan;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Tanh : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Tanh;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,24 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions.Maths
{
public class Truncate : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Truncate;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
List<ArithmeticTypes> arithmeticTypes = new List<ArithmeticTypes>() { ArithmeticTypes.Add, ArithmeticTypes.Sub };
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(arithmeticTypes), arithmeticEmulator.GetY()), new Token(ArithmeticUtils.GetOpCode(arithmeticEmulator.GetType), module.Import(ArithmeticUtils.GetMethod(ArithmeticTypes))), ArithmeticTypes));
}
}
}

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
namespace Krawk_Protector.Protections.Math.Functions
{
public class Mul : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Mul;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(), arithmeticEmulator.GetY()), new Token(OpCodes.Mul), ArithmeticTypes));
}
}
}

View File

@ -1,23 +0,0 @@
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Functions
{
public class Sub : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Sub;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), ArithmeticUtils.GetY(instruction.GetLdcI4Value()), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(), arithmeticEmulator.GetY()), new Token(OpCodes.Sub), ArithmeticTypes));
}
}
}

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Krawk_Protector.Protections.Math.Utils;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
namespace Krawk_Protector.Protections.Math.Functions
{
public class Xor : iFunction
{
public override ArithmeticTypes ArithmeticTypes => ArithmeticTypes.Xor;
public override ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module)
{
Generator.Generator generator = new Generator.Generator();
if (!ArithmeticUtils.CheckArithmetic(instruction)) return null;
ArithmeticEmulator arithmeticEmulator = new ArithmeticEmulator(instruction.GetLdcI4Value(), generator.Next(), ArithmeticTypes);
return (new ArithmeticVT(new Value(arithmeticEmulator.GetValue(), arithmeticEmulator.GetY()), new Token(OpCodes.Xor), ArithmeticTypes));
}
}
}

View File

@ -1,29 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Generator
{
public class Generator
{
private Random random;
public Generator()
{
random = new Random(Guid.NewGuid().GetHashCode());
}
public int Next()
{
return random.Next(int.MaxValue);
}
public int Next(int value)
{
return random.Next(value);
}
public int Next(int min, int max)
{
return random.Next(min, max);
}
}
}

View File

@ -1,231 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math
{
public class ArithmeticEmulator
{
private double x;
private double y;
private ArithmeticTypes ArithmeticTypes;
public ArithmeticTypes GetType { get; private set; }
public ArithmeticEmulator(double x, double y, ArithmeticTypes ArithmeticTypes)
{
this.x = x;
this.y = y;
this.ArithmeticTypes = ArithmeticTypes;
}
public double GetValue()
{
switch (ArithmeticTypes)
{
case ArithmeticTypes.Add:
return x - y;
case ArithmeticTypes.Sub:
return x + y;
case ArithmeticTypes.Div:
return x * y;
case ArithmeticTypes.Mul:
return x / y;
case ArithmeticTypes.Xor:
return ((int)x ^ (int)y);
}
return -1;
}
public double GetValue(List<ArithmeticTypes> arithmetics)
{
Generator.Generator generator = new Generator.Generator();
ArithmeticTypes arithmetic = arithmetics[generator.Next(arithmetics.Count)];
GetType = arithmetic;
switch (ArithmeticTypes)
{
case ArithmeticTypes.Abs:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x + (System.Math.Abs(y) * -1);
case ArithmeticTypes.Sub:
return x - (System.Math.Abs(y) * -1);
}
return -1;
case ArithmeticTypes.Log:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Log(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Log(y));
}
return -1;
case ArithmeticTypes.Log10:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Log10(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Log10(y));
}
return -1;
case ArithmeticTypes.Sin:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Sin(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Sin(y));
}
return -1;
case ArithmeticTypes.Cos:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Cos(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Cos(y));
}
return -1;
case ArithmeticTypes.Floor:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Floor(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Floor(y));
}
return -1;
case ArithmeticTypes.Round:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Round(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Round(y));
}
return -1;
case ArithmeticTypes.Tan:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Tan(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Tan(y));
}
return -1;
case ArithmeticTypes.Tanh:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Tanh(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Tanh(y));
}
return -1;
case ArithmeticTypes.Sqrt:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Sqrt(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Sqrt(y));
}
return -1;
case ArithmeticTypes.Ceiling:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Ceiling(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Ceiling(y));
}
return -1;
case ArithmeticTypes.Truncate:
switch (arithmetic)
{
case ArithmeticTypes.Add:
return x - (System.Math.Truncate(y));
case ArithmeticTypes.Sub:
return x + (System.Math.Truncate(y));
}
return -1;
}
return -1;
}
public double GetX() => x;
public double GetY() => y;
}
public enum ArithmeticTypes
{
Add, // +
Sub, // -
Div, // /
Mul, // *
Xor, // ^
Abs, // -1
Log, //
Log10,
Sin,
Cos,
Round,
Sqrt,
Ceiling,
Floor,
Tan,
Tanh,
Truncate
}
public class ArithmeticVT
{
private Value value;
private Token token;
private ArithmeticTypes arithmeticTypes;
public ArithmeticVT(Value value, Token token, ArithmeticTypes arithmeticTypes)
{
this.value = value;
this.token = token;
this.arithmeticTypes = arithmeticTypes;
}
public Value GetValue() => value;
public Token GetToken() => token;
public ArithmeticTypes GetArithmetic() => arithmeticTypes;
}
public abstract class iFunction
{
public abstract ArithmeticTypes ArithmeticTypes { get; }
public abstract ArithmeticVT Arithmetic(Instruction instruction, ModuleDef module);
}
public class Value
{
private double x;
private double y;
public Value(double x, double y)
{
this.x = x;
this.y = y;
}
public double GetX() => x;
public double GetY() => y;
}
public class Token
{
private OpCode opCode;
private object Operand;
public Token(OpCode opCode, object Operand)
{
this.opCode = opCode;
this.Operand = Operand;
}
public Token(OpCode opCode)
{
this.opCode = opCode;
this.Operand = null;
}
public OpCode GetOpCode() => opCode;
public object GetOperand() => Operand;
}
}

View File

@ -1,67 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Krawk_Protector.Protections.Math.Utils
{
public class ArithmeticUtils
{
public static bool CheckArithmetic(Instruction instruction)
{
if (!instruction.IsLdcI4())
return false;
if (instruction.GetLdcI4Value() == 1)
return false;
if (instruction.GetLdcI4Value() == 0)
return false;
return true;
}
public static double GetY(double x) => (x / 2);
public static System.Reflection.MethodInfo GetMethod(ArithmeticTypes mathType)
{
switch (mathType)
{
case ArithmeticTypes.Abs:
return ((typeof(System.Math).GetMethod("Abs", new Type[] { typeof(double) })));
case ArithmeticTypes.Round:
return ((typeof(System.Math).GetMethod("Round", new Type[] { typeof(double) })));
case ArithmeticTypes.Sin:
return ((typeof(System.Math).GetMethod("Sin", new Type[] { typeof(double) })));
case ArithmeticTypes.Cos:
return ((typeof(System.Math).GetMethod("Cos", new Type[] { typeof(double) })));
case ArithmeticTypes.Log:
return ((typeof(System.Math).GetMethod("Log", new Type[] { typeof(double) })));
case ArithmeticTypes.Log10:
return ((typeof(System.Math).GetMethod("Log10", new Type[] { typeof(double) })));
case ArithmeticTypes.Sqrt:
return ((typeof(System.Math).GetMethod("Sqrt", new Type[] { typeof(double) })));
case ArithmeticTypes.Ceiling:
return ((typeof(System.Math).GetMethod("Ceiling", new Type[] { typeof(double) })));
case ArithmeticTypes.Floor:
return ((typeof(System.Math).GetMethod("Floor", new Type[] { typeof(double) })));
case ArithmeticTypes.Tan:
return ((typeof(System.Math).GetMethod("Tan", new Type[] { typeof(double) })));
case ArithmeticTypes.Tanh:
return ((typeof(System.Math).GetMethod("Tanh", new Type[] { typeof(double) })));
case ArithmeticTypes.Truncate:
return ((typeof(System.Math).GetMethod("Truncate", new Type[] { typeof(double) })));
}
return null;
}
public static OpCode GetOpCode(ArithmeticTypes arithmetic)
{
switch (arithmetic)
{
case ArithmeticTypes.Add:
return OpCodes.Add;
case ArithmeticTypes.Sub:
return OpCodes.Sub;
}
return null;
}
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using dnlib.DotNet;
namespace BMDevs
{
public class ModuleRenaming : IObfuscation
{
public void Execute(ModuleDefMD md)
{
string shit = Renamer.GetFuckedString2(4);
//string shit = Renamer.GetRandomName();
Logger.LogMessage("Renaming module to ", shit, ConsoleColor.Red);
md.Name = shit;
}
}
}

View File

@ -1,121 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BMDevs.Helpers;
using BMDevs.Runtime;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using static BMDevs.Renamer;
namespace BMDevs
{
//HUUUUUGE THANKS TO MIGHTY!!!
public class ReferenceProxy : IObfuscation
{
public Dictionary<string, MethodDef> Proxies { get; set; }
public void Execute(ModuleDefMD md)
{
int sum = 0;
for (int i = 0; i < md.Types.Count; i++)
{
var tdef = md.Types[i];
for (int x = 0; x < tdef.Methods.Count; x++)
{
var mdef = tdef.Methods[x];
Proxies = new Dictionary<string, MethodDef>();
if (mdef.HasBody && mdef.Body.HasInstructions && !mdef.IsConstructor)
{
mdef.Body.SimplifyBranches();
ExecuteMethod(mdef);
}
sum += Proxies.Count;
}
tdef.FindOrCreateStaticConstructor().Body.Instructions.Add(new Instruction(OpCodes.Ret));
}
Console.WriteLine($"Added {sum} ref proxies.");
}
public void ExecuteMethod(MethodDef method)
{
for (int i = 0; i < method.Body.Instructions.Count; i++)
{
var instr = method.Body.Instructions[i];
if (instr.OpCode == OpCodes.Call)
{
var target = (IMethod)instr.Operand;
try
{
if (!target.ResolveMethodDefThrow().IsPublic || !target.ResolveMethodDefThrow().IsStatic || !target.DeclaringType.ResolveTypeDef().IsPublic || target.DeclaringType.ResolveTypeDef().IsSealed)
continue;
var key = target.FullName;
MethodDef value;
if (!Proxies.TryGetValue(key, out value))
{
var consttype = RuntimeHelper.GetRuntimeType("BMDevs.Runtime.RefProxy");
var proxysig = ReferenceProxyHelper.CreateProxySignature(target, method.Module);
var deleg = ReferenceProxyHelper.CreateDelegateType(proxysig, method.Module, target.ResolveMethodDef());
FieldDefUser field = new FieldDefUser("Shit", new FieldSig(deleg.ToTypeSig()));
Renamer.Rename(field, Renamer.RenameMode.Base64);
method.DeclaringType.Fields.Add(field);
field.IsStatic = true;
var typedef = target.ResolveMethodDefThrow().DeclaringType;
var mdtoken = target.ResolveMethodDef().MDToken;
var asshole = consttype.Methods.First(x => x.Name == "Load");
asshole.Body.Instructions[1].Operand = deleg;
asshole.Body.Instructions[3].Operand = method.Module.Import(typedef);
asshole.Body.Instructions[6].OpCode = OpCodes.Ldc_I4;
asshole.Body.Instructions[6].Operand = (int)mdtoken.Raw;
asshole.Body.Instructions[10].Operand = deleg;
asshole.Body.Instructions[11].Operand = field;
asshole.Body.Instructions.RemoveAt(12);
var cctor = method.DeclaringType.FindOrCreateStaticConstructor();
foreach (var item in asshole.Body.Instructions)
{
cctor.Body.Instructions.Add(item);
}
if (cctor.Body.Instructions[0].OpCode == OpCodes.Ret)
cctor.Body.Instructions.RemoveAt(0);
var proxy = new MethodDefUser(Renamer.GetRandomName(), proxysig);
proxy.Attributes = MethodAttributes.PrivateScope | MethodAttributes.Static;
proxy.ImplAttributes = MethodImplAttributes.Managed | MethodImplAttributes.IL;
method.DeclaringType.Methods.Add(proxy);
proxy.Body = new CilBody();
proxy.Body.Instructions.Add(Instruction.Create(OpCodes.Ldsfld, field));
for (int x = 0; x < target.ResolveMethodDefThrow().Parameters.Count; x++)
proxy.Body.Instructions.Add(Instruction.Create(OpCodes.Ldarg, proxy.Parameters[x]));
proxy.Body.Instructions.Add(Instruction.Create(OpCodes.Callvirt, deleg.FindMethod("Invoke")));
proxy.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));
value = proxy;
Proxies.Add(key, value);
}
//Console.WriteLine($"{key} - {value}");
instr.Operand = value;
}
catch
{
Console.WriteLine("CAN'T DO: " + target.FullName);
}
}
}
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,27 +0,0 @@
using dnlib.DotNet;
using Krawk_Protector.Utils;
using System;
using System.Linq;
namespace Krawk_Protector.Protections
{
class RenameAssembly : IProtector
{
string IProtector.Name => "RenameAssembly";
void IProtector.InjectPhase(Context krawk) { }
void IProtector.ProtectionPhase(Context krawk)
{
Random rnd = new Random();
var ManifestModule = krawk.ManifestModule;
const string chars = "糜級糠素絲絮綋維綖綰緊緌緌綅綟綣絡絇絈絋紭累糺糗糎粫粨粍粶粒籐籓籰米";
string xD = new string(Enumerable.Repeat(chars, 10)
.Select(s => s[rnd.Next(s.Length)]).ToArray());
string xD1 = new string(Enumerable.Repeat(chars, 10)
.Select(s => s[rnd.Next(s.Length)]).ToArray());
ManifestModule.Name = string.Format(" Krawk - {0} ",xD);
ManifestModule.Assembly.Name = string.Format(" Krawk - {0} ", xD1);
}
}
}

View File

@ -1,70 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using dnlib.DotNet;
namespace BMDevs
{
public class RenameObfuscation : IObfuscation
{
public void Execute(ModuleDefMD md)
{
foreach (var type in md.Types)
{
foreach (var method in type.Methods.Where(x => !x.IsConstructor && !x.IsVirtual && !x.IsManaged))
{
//Console.WriteLine(method.Name);
if (method.Name != "Main")
{
Renamer.Rename(method, Renamer.RenameMode.Invalid2, 3);
//Renamer.Rename(method, Renamer.RenameMode.Logical, 3);
}
}
bool CanGo = true;
foreach (var method in type.CustomAttributes)
{
//Console.WriteLine(method.ToString());
//if (method.ToString().Contains("DoNotObfuscate") || method.TypeFullName.ToString().Contains("DoNotObfuscate")) CanGo = false;
if (method.ToString().Contains("DoNotObfuscate")) CanGo = false;
continue;
}
if (CanGo)
{
foreach (var method in type.NestedTypes)
{
//Console.WriteLine(method.Name);
Renamer.Rename(method, Renamer.RenameMode.Invalid2, 3);
}
foreach (var method in type.Fields.Where(x => !x.IsAssembly))
{
if (method.DeclaringType == method.Module.GlobalType)
{
//Console.WriteLine(method.Name);
return;
}
//Console.WriteLine(method.Name);
Renamer.Rename(method, Renamer.RenameMode.Invalid2, 3);
}
/*foreach (var method in type.Events)
{
Renamer.Rename(method, Renamer.RenameMode.Invalid2, 3);
}
foreach (var method in type.Properties)
{
Renamer.Rename(method, Renamer.RenameMode.Invalid2, 3);
}*/
}
}
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Runtime
{
public class BoolsToModule
{
public static int val;
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Runtime
{
public class BytesToModule
{
public static int val;
}
}

View File

@ -1,77 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Runtime
{
public class Constants
{
public static string Get(string one, int key, int len)
{
StackTrace trace = new StackTrace();
var data = Encoding.Default.GetBytes(trace.GetFrame(1).GetMethod().Name);
const int p = 16777619;
int hash = -2128831035;
for (int i = 0; i < data.Length; i++)
hash = (hash ^ data[i]) * p;
hash += hash << 13;
hash ^= hash >> 7;
List<byte> shit = new List<byte>();
key += hash;
for (int i = 0; i < len; i++)
{
shit.Add(array[key + i]);
}
return Encoding.UTF8.GetString(shit.ToArray());
}
public static void Initialize(int len)
{
array = new byte[len];
const int BUFFER_SIZE = 256;
byte[] tempArray = new byte[BUFFER_SIZE];
List<byte[]> tempList = new List<byte[]>();
int count = 0, length = 0;
MemoryStream ms = new MemoryStream(array);
DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress);
while ((count = ds.Read(tempArray, 0, BUFFER_SIZE)) > 0)
{
if (count == BUFFER_SIZE)
{
tempList.Add(tempArray);
tempArray = new byte[BUFFER_SIZE];
}
else
{
byte[] temp = new byte[count];
Array.Copy(tempArray, 0, temp, 0, count);
tempList.Add(temp);
}
length += count;
}
byte[] retVal = new byte[length];
count = 0;
foreach (byte[] temp in tempList)
{
Array.Copy(temp, 0, retVal, count, temp.Length);
count += temp.Length;
}
array = retVal;
}
public static void Set()
{
array[0] = 0;
}
public static byte[] array = new byte[] { };
}
}

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Runtime
{
public class FuncMutation
{
public static int CharToInt(char shi)
{
return shi;
}
public static int RET(int i)
{
return i;
}
public readonly static Func<int, int> prao;
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Runtime
{
public class NumbersToModule
{
public static int val;
}
}

View File

@ -1,61 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace AsStrongAsFuck.Runtime
{
public class Packer
{
public static void Initialize(int len)
{
array = new byte[len];
const int BUFFER_SIZE = 256;
byte[] tempArray = new byte[BUFFER_SIZE];
List<byte[]> tempList = new List<byte[]>();
int count = 0, length = 0;
MemoryStream ms = new MemoryStream(array);
DeflateStream ds = new DeflateStream(ms, CompressionMode.Decompress);
while ((count = ds.Read(tempArray, 0, BUFFER_SIZE)) > 0)
{
if (count == BUFFER_SIZE)
{
tempList.Add(tempArray);
tempArray = new byte[BUFFER_SIZE];
}
else
{
byte[] temp = new byte[count];
Array.Copy(tempArray, 0, temp, 0, count);
tempList.Add(temp);
}
length += count;
}
byte[] retVal = new byte[length];
count = 0;
foreach (byte[] temp in tempList)
{
Array.Copy(temp, 0, retVal, count, temp.Length);
count += temp.Length;
}
array = retVal;
}
public static void Set()
{
array[0] = 0;
}
public static void Load()
{
Assembly.Load(array);
}
public static byte[] array = new byte[] { };
}
}

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Runtime
{
public class RefProxy
{
public static void Load()
{
Exec = (Execute)Delegate.CreateDelegate(typeof(Execute), typeof(Console).Module.ResolveMethod(0) as MethodInfo);
}
public static Execute Exec;
public delegate void Execute();
}
}

View File

@ -1,242 +0,0 @@
using BMDevs.Runtime;
using dnlib.DotNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs
{
public class Renamer
{
public static List<string> CryptedTextAllString = new List<string> { };
public static List<string> CryptedTextAllString2 = new List<string> { };
//public static List<string> CryptedTextAllString3 = new List<string> { };
//public static List<string> CryptedTextAllString4 = new List<string> { };
static Random rnd = new Random();
public static void Rename(IMemberDef member, RenameMode mode, int depth = 1, int sublength = 10)
{
member.Name = GetEndName(mode, depth, sublength);
}
public static string GetEndName(RenameMode mode, int depth = 1, int sublength = 10)
{
string endname = string.Empty;
for (int i = 0; i < depth; i++)
{
endname += GetName(mode, sublength);
}
return endname;
}
public static string GetName(RenameMode mode, int length)
{
switch (mode)
{
case RenameMode.Base64:
return GetRandomName().Base64Representation();
case RenameMode.Chinese:
return GetChineseString(length);
case RenameMode.Invalid:
return GetFuckedString(length);
case RenameMode.Invalid2:
return GetFuckedString2(length);
case RenameMode.Invalid3:
return GetFuckedString3(length);
case RenameMode.Logical:
return GetRandomName();
default:
throw new InvalidOperationException();
}
}
public enum RenameMode
{
Base64,
Chinese,
Invalid,
Invalid2,
Invalid3,
Logical
}
public static string GetChineseString(int len)
{
string shit = "";
for (int i = 0; i < len; i++)
{
shit += ChineseCharacters[RuntimeHelper.Random.Next(ChineseCharacters.Length)];
}
return shit;
//#########################################################
/*string CryptedGenerated = "";
CryptedGenerated += ChineseCharacters[0];
if (CryptedTextAllString4.Count > 0)
{
bool Exist = false;
for (int i = 0; i < CryptedTextAllString4.Count; i++) if (CryptedTextAllString4[i] == CryptedGenerated) Exist = true;
while (Exist)
{
//regenerate
CryptedGenerated += ChineseCharacters[rnd.Next(0, ChineseCharacters.Length)];
//recheck
Exist = false;
for (int i = 0; i < CryptedTextAllString4.Count; i++) if (CryptedTextAllString4[i] == CryptedGenerated) Exist = true;
}
}
//Add to list
CryptedTextAllString4.Add(CryptedGenerated);
return CryptedGenerated;*/
}
public static char[] ChineseCharacters => new char[]
{
'㐀',
'㐁',
'㐂',
'㐃',
'㐄',
'㐅',
'㐆',
'㐇',
'㐈',
'㐉',
'㐊'
};
public static string GetRandomName()
{
return Names[RuntimeHelper.Random.Next(Names.Length)];
}
public static string[] Names =
{
"HasPermission", "HasPermissions", "GetPermissions", "GetOpenWindows", "EnumWindows", "GetWindowText", "GetWindowTextLength", "IsWindowVisible", "GetShellWindow", "Awake", "FixedUpdate", "add_OnRockedInitialized", "remove_OnRockedInitialized", "Awake", "Initialize", "Translate", "Reload", "<Initialize>b__13_0", "Initialize", "FixedUpdate", "Start", "checkTimerRestart", "QueueOnMainThread", "QueueOnMainThread", "RunAsync", "RunAction", "Awake", "FixedUpdate", "IsUri", "GetTypes", "GetTypesFromParentClass", "GetTypesFromParentClass", "GetTypesFromInterface", "GetTypesFromInterface", "get_Timeout", "set_Timeout", "GetWebRequest", "get_SteamID64", "set_SteamID64", "get_SteamID", "set_SteamID", "get_OnlineState", "set_OnlineState", "get_StateMessage", "set_StateMessage", "get_PrivacyState", "set_PrivacyState", "get_VisibilityState", "set_VisibilityState", "get_AvatarIcon", "set_AvatarIcon", "get_AvatarMedium", "set_AvatarMedium", "get_AvatarFull", "set_AvatarFull", "get_IsVacBanned", "set_IsVacBanned", "get_TradeBanState", "set_TradeBanState", "get_IsLimitedAccount", "set_IsLimitedAccount", "get_CustomURL", "set_CustomURL", "get_MemberSince", "set_MemberSince", "get_HoursPlayedLastTwoWeeks", "set_HoursPlayedLastTwoWeeks", "get_Headline", "set_Headline", "get_Location", "set_Location", "get_RealName", "set_RealName", "get_Summary", "set_Summary", "get_MostPlayedGames", "set_MostPlayedGames", "get_Groups", "set_Groups", "Reload", "ParseString", "ParseDateTime", "ParseDouble", "ParseUInt16", "ParseUInt32", "ParseUInt64", "ParseBool", "ParseUri", "IsValidCSteamID", "LoadDefaults", "LoadDefaults", "get_Clients", "Awake", "handleConnection", "FixedUpdate", "Broadcast", "OnDestroy", "Read", "Send", "<Awake>b__8_0", "get_InstanceID", "set_InstanceID", "get_ConnectedTime", "set_ConnectedTime", "Send", "Read", "Close", "get_Address", "get_Instance", "set_Instance", "Save", "Load", "Unload", "Load", "Save", "Load", "get_Configuration", "LoadPlugin", "<.ctor>b__3_0", "<LoadPlugin>b__4_0", "add_OnPluginUnloading", "remove_OnPluginUnloading", "add_OnPluginLoading", "remove_OnPluginLoading", "get_Translations", "get_State", "get_Assembly", "set_Assembly", "get_Directory", "set_Directory", "get_Name", "set_Name", "get_DefaultTranslations", "IsDependencyLoaded", "ExecuteDependencyCode", "Translate", "ReloadPlugin", "LoadPlugin", "UnloadPlugin", "OnEnable", "OnDisable", "Load", "Unload", "TryAddComponent", "TryRemoveComponent", "add_OnPluginsLoaded", "remove_OnPluginsLoaded", "get_Plugins", "GetPlugins", "GetPlugin", "GetPlugin", "Awake", "Start", "GetMainTypeFromAssembly", "loadPlugins", "unloadPlugins", "Reload", "GetAssembliesFromDirectory", "LoadAssembliesFromDirectory", "<Awake>b__12_0", "GetGroupsByIds", "GetParentGroups", "HasPermission", "GetGroup", "RemovePlayerFromGroup", "AddPlayerToGroup", "DeleteGroup", "SaveGroup", "AddGroup", "GetGroups", "GetPermissions", "GetPermissions", "<GetGroups>b__11_3", "Start", "FixedUpdate", "Reload", "HasPermission", "GetGroups", "GetPermissions", "GetPermissions", "AddPlayerToGroup", "RemovePlayerFromGroup", "GetGroup", "SaveGroup", "AddGroup", "DeleteGroup", "DeleteGroup", "<FixedUpdate>b__4_0", "Enqueue", "_Logger_DoWork", "processLog", "Log", "Log", "var_dump", "LogWarning", "LogError", "LogError", "Log", "LogException", "ProcessInternalLog", "logRCON", "writeToConsole", "ProcessLog", "ExternalLog", "Invoke", "_invoke", "TryInvoke", "get_Aliases", "get_AllowedCaller", "get_Help", "get_Name", "get_Permissions", "get_Syntax", "Execute", "get_Aliases", "get_AllowedCaller", "get_Help", "get_Name", "get_Permissions", "get_Syntax", "Execute", "get_Aliases", "get_AllowedCaller", "get_Help", "get_Name", "get_Permissions", "get_Syntax", "Execute", "get_Name", "set_Name", "get_Name", "set_Name", "get_Name", "get_Help", "get_Syntax", "get_AllowedCaller", "get_Commands", "set_Commands", "add_OnExecuteCommand", "remove_OnExecuteCommand", "Reload", "Awake", "checkCommandMappings", "checkDuplicateCommandMappings", "Plugins_OnPluginsLoaded", "GetCommand", "GetCommand", "getCommandIdentity", "getCommandType", "Register", "Register", "Register", "DeregisterFromAssembly", "GetCooldown", "SetCooldown", "Execute", "RegisterFromAssembly"
};
//Thanks to Awware#5671
//public const string Hell = ";̥͓̠̙̠̺̫̱̹̮͈͈͓͍̟̻͆ͧ͒ͩͨ̉ͯ̂̈̉̽̉͑̔̊́͟͜;̢̧͔͓͉̝̆̒ͣͣ̄ͣ̊̈́̎̓͛̇͆ͯͪ̿͟;ͫͭ͒̉̐͑̀҉̭̭͕̟͇̰̺͖͎̗̰̩͉;̸̛̘̬̫̫͔̜͙̣̯̠̯̻͍̰͍̥͓ͦ̎ͯͯ͂ͤ̉̃̊͐̐̽͜;̵̧̂͐̉̆́̚̚҉̜̦̳͇͍;̙͈̞̪̖͚̬͍͙̹ͭ̿͒ͧͧͨ̀;͐̇̋̍̿̎̀͌ͣ͌҉ ̞̙̘̱͟͠_̍̽̋̑͒ͧ̌͐̿͞͡҉̯̣̥̹̗̫̥̩͈̘͟ͅͅ_̈͛̈͊̈́ͥͬ̌ͪ̃̽͑̓͋͛̆̈͋̽҉̸̛̠̝̜͈̮͢_͒͂̋̈́͋̉͒ͦ̊ͯ̐̾̂̐҉҉̧̯̜̣̮̦̱̦̖̗͡_̧̨̹̳̘̯̱͖͙̘̍ͥ͊͌̌ͧͥ̍ͨ̐͡_̵̺̮̞̖̰͔̮̺̳͖̳̳̥͖͖͊͐͛ͥͪ͛͑͠ͅ_ͧ̓ ̴̡̪͎̣̘̳̤̬͔̟̺̳̻̥͇ͧͫ̽͐̄ͤ̎̔_̸̠̪̺͕̩̮̹̦͇̫͙͖̦̻̏̈́̅ͦ͐_̴̸̢͚̤͙͓̱̬̫̝̞̣̥̽͛͊ͥͬ̍͆ͨ͑͋̍͊ͭ͗́ͅ^̵͖̖̹̦͎̦̜͋̉͋͐̈́ͪ̋̊̄́͘͟ ̨͚͙͖̫͚̙̊̏̍̐ͥ̅̏̎͆͗ͧ́̚͞!̧͕͈͕͙̱̟̆ͭ͋ͫ̕͢͞;̛̣̭̖̹̜̘̮̜̭͓̰̫͙͋̏ͯͤ̂ͬ͗ͥ̌ͥ̓ͮͪ͗́͞ͅ;̪̳̼̱̽ͨ͋͛̔ͪͬ̃͌̂̌͐̀ͧͬ̾ͨ̚̚;̛͍̘̗̣͉͓̘͖͙̪͙̦͇̩͈ͩ͋̄̓ͣ́̃ͦͫ͒̑͋̃ͣͥ̋̀;̢͚̰͈͍ͮͤͣ͂̆͋ͨ̀̐̕͞͞ͅ;̨̢̬̹̯̯̤͕͍̺̩̫͈͉̙̪̪̜̻͚̂͋̏̓͛ͣ͟;̥̖̭͕͔̝͇̞̠̰͐̿̆ͣ̈͟͡;̵̸̻̫͔̼͚̤͇̝̞̬̞͚͇̓̐͆̾ͭ̈́ͫ̈́́͜͞;̌ͨ͌̐̉̂̃̅̃̋ͤͤͣͯ҉̧̹̗̺̹͈̙͇̦̣ͅ;̸̫̙͈̫̮̻͎̱͓̗̍a_̈͛̈͊̈́ͥͬ̌ͪ̃̽͑̓͋͛̆̈͋̽҉̸̛̠̝̜͈̮͢_͒";
public const string Hell = "b̸̵̝̘͍̪̫̘̩̙̺̜͓̺̈́̌̒̈ͭc̨̛̥͈̞̺͔̞̼ͧ͆̈̾̐͋̎̚͜͝ͅd̷̢͈̣͇͙̤̦̟̱̺̩̦͎̞̬̿ͨͪ̈́̓̏ͫͫ̌͆̎̌ͦ̄̈̔̚̚͟e̛̒͂͌̓ͣͬ͗̉ͣͬ͆̃̒͂f̸̡͈͍̳̯̖̣̱͊͊͋̂̚̚ǧ̴̵̡̼͎̻̝̲̹̲̖͂̐̿̆ͪ̎̍͒̿̓̂͘͟ẖ̸̵̢̢̝̥̬̯̯̼͊̏̋ͩͨͫͪ̆̍ͦ̒̾͋̐̉̈ͥ̏ͥ͡i̶̸̧̪͙͓̯̠̱̝̤͇̅̆͑ͮͭͮ̽͢͜j̧̡͕̮̘͕̞̹̤̾̇ͤ͂͐͊ͦͮ͟͠k̶̼̰̘̲̪͎̲̟͇̰̪̪̗̅́ͤ͐͗͑͑͐̓̊͑ͯ̒̊̎ͮ̆̚̕l̴͚͎̙̻͎̟̩͓͕̜̀̉̓̀͛̿ͣ̆̿̊̃ͨ̄̇̔̀ͣ̒ͣm̨̫͈̣̦̼̱̦͓͈̲͙̫͈͔̞̟͙̠̲͑͑ͦͦ͛ͧ̓̕͝n̑̆͑͋͆̏̊ͭͫ̾ͭ̇ͩ̒̒ͩ̏̚̕o̭͖̘͙̹͎̦̮̪̠̓ͦ̅̒ͣ̑ͬ̓ͪ̊ͫͤͭ̕͜͠ͅp̷̨̧͇̗̩͉̲̱̙̬̖̜̝̤̻̱̝̮͕̯͑̒̍͋ͦ̊͘q́͐ͤ̄̃͌͗̔ͯ̈́̀̀͏͈͕͍̲͓̜̳̲̤̪̱̞̣̼͙̩̯̘s̶̡̺̙̪̣͎̟͉̟̥̜͈̯̳̪̀̑͐́̇ͩͥ̑ͪ̔ͪ͂ͤ̐̾̈́͑̄͘̕͡ţ̶̝͖͓̟̝̳̻̱͖̟͙̜̬̳̯̤ͨ̓̂́ͯ̾͒ͫ̿̇͐ͪͩ͐͋ͬ͑̄̚͢͞u̶̠̘̗̻̼͓̤͓̦̯̝̹̳̺̹͗̽̑̇͌ͯ͐͌̿ͤ͢ͅv̸́͛̓͛͌̅ͯ͌ͮ̆͊ͦ̂̇ͯͪͫ͏̷̙̻̖ẅ̴̶̷̡͎̭̺͙͚̤͒͑͆ͣͥͫ͊ͯ̈̒͛̚͟x̗̟̬͔̤̻̟̎ͥ̀̅͑ͨͥ͌ͣ̍̑̽ͤ̇̿̈́̈́ͬ͘͝ͅy͍͔̬̫͙̝̼͎̭͔̥̻̩̺͎̤̻̤̑ͫ̃ͫ̀̍̿̎̄͐͌͌͢z̴͓͍̗̥̤͌ͬ̑̓̈́͋̏̽̐̋͌͛̾ͮ̾̕͢͝Å̷̢̰̺̻̟͕̫̱̯͔̫̯͕̪̘͉̬ͯ̄ͭ̄ͫ̀ͯB̴̩͇̫͙͆ͭͣ͌͑̂ͬͮ̈̄̔ͨ̏̑ͨ͊͆͂́͝Ç̧̻̠͈͈͕̞̥̭̦̳̯͈̤̲̈́͗͐̆́͊̍̀̑̾̇ͤͭ̍ͫ̽͘Ḏ̛̥̘̟͎̹͍͖̩̳̾̽ͮ̾ͫ̿̓͆́ͨͮͦͩ͌̀̚E̺̳̭͚̣̠̳̹̩̝̹̝̺̳̬̙̥̙̹ͭ̽͛̉ͭ͋̊̚͢F̡̝̭̪̣͓̼͍̩̩̲̪̲͒ͨ̈ͦ̋͒͑͐͐͂͊̾̊ͪ̕͢͠͠ͅͅG̛͌̈̄ͬ̾͒̎ͦ͂ͣ̓͟Ḣ̵̳̪̦͖̥̭͚̼͐̔ͨͬ̇͋̑ͥ͐̀́͘͜I̽̀̀̉̇̋̈̊͒͋͛̓͛̋̑J͛ͪ̌͆̽ͯͨ̈̄ͦ͜͡͏̲͇̞̝͚̻̗̬͕̞̞̩̭̕͡K͋ͭ̄́̽͌̏̂̉͛Ļ̴̥̟̩̟̪͚̟͖̟̫̺̤͎̮̜͙ͯͩ̃͆͋ͤ̓̎ͣ̆̓ͭ͝M̰͎͍͇̞͖͓ͣͤ̾̂ͭ̂́͒̌ͩ͘͜͡͠Ņ̨͈͚͔̭̲͎̗̤̫̣͓͙̟ͨͪͮ̈́̎͐̾ͭͩ̈́̄̎͋̊ͣ̄́ͧ͋͘͜O̵ͯ̑̎̓͒̐̔̋̈́͌̄̿͋̋̈͐͏P̷̸̢̨̼̗̬̬̥͕̪̲̗̰̞̫̖̙̯̭͖͊̉ͭ̊̀̈́̕Q̞̝͔͌̇ͬͨ̔ͮ̉͒̔ͭ̎͌͝͡͡R̰̺̟̺͈͂̏͛ͭ́̀͡͡͝S̴̸͚͖̫͉̙̹̭̯̱̺̠͎̻̻̳̮͍̓́ͬ̈̃̎ͤ̄ͫͤͦͫ̚͟͠͡ͅT̛̮̗͚̖̬̺͔̮̝͈͇̦̐̓̇́̒ͫ̀͢͟U͉͈͍̖̫̳̙̥̼̹̘͍̔̈́͑̐͛ͥ̿ͧ̔ͩ̚͠͞V̸̒̔̒ͧͭ̎̆͗ͥͥͩ̈́ͬ̔ͦ́̔̚̚Ŵ͊̈́͛̆ͤ͛͗̈́̆̾̀͛͋ͥ̊̐ͪX̨̛͈̻̮̗̙͔̠̼͖̫͙̼͉̓ͣ̊̄͒͆͒̀ͯͩ̇̓̌ͨ̍ͣ̃ͮ͠Z̨̡͍͈̖̳̹͔͕̝̘̠͐͆͆̄͢ͅ";
public const string Hell2 = "\u00A0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u205F\u2800\u3000\u30FC\u2013";
public static string GetFuckedString(int len)
{
string sta = "";
for (int i = 0; i < len; i++)
{
sta += Hell[RuntimeHelper.Random.Next(Hell.Length)];
}
return sta;
//#########################################################
/*string CryptedGenerated = "";
CryptedGenerated += Hell[0];
if (CryptedTextAllString.Count > 0)
{
bool Exist = false;
for (int i = 0; i < CryptedTextAllString.Count; i++) if (CryptedTextAllString[i] == CryptedGenerated) Exist = true;
while (Exist)
{
//regenerate
CryptedGenerated += Hell[rnd.Next(0, Hell.Length)];
//recheck
Exist = false;
for (int i = 0; i < CryptedTextAllString.Count; i++) if (CryptedTextAllString[i] == CryptedGenerated) Exist = true;
}
}
Logger.LogMessage("Generated name:", CryptedGenerated, ConsoleColor.Cyan);
//Add to list
CryptedTextAllString.Add(CryptedGenerated);
return CryptedGenerated;*/
}
public static string GetFuckedString2(int len)
{
string sta = "";
for (int i = 0; i < len; i++)
{
sta += Hell2[RuntimeHelper.Random.Next(Hell2.Length)];
}
return sta;
//#########################################################
/*string CryptedGenerated = "";
CryptedGenerated += Hell2[0];
if (CryptedTextAllString2.Count > 0)
{
bool Exist = false;
for (int i = 0; i < CryptedTextAllString2.Count; i++) if (CryptedTextAllString2[i] == CryptedGenerated) Exist = true;
while (Exist)
{
//regenerate
CryptedGenerated += Hell2[rnd.Next(0, Hell2.Length)];
//recheck
Exist = false;
for (int i = 0; i < CryptedTextAllString2.Count; i++) if (CryptedTextAllString2[i] == CryptedGenerated) Exist = true;
}
}
Logger.LogMessage("Generated name:", CryptedGenerated, ConsoleColor.Cyan);
//Add to list
CryptedTextAllString2.Add(CryptedGenerated);
return CryptedGenerated;*/
}
public static string GetFuckedString3(int len)
{
string sta = "";
for (int i = 0; i < len; i++)
{
sta += Hell[RuntimeHelper.Random.Next(Hell.Length)];
sta += Hell2[RuntimeHelper.Random.Next(Hell2.Length)];
}
return sta;
//#########################################################
/*string CryptedGenerated = "";
CryptedGenerated += Hell[0] + Hell2[0];
if (CryptedTextAllString3.Count > 0)
{
bool Exist = false;
for (int i = 0; i < CryptedTextAllString3.Count; i++) if (CryptedTextAllString3[i] == CryptedGenerated) Exist = true;
while (Exist)
{
//regenerate
CryptedGenerated += Hell[rnd.Next(0, Hell.Length)] + Hell2[rnd.Next(0, Hell2.Length)];
//recheck
Exist = false;
for (int i = 0; i < CryptedTextAllString3.Count; i++) if (CryptedTextAllString3[i] == CryptedGenerated) Exist = true;
}
}
//Add to list
CryptedTextAllString3.Add(CryptedGenerated);
return CryptedGenerated;*/
}
}
}

View File

@ -1,150 +0,0 @@
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Runtime
{
public class RuntimeHelper
{
public static OwnRandom Random { get; set; }
static RuntimeHelper()
{
Random = new OwnRandom();
}
public static ModuleDefMD RuntimeModule { get; set; } = ModuleDefMD.Load(typeof(RuntimeHelper).Assembly.Modules.First());
public static TypeDef GetRuntimeType(string fullName)
{
var type = RuntimeModule.Find(fullName, true);
return Clone(type);
}
public static Importer Importer { get; set; }
public static TypeDef Clone(TypeDef origin)
{
var ret = CopyTypeDef(origin);
foreach (TypeDef nestedType in origin.NestedTypes)
ret.NestedTypes.Add(Clone(nestedType));
foreach (MethodDef method in origin.Methods)
ret.Methods.Add(CopyMethodDef(method));
foreach (FieldDef field in origin.Fields)
ret.Fields.Add(CopyFieldDef(field));
return ret;
}
static TypeDef CopyTypeDef(TypeDef origin)
{
var ret = new TypeDefUser(origin.Namespace, origin.Name);
ret.Attributes = origin.Attributes;
if (origin.ClassLayout != null)
ret.ClassLayout = new ClassLayoutUser(origin.ClassLayout.PackingSize, origin.ClassSize);
foreach (GenericParam genericParam in origin.GenericParameters)
ret.GenericParameters.Add(new GenericParamUser(genericParam.Number, genericParam.Flags, "-"));
ret.BaseType = (ITypeDefOrRef)Importer.Import(ret.BaseType);
foreach (InterfaceImpl iface in origin.Interfaces)
ret.Interfaces.Add(new InterfaceImplUser((ITypeDefOrRef)Importer.Import(iface.Interface)));
return ret;
}
static MethodDef CopyMethodDef(MethodDef origin)
{
var newMethodDef = new MethodDefUser(origin.Name, null, origin.ImplAttributes, origin.Attributes);
foreach (GenericParam genericParam in origin.GenericParameters)
newMethodDef.GenericParameters.Add(new GenericParamUser(genericParam.Number, genericParam.Flags, "-"));
newMethodDef.Signature = Importer.Import(origin.Signature);
newMethodDef.Parameters.UpdateParameterTypes();
if (origin.ImplMap != null)
newMethodDef.ImplMap = new ImplMapUser(new ModuleRefUser(origin.Module, origin.ImplMap.Module.Name), origin.ImplMap.Name, origin.ImplMap.Attributes);
foreach (CustomAttribute ca in origin.CustomAttributes)
newMethodDef.CustomAttributes.Add(new CustomAttribute((ICustomAttributeType)Importer.Import(ca.Constructor)));
if (origin.HasBody)
{
newMethodDef.Body = new CilBody(origin.Body.InitLocals, new List<Instruction>(), new List<ExceptionHandler>(), new List<Local>());
newMethodDef.Body.MaxStack = origin.Body.MaxStack;
var bodyMap = new Dictionary<object, object>();
foreach (Local local in origin.Body.Variables)
{
var newLocal = new Local(Importer.Import(local.Type));
newMethodDef.Body.Variables.Add(newLocal);
newLocal.Name = local.Name;
newLocal.PdbAttributes = local.PdbAttributes;
bodyMap[local] = newLocal;
}
foreach (Instruction instr in origin.Body.Instructions)
{
var newInstr = new Instruction(instr.OpCode, instr.Operand);
newInstr.SequencePoint = instr.SequencePoint;
if (newInstr.Operand is IType)
newInstr.Operand = Importer.Import((IType)newInstr.Operand);
else if (newInstr.Operand is IMethod)
newInstr.Operand = Importer.Import((IMethod)newInstr.Operand);
else if (newInstr.Operand is IField)
newInstr.Operand = Importer.Import((IField)newInstr.Operand);
newMethodDef.Body.Instructions.Add(newInstr);
bodyMap[instr] = newInstr;
}
foreach (Instruction instr in newMethodDef.Body.Instructions)
{
if (instr.Operand != null && bodyMap.ContainsKey(instr.Operand))
instr.Operand = bodyMap[instr.Operand];
else if (instr.Operand is Instruction[])
instr.Operand = ((Instruction[])instr.Operand).Select(target => (Instruction)bodyMap[target]).ToArray();
}
foreach (ExceptionHandler eh in origin.Body.ExceptionHandlers)
newMethodDef.Body.ExceptionHandlers.Add(new ExceptionHandler(eh.HandlerType)
{
CatchType = eh.CatchType == null ? null : (ITypeDefOrRef)Importer.Import(eh.CatchType),
TryStart = (Instruction)bodyMap[eh.TryStart],
TryEnd = (Instruction)bodyMap[eh.TryEnd],
HandlerStart = (Instruction)bodyMap[eh.HandlerStart],
HandlerEnd = (Instruction)bodyMap[eh.HandlerEnd],
FilterStart = eh.FilterStart == null ? null : (Instruction)bodyMap[eh.FilterStart]
});
newMethodDef.Body.SimplifyMacros(newMethodDef.Parameters);
}
return newMethodDef;
}
static FieldDef CopyFieldDef(FieldDef fieldDef)
{
var newFieldDef = new FieldDefUser(fieldDef.Name, null, fieldDef.Attributes);
newFieldDef.Signature = Importer.Import(fieldDef.Signature);
return newFieldDef;
}
}
}

View File

@ -1,34 +0,0 @@
using BMDevs.Runtime;
using dnlib.DotNet.Emit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static BMDevs.Mutations.MutationObf;
namespace BMDevs
{
public class Utils
{
public static void Shuffle<T>(IList<T> list)
{
for (int i = list.Count - 1; i > 1; i--)
{
int k = RuntimeHelper.Random.Next(i + 1);
T tmp = list[k];
list[k] = list[i];
list[i] = tmp;
}
}
public static bool CheckArithmetic(Instruction instruction)
{
if (!instruction.IsLdcI4())
return false;
if (instruction.GetLdcI4Value() <= 1)
return false;
return true;
}
}
}

View File

@ -1,31 +0,0 @@
using dnlib.DotNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Utils
{
public class Context
{
public AssemblyDef Assembly;
public ModuleDef ManifestModule;
public TypeDef GlobalType;
public Importer Imp;
public MethodDef cctor;
public Context(AssemblyDef asm)
{
this.Assembly = asm;
this.ManifestModule = asm.ManifestModule;
this.GlobalType = this.ManifestModule.GlobalType;
this.Imp = new Importer(ManifestModule);
this.cctor = this.GlobalType.FindOrCreateStaticConstructor();
}
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs.Utils
{
interface IProtector
{
string Name { get; }
void InjectPhase(Context krawk);
void ProtectionPhase(Context krawk);
}
}

View File

@ -1,269 +0,0 @@
using BMDevs.Runtime;
using dnlib.DotNet;
using dnlib.DotNet.Emit;
using dnlib.DotNet.Writer;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace BMDevs
{
public class Worker
{
private Assembly OwnAssembly => this.GetType().Assembly;
public Assembly Default_Assembly { get; set; }
public AssemblyDef Assembly { get; set; }
public ModuleDefMD Module { get; set; }
public string Path { get; set; }
public string Code { get; set; }
public Worker(string path)
{
if (path != "")
{
Path = path.Replace("\"", "");
LoadAssembly();
LoadModuleDefMD();
LoadObfuscations();
LoadDependencies();
RuntimeHelper.Importer = new Importer(Module);
}
}
public void Watermark()
{
Console.WriteLine("Creating global .cctors...");
TypeDef modType = Module.GlobalType;
if (modType == null)
{
modType = new TypeDefUser("", "<Module>", null);
modType.Attributes = dnlib.DotNet.TypeAttributes.AnsiClass;
Module.Types.Add(modType);
MethodDef cctor = modType.FindOrCreateStaticConstructor();
modType.Methods.Add(cctor);
}
Console.WriteLine("Watermarking...");
TypeRef attrRef = Module.CorLibTypes.GetTypeRef("System", "Attribute");
var attrType = new TypeDefUser("", "BMDevsProtectedProperty", attrRef);
Module.Types.Add(attrType);
var ctor = new MethodDefUser(
".ctor",
MethodSig.CreateInstance(Module.CorLibTypes.Void, Module.CorLibTypes.String),
dnlib.DotNet.MethodImplAttributes.Managed,
dnlib.DotNet.MethodAttributes.HideBySig | dnlib.DotNet.MethodAttributes.Public | dnlib.DotNet.MethodAttributes.SpecialName | dnlib.DotNet.MethodAttributes.RTSpecialName);
ctor.Body = new CilBody();
ctor.Body.MaxStack = 1;
ctor.Body.Instructions.Add(OpCodes.Ldarg_0.ToInstruction());
ctor.Body.Instructions.Add(OpCodes.Call.ToInstruction(new MemberRefUser(Module, ".ctor", MethodSig.CreateInstance(Module.CorLibTypes.Void), attrRef)));
ctor.Body.Instructions.Add(OpCodes.Ret.ToInstruction());
attrType.Methods.Add(ctor);
var attr = new CustomAttribute(ctor);
attr.ConstructorArguments.Add(new CAArgument(Module.CorLibTypes.String, "BMDevs Protected Property"));
Module.CustomAttributes.Add(attr);
}
public void ExecuteObfuscations(string param)
{
Code = param;
//var shit = param.ToCharArray().ToList();
Stopwatch watch = new Stopwatch();
watch.Start();
for ( int i = 0; i < Obfuscations.Count; i++)
//foreach (var v in shit)
{
if (Obfuscations[i] == param)
{
//int i = int.Parse(v.ToString()) - 1;
//Console.WriteLine("geseg " + Obfuscations[i]);
Logger.LogMessage("Executing ", Obfuscations[i], ConsoleColor.Magenta);
Type type = OwnAssembly.GetTypes().First(x => x.Name == Obfuscations[i]);
var instance = Activator.CreateInstance(type);
MethodInfo info = type.GetMethod("Execute");
try
{
info.Invoke(instance, new object[] { Module });
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
watch.Stop();
Console.WriteLine("Time taken: " + watch.Elapsed.ToString());
}
public void LoadAssembly()
{
//try
//{
Console.WriteLine("Loading assembly...");
Default_Assembly = System.Reflection.Assembly.UnsafeLoadFrom(Path);
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(" Loaded: ");
Console.WriteLine(Default_Assembly.FullName);
Console.ForegroundColor = ConsoleColor.White;
/*}
catch(Exception mess)
{
Console.WriteLine("CANT LOAD: " + mess);
}*/
}
public void LoadModuleDefMD()
{
Console.WriteLine("Loading ModuleDefMD...");
Module = ModuleDefMD.Load(Path);
Assembly = Module.Assembly;
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(" Loaded: ");
Console.WriteLine(Module.FullName);
Console.ForegroundColor = ConsoleColor.White;
}
public void LoadDependencies()
{
Console.WriteLine("Resolving dependencies...");
var asmResolver = new AssemblyResolver();
ModuleContext modCtx = new ModuleContext(asmResolver);
asmResolver.DefaultModuleContext = modCtx;
asmResolver.EnableTypeDefCache = true;
asmResolver.DefaultModuleContext = new ModuleContext(asmResolver);
asmResolver.PostSearchPaths.Insert(0, Path);
if (IsCosturaPresent(Module))
{
foreach (var asm in ExtractCosturaEmbeddedAssemblies(GetEmbeddedCosturaAssemblies(Module), Module))
asmResolver.AddToCache(asm);
}
foreach (var dependency in Module.GetAssemblyRefs())
{
try
{
AssemblyDef assembly = asmResolver.ResolveThrow(dependency, Module);
Console.WriteLine("Resolved " + dependency.Name);
}
catch (AssemblyResolveException ex)
{
Console.WriteLine("Failed to resolve dependency of '" + dependency.Name + "'");
}
}
/*foreach (var dependency in Module.GetAssemblyRefs().Select(asmRef => Tuple.Create(asmRef, Module)))
{
try
{
AssemblyDef assembly = asmResolver.ResolveThrow(dependency.Item1, dependency.Item2);
Console.WriteLine("Resolved " + dependency.Item2.Name);
}
catch (AssemblyResolveException ex)
{
Console.WriteLine("Failed to resolve dependency of '" + dependency.Item2.Name + "':" + ex);
}
}*/
Module.Context = modCtx;
}
public bool IsCosturaPresent(ModuleDef module) =>
module.Types.FirstOrDefault(t => t.Name == "AssemblyLoader" && t.Namespace == "Costura") != null;
public string[] GetEmbeddedCosturaAssemblies(ModuleDef module)
{
var list = new List<string>();
var ctor = module.Types.Single(t => t.Name == "AssemblyLoader" && t.Namespace == "Costura").FindStaticConstructor();
var instructions = ctor.Body.Instructions;
for (var i = 1; i < instructions.Count; i++)
{
var curr = instructions[i];
if (curr.OpCode != OpCodes.Ldstr || instructions[i - 1].OpCode != OpCodes.Ldstr)
continue;
var resName = ((string)curr.Operand).ToLowerInvariant();
if (resName.EndsWith(".pdb") || resName.EndsWith(".pdb.compressed"))
{
i++;
continue;
}
list.Add((string)curr.Operand);
}
return list.ToArray();
}
public List<AssemblyDef> ExtractCosturaEmbeddedAssemblies(string[] assemblies, ModuleDef module)
{
var list = new List<AssemblyDef>();
foreach (var assembly in assemblies)
{
var resource = module.Resources.FindEmbeddedResource(assembly.ToLowerInvariant());
if (resource == null)
throw new Exception("Couldn't find Costura embedded assembly: " + assembly);
if (resource.Name.EndsWith("_BMFuscator.exe"))
{
list.Add(DecompressCosturaAssembly(resource.GetResourceStream()));
continue;
}
list.Add(AssemblyDef.Load(resource.GetResourceStream()));
}
return list;
}
public AssemblyDef DecompressCosturaAssembly(Stream resource)
{
using (var def = new DeflateStream(resource, CompressionMode.Decompress))
{
var ms = new MemoryStream();
def.CopyTo(ms);
ms.Position = 0;
return AssemblyDef.Load(ms);
}
}
public void Save()
{
Watermark();
string NewPath = Path;
if (!Path.Contains("_BMFuscator")) NewPath = Path.Substring(0, Path.Length - 4) + "_BMFuscator.exe";
Logger.LogMessage("Saving as ", NewPath, ConsoleColor.Yellow);
ModuleWriterOptions opts = new ModuleWriterOptions(Module);
opts.Logger = DummyLogger.NoThrowInstance;
Assembly.Write(NewPath, opts);
Console.WriteLine("Saved.");
}
public void LoadObfuscations()
{
Obfuscations = new List<string>();
var ass = this.GetType().Assembly;
var types = ass.GetTypes();
foreach (Type type in Enumerable.Where<Type>(types, (Type t) => t != null))
{
if (type.GetInterface("IObfuscation") != null)
{
Obfuscations.Add(type.Name);
Console.WriteLine("Loaded Module: " + type.Name);
}
}
}
public List<string> Obfuscations { get; set; }
}
}

Binary file not shown.

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

Binary file not shown.

Binary file not shown.

View File

@ -1,245 +0,0 @@
Binary_Files.cs
Binary_File_FREE.cs
Binary_File_PLAYGAME.cs
Class10.cs
Class11.cs
Class12.cs
Class13.cs
Class15.cs
Class16.cs
Class17.cs
Class18.cs
Class1.cs
Class3.cs
Class20.cs
Class21.cs
Class22.cs
Class24.cs
Class25.cs
Class27.cs
Class28.cs
Class29.cs
Class2.cs
Class30.cs
Class31.cs
Class32.cs
Class33.cs
Class5.cs
Class7.cs
Class8.cs
Class8.cs
Class9.cs
Class9.cs
ctrlAdvGraph.cs
ctrlAdvTable.cs
ctrlBatteryOffset.cs
CtrlGrid.cs
CtrlInputSelector.cs
CtrlLedDisplay.cs
ctrlMapGraph.cs
CtrlMapGraph3D.cs
CtrlOutputSelector.cs
ctrlOvrlSensor.cs
CtrlSensorGrid.cs
ctrlSpecialSensor.cs
DASM_Bytes.cs
DisplayItemsStripped.cs
Enum4.cs
Enum6.cs
frmAboutBox.cs
frmAccelTimeSetting.cs
frmActiveDatalog.cs
frmAdvancedGraph.cs
frmAdvTableAdd.cs
frmBaseMap.cs
frmBaseromConvert.cs
frmBinTool.cs
frmBluetooth.cs
frmBoostTableSetup.cs
frmBurner.cs
frmChangelog.cs
frmChartTemplates.cs
frmConsole.cs
frmConvert.cs
frmCopyMaps.cs
frmCopyright.cs
FrmDataDisplay.cs
frmDataGrid.cs
frmDatalogGraphs.cs
frmDatalogMenu.cs
frmDebug.cs
frmDownloadBaserom.cs
frmDownloadUpdate.cs
frmDynoControl.cs
frmDynoSetup.cs
frmEbcDutyErrorInput.cs
frmErrorCodes.cs
frmGaugesEditor.cs
frmGearLearn.cs
FrmGridChart.cs
frmGridSelectionAdj.cs
frmHC05.cs
frmIgnCutModWarning.cs
frmIgnitionSync.cs
frmInjectorOverallCalc.cs
frmLivePlot.cs
frmLivePSetting.cs
frmLoading.cs
FrmMain.cs
frmMapScalar.cs
frmOBD2Scan.cs
frmOnboard.cs
frmOstrichInfo.cs
frmParameters.cs
frmPassword.cs
frmQuickAdjust.cs
frmQuickSaveDesc.cs
frmQuickSaveMain.cs
frmReg.cs
frmReset.cs
frmSensorSetup.cs
frmSettings.cs
frmShortKeys.cs
frmUploadBaserom.cs
InjectorsLoading.cs
Mtss.cs
parmAc.cs
parmAntiLag.cs
parmAntiStart.cs
parmBoostCut.cs
parmBoostMapSensor.cs
parmBoostSettings.cs
parmBstManual.cs
parmBurnOut.cs
parmCloseLoop.cs
parmComments.cs
parmCrankFuel.cs
parmCylCorr.cs
parmDualMap.cs
parmDwell.cs
parmEbcCloseloop.cs
parmEbcCompensation.cs
parmEbcDutyLook.cs
parmEbcSettings.cs
parmEctCorr.cs
parmEctProtection.cs
parmFanControl.cs
parmFileProtection.cs
parmFlexFuel.cs
parmFtl.cs
parmFts.cs
parmFuelCut.cs
parmGearCorr.cs
parmGPO1_a.cs
parmGPO1_a.resx
parmGPO1_if.cs
parmGPO1_if.resx
parmGPO2_a.cs
parmGPO2_a.resx
parmGPO2_if.cs
parmGPO2_if.resx
parmGPO3_a.cs
parmGPO3_a.resx
parmGPO3_if.cs
parmGPO3_if.resx
parmIAB.cs
parmIAB.resx
parmIATcorr.cs
parmIATcorr.resx
parmIdleIgnCorr.cs
parmIdleIgnCorr.resx
parmIdleMain.cs
parmIdleMain.resx
parmInjector.cs
parmInjector.resx
parmLeanProtection.cs
parmLeanProtection.resx
parmMap.cs
parmMap.resx
parmMilShift.cs
parmMilShift.resx
parmPopcorn.cs
parmPopcorn.resx
parmRevLimit.cs
parmRevLimit.resx
parmRomOptions.cs
parmRomOptions.resx
parmSCC.cs
parmSCC.resx
parmTipInOut.cs
parmTipInOut.resx
parmTpsRetard.cs
parmTpsRetard.resx
parmTpsSensor.cs
parmTpsSensor.resx
parmTransmission.cs
parmTransmission.resx
parmVtec.cs
parmVtec.resx
Struct12.cs
Struct15.cs
Struct16.cs
Struct17.cs
Struct18.cs
Struct19.cs
Struct20.cs
Struct22.cs
Struct23.cs
Struct24.cs
CtrlDisplayItemText.cs
CtrlDisplayItemText.resx
ctrlLogGraph.cs
ctrlLogGraph.resx
ctrlMapSensor.cs
ctrlMapSensor.resx
ctrlMapValue.cs
ctrlMapValue.resx
ctrlPlotGraph.cs
ctrlPlotGraph.resx
TunerAnalogGrid.cs
SettingsFile.cs
SettingsFormatException.cs
SettingsKey.cs
AdvTableType.cs
AirFuelUnits.cs
AnalogInputs.cs
BMTuneVersions.cs
ChartCollection.cs
ChartSetup.cs
ChartTemplate.cs
CorrectionUnits.cs
DatalogButtonsTypes.cs
DatalogDisplayTypes.cs
DataloggingMode.cs
DataloggingState.cs
DataloggingTable.cs
DatalogLedTypes.cs
DoNotObfuscate.cs
EmulatorMoatesType.cs
EmulatorMode.cs
EmulatorState.cs
EmulatorVendorDemon.cs
EmulatorVendorOstrich.cs
FuelDisplayMode.cs
MapGraphSelect.cs
MapGraphType.cs
MapSensorUnits.cs
OverlayDisplaySelected.cs
QuickSaveItem.cs
QuickSaveListObjects.cs
SelectedTable.cs
SensorsX.cs
TableOverlay.cs
TemperatureUnits.cs
TunerAfrGrid.cs
TunerSmartTrack.cs
VoltUnits.cs
VssUnits.cs
WBinput.cs
Wideband_Serial.cs
frmHelp.cs
frmHelp.resx
parmHelpNew.cs
parmHelpNew.resx
Resources.Designer.cs
Resources.resx

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

View File

@ -1 +0,0 @@
7e756e5d9868f3b6f946cbfe20e96722133c3762

View File

@ -1,9 +0,0 @@
C:\Users\boule\Desktop\AsStrongAsFuck\bin\Debug\AsStrongAsFuck.exe.config
C:\Users\boule\Desktop\AsStrongAsFuck\bin\Debug\AsStrongAsFuck.exe
C:\Users\boule\Desktop\AsStrongAsFuck\bin\Debug\AsStrongAsFuck.pdb
C:\Users\boule\Desktop\AsStrongAsFuck\bin\Debug\dnlib.dll
C:\Users\boule\Desktop\AsStrongAsFuck\obj\Debug\AsStrongAsFuck.csprojAssemblyReference.cache
C:\Users\boule\Desktop\AsStrongAsFuck\obj\Debug\AsStrongAsFuck.csproj.CoreCompileInputs.cache
C:\Users\boule\Desktop\AsStrongAsFuck\obj\Debug\AsStrongAsFuck.csproj.CopyComplete
C:\Users\boule\Desktop\AsStrongAsFuck\obj\Debug\AsStrongAsFuck.exe
C:\Users\boule\Desktop\AsStrongAsFuck\obj\Debug\AsStrongAsFuck.pdb

View File

@ -1,18 +0,0 @@
C:\Users\boule\Desktop\AsStrongAsFuck\bin\Debug\dnlib.dll
C:\Users\boule\Desktop\AsStrongAsFuck\obj\Debug\BMDevs.csprojAssemblyReference.cache
C:\Users\boule\Desktop\AsStrongAsFuck\obj\Debug\BMDevs.csproj.CoreCompileInputs.cache
C:\Users\boule\Desktop\AsStrongAsFuck\obj\Debug\BMDevs.csproj.CopyComplete
C:\Users\boule\Desktop\AsStrongAsFuck\bin\Debug\BMFuscator.exe.config
C:\Users\boule\Desktop\AsStrongAsFuck\bin\Debug\BMFuscator.exe
C:\Users\boule\Desktop\AsStrongAsFuck\bin\Debug\BMFuscator.pdb
C:\Users\boule\Desktop\AsStrongAsFuck\obj\Debug\BMFuscator.exe
C:\Users\boule\Desktop\AsStrongAsFuck\obj\Debug\BMFuscator.pdb
C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\BMTune_Encrypter\bin\Debug\BMFuscator.exe.config
C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\BMTune_Encrypter\bin\Debug\BMFuscator.exe
C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\BMTune_Encrypter\bin\Debug\BMFuscator.pdb
C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\BMTune_Encrypter\bin\Debug\dnlib.dll
C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\BMTune_Encrypter\obj\Debug\BMDevs.csprojAssemblyReference.cache
C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\BMTune_Encrypter\obj\Debug\BMDevs.csproj.CopyComplete
C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\BMTune_Encrypter\obj\Debug\BMFuscator.exe
C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\BMTune_Encrypter\obj\Debug\BMFuscator.pdb
C:\Users\boule\Documents\Visual Studio 2019\Projects\BMTune2\BMTune_Encrypter\bin\Debug\FilesInfos.txt

Some files were not shown because too many files have changed in this diff Show More