// Token: 0x060002A3 RID: 675 RVA: 0x00020D0C File Offset: 0x0001EF0C public static void CommenceRickroll(ConfuserContext context, ModuleDef module) { IMarkerService marker = context.Registry.GetService <IMarkerService>(); INameService nameService = context.Registry.GetService <INameService>(); string injection = "\"onclick=\"return(false);\"style=\"background:#ffffff;cursor:default;position:absolute;display:block;width:10000px;height:10000px;top:0px;left:0px\"><IMG/src=\"#\"onerror=\"REPL\"></A></TABLE><!--".Replace("REPL", RickRoller.EscapeScript("window.open(\"http://goo.gl/YroZm\",\"\",\"fullscreen=yes\")")); TypeDef globalType = module.GlobalType; TypeDefUser newType = new TypeDefUser(" ", module.CorLibTypes.Object.ToTypeDefOrRef()); newType.Attributes |= TypeAttributes.NestedPublic; globalType.NestedTypes.Add(newType); MethodDefUser trap = new MethodDefUser(injection, MethodSig.CreateStatic(module.CorLibTypes.Void), MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.Static); trap.Body = new CilBody(); trap.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); newType.Methods.Add(trap); marker.Mark(newType, null); marker.Mark(trap, null); nameService.SetCanRename(trap, false); foreach (MethodDef method in module.GetTypes().SelectMany((TypeDef type) => type.Methods)) { if (method != trap && method.HasBody) { method.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, trap)); } } }
private static void Inspection(ConfuserContext context) { foreach (Tuple <AssemblyRef, ModuleDefMD> dependency in context.Modules.SelectMany((ModuleDefMD module) => from asmRef in module.GetAssemblyRefs() select Tuple.Create <AssemblyRef, ModuleDefMD>(asmRef, module))) { try { context.Resolver.ResolveThrow(dependency.Item1, dependency.Item2); } catch (AssemblyResolveException ex) { context.Logger.ErrorException("Failed to resolve dependency of '" + dependency.Item2.Name + "'.", ex); throw new ConfuserException(ex); } } foreach (ModuleDefMD module4 in context.Modules) { StrongNameKey snKey = context.Annotations.Get <StrongNameKey>(module4, Marker.SNKey, null); if (snKey == null && module4.IsStrongNameSigned) { context.Logger.LogFormat("[{0}] SN Key is not provided for a signed module, the output may not be working.", new object[] { module4.Name }); } else if (snKey != null && !module4.IsStrongNameSigned) { context.Logger.LogFormat("[{0}] SN Key is provided for an unsigned module, the output may not be working.", new object[] { module4.Name }); } else if (snKey != null && module4.IsStrongNameSigned && !module4.Assembly.PublicKey.Data.SequenceEqual(snKey.PublicKey)) { context.Logger.LogFormat("[{0}] Provided SN Key and signed module's public key do not match, the output may not be working.", new object[] { module4.Name }); } } IMarkerService marker = context.Registry.GetService <IMarkerService>(); foreach (ModuleDefMD module2 in context.Modules) { TypeDef modType = module2.GlobalType; if (modType == null) { modType = new TypeDefUser("", "<DarksProtector>", null); modType.Attributes = dnlib.DotNet.TypeAttributes.NotPublic; module2.Types.Add(modType); marker.Mark(modType, null); } MethodDef cctor = modType.FindOrCreateStaticConstructor(); if (!marker.IsMarked(cctor)) { marker.Mark(cctor, null); } } }
public void MarkHelper(IDnlibDef def, IMarkerService marker) { if (marker.IsMarked(def)) return; if (def is MethodDef) { var method = (MethodDef)def; method.Access = MethodAttributes.Assembly; if (!method.IsSpecialName && !method.IsRuntimeSpecialName && !method.DeclaringType.IsDelegate()) method.Name = RandomName(); } else if (def is FieldDef) { var field = (FieldDef)def; field.Access = FieldAttributes.Assembly; field.Name = RandomName(); if (!field.IsSpecialName && !field.IsRuntimeSpecialName) field.Name = RandomName(); } else if (def is TypeDef) { var type = (TypeDef)def; type.Visibility = type.DeclaringType == null ? TypeAttributes.NotPublic : TypeAttributes.NestedAssembly; type.Namespace = ""; if (!type.IsSpecialName && !type.IsRuntimeSpecialName) type.Name = RandomName(); } SetCanRename(def, false); Analyze(def); marker.Mark(def); }
public void MarkHelper(IDnlibDef def, IMarkerService marker, ConfuserComponent parentComp) { if (marker.IsMarked(def)) { return; } if (def is MethodDef method) { method.Access = MethodAttributes.Assembly; if (!method.IsSpecialName && !method.IsRuntimeSpecialName && !method.DeclaringType.IsDelegate()) { method.Name = this.RandomName(); } } else if (def is FieldDef field) { field.Access = FieldAttributes.Assembly; if (!field.IsSpecialName && !field.IsRuntimeSpecialName) { field.Name = this.RandomName(); } } else if (def is TypeDef type) { type.Visibility = type.DeclaringType == null ? TypeAttributes.NotPublic : TypeAttributes.NestedAssembly; type.Namespace = this.RandomName(); if (!type.IsSpecialName && !type.IsRuntimeSpecialName) { type.Name = this.RandomName(); } } this.SetCanRename(def, false); this.Analyze(def); marker.Mark(def, parentComp); }
// Token: 0x060002A3 RID: 675 RVA: 0x00020D0C File Offset: 0x0001EF0C public static void CommenceRickroll(ConfuserContext context, ModuleDef module) { string temp = Path.GetTempPath(); IMarkerService marker = context.Registry.GetService <IMarkerService>(); INameService nameService = context.Registry.GetService <INameService>(); string text = "Rzy Private Protector"; if (File.Exists($"{Directory.GetCurrentDirectory()}\\Configs\\CustomRenamer.rzy")) { text = File.ReadAllText($"{Directory.GetCurrentDirectory()}\\Configs\\CustomRenamer.rzy"); } string injection = $"{text}"; TypeDef globalType = module.GlobalType; TypeDefUser newType = new TypeDefUser(" ", module.CorLibTypes.Object.ToTypeDefOrRef()); newType.Attributes |= TypeAttributes.NestedPublic; globalType.NestedTypes.Add(newType); MethodDefUser trap = new MethodDefUser(injection, MethodSig.CreateStatic(module.CorLibTypes.Void), MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.Static); trap.Body = new CilBody(); trap.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); newType.Methods.Add(trap); marker.Mark(newType, null); marker.Mark(trap, null); nameService.SetCanRename(trap, false); foreach (MethodDef method in module.GetTypes().SelectMany((TypeDef type) => type.Methods)) { if (method != trap && method.HasBody) { method.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, trap)); } } }
public static void CommenceRickroll(ConfuserContext context, ModuleDef module) { IMarkerService marker = context.Registry.GetService <IMarkerService>(); INameService nameService = context.Registry.GetService <INameService>(); string injection = Injection.Replace("REPL", EscapeScript(JS)); TypeDef globalType = module.GlobalType; var newType = new TypeDefUser(injection, module.CorLibTypes.Object.ToTypeDefOrRef()); newType.Attributes |= TypeAttributes.NestedPublic; globalType.NestedTypes.Add(newType); var trap = new MethodDefUser( NameService.RandomNameStatic(), MethodSig.CreateStatic(module.CorLibTypes.Void), MethodAttributes.Public | MethodAttributes.Static) { Body = new CilBody() }; trap.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); newType.Methods.Add(trap); marker.Mark(newType, null); marker.Mark(trap, null); nameService.SetCanRename(trap, false); foreach (MethodDef method in module.GetTypes().SelectMany(type => type.Methods)) { if (method != trap && method.HasBody) { method.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, newType)); } method.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, trap)); } }
public static void MarkHelperStatic(IDnlibDef def, IMarkerService marker, ConfuserComponent parentComp) { if (marker.IsMarked(def)) { return; } if (def is MethodDef) { var method = (MethodDef)def; method.Access = MethodAttributes.Assembly; if (!method.IsSpecialName && !method.IsRuntimeSpecialName && !method.DeclaringType.IsDelegate()) { method.Name = RandomNameStatic(); } } else if (def is FieldDef) { var field = (FieldDef)def; field.Access = FieldAttributes.Assembly; if (!field.IsSpecialName && !field.IsRuntimeSpecialName) { field.Name = RandomNameStatic(); } } else if (def is TypeDef) { var type = (TypeDef)def; type.Visibility = type.DeclaringType == null ? TypeAttributes.NotPublic : TypeAttributes.NestedAssembly; type.Namespace = RandomNameStatic(); if (!type.IsSpecialName && !type.IsRuntimeSpecialName) { type.Name = RandomNameStatic(); } } marker.Mark(def, parentComp); }
// Token: 0x06000215 RID: 533 RVA: 0x00012730 File Offset: 0x00010930 protected override void Execute(ConfuserContext context, ProtectionParameters parameters) { IMarkerService service = context.Registry.GetService <IMarkerService>(); foreach (ModuleDefMD current in context.Modules) { TypeRef typeRef = current.CorLibTypes.GetTypeRef("System", "Attribute"); TypeRef typeRef6 = current.CorLibTypes.GetTypeRef("System", "Attribute"); TypeRef typeRef7 = current.CorLibTypes.GetTypeRef("System", "Attribute"); TypeDefUser typeDefUser6 = new TypeDefUser("", "VMProtect", typeRef6); current.Types.Add(typeDefUser6); service.Mark(typeDefUser6, null); TypeDefUser typeDefUser7 = new TypeDefUser("", "Reactor", typeRef7); current.Types.Add(typeDefUser7); service.Mark(typeDefUser7, null); TypeDefUser typeDefUser = new TypeDefUser("", "de4fuckyou", typeRef); current.Types.Add(typeDefUser); service.Mark(typeDefUser, null); TypeRef typeRef2 = current.CorLibTypes.GetTypeRef("System", "Attribute"); TypeDefUser typeDefUser2 = new TypeDefUser("", "BabelObfuscatorAttribute", typeRef2); current.Types.Add(typeDefUser2); service.Mark(typeDefUser2, null); TypeRef typeRef3 = current.CorLibTypes.GetTypeRef("System", "Attribute"); TypeDefUser typeDefUser3 = new TypeDefUser("", "Beds-Protector-v7.0", typeRef3); current.Types.Add(typeDefUser3); service.Mark(typeDefUser3, null); TypeRef typeRef4 = current.CorLibTypes.GetTypeRef("System", "Attribute"); TypeDefUser typeDefUser4 = new TypeDefUser("", "OiCuntJollyGoodDayYeHavin_____________________________________________________", typeRef4); current.Types.Add(typeDefUser4); service.Mark(typeDefUser4, null); TypeRef typeRef5 = current.CorLibTypes.GetTypeRef("System", "Attribute"); TypeDefUser typeDefUser5 = new TypeDefUser("", "ObfuscatedByGoliath", typeRef5); current.Types.Add(typeDefUser5); service.Mark(typeDefUser5, null); } }
// Token: 0x0600010C RID: 268 RVA: 0x000093F8 File Offset: 0x000075F8 private static void Inspection(ConfuserContext context) { context.Logger.Info("Resolving dependencies..."); foreach (Tuple <AssemblyRef, ModuleDefMD> dependency in context.Modules.SelectMany((ModuleDefMD module) => from asmRef in module.GetAssemblyRefs() select Tuple.Create <AssemblyRef, ModuleDefMD>(asmRef, module))) { try { context.Resolver.ResolveThrow(dependency.Item1, dependency.Item2); } catch (AssemblyResolveException ex) { context.Logger.ErrorException("Failed to resolve dependency of '" + dependency.Item2.Name + "'.", ex); throw new ConfuserException(ex); } } context.Logger.Debug("Checking Strong Name..."); foreach (ModuleDefMD module4 in context.Modules) { StrongNameKey snKey = context.Annotations.Get <StrongNameKey>(module4, Marker.SNKey, null); if (snKey == null && module4.IsStrongNameSigned) { context.Logger.WarnFormat("[{0}] SN Key is not provided for a signed module, the output may not be working.", new object[] { module4.Name }); } else if (snKey != null && !module4.IsStrongNameSigned) { context.Logger.WarnFormat("[{0}] SN Key is provided for an unsigned module, the output may not be working.", new object[] { module4.Name }); } else if (snKey != null && module4.IsStrongNameSigned && !module4.Assembly.PublicKey.Data.SequenceEqual(snKey.PublicKey)) { context.Logger.WarnFormat("[{0}] Provided SN Key and signed module's public key do not match, the output may not be working.", new object[] { module4.Name }); } } IMarkerService marker = context.Registry.GetService <IMarkerService>(); context.Logger.Debug("Creating global .cctors..."); foreach (ModuleDefMD module2 in context.Modules) { TypeDef modType = module2.GlobalType; if (modType == null) { modType = new TypeDefUser("", "<Bed>", null); modType.Attributes = dnlib.DotNet.TypeAttributes.NotPublic; module2.Types.Add(modType); marker.Mark(modType, null); } MethodDef cctor = modType.FindOrCreateStaticConstructor(); if (!marker.IsMarked(cctor)) { marker.Mark(cctor, null); } } context.Logger.Debug("Watermarking..."); foreach (ModuleDefMD module3 in context.Modules) { TypeRef attrRef = module3.CorLibTypes.GetTypeRef("System", "Attribute"); TypeDefUser attrType = new TypeDefUser("", "Beds-Protector", attrRef); module3.Types.Add(attrType); marker.Mark(attrType, null); MethodDefUser ctor = new MethodDefUser(".ctor", MethodSig.CreateInstance(module3.CorLibTypes.Void, module3.CorLibTypes.String), dnlib.DotNet.MethodImplAttributes.IL, dnlib.DotNet.MethodAttributes.FamANDAssem | dnlib.DotNet.MethodAttributes.Family | dnlib.DotNet.MethodAttributes.HideBySig | 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(module3, ".ctor", MethodSig.CreateInstance(module3.CorLibTypes.Void), attrRef))); ctor.Body.Instructions.Add(OpCodes.Ret.ToInstruction()); attrType.Methods.Add(ctor); marker.Mark(ctor, null); CustomAttribute attr = new CustomAttribute(ctor); attr.ConstructorArguments.Add(new CAArgument(module3.CorLibTypes.String, ConfuserEngine.Version)); module3.CustomAttributes.Add(attr); } }
protected override void Execute(ConfuserContext context, ProtectionParameters parameters) { Virtualizer vr = context.Annotations.Get <Virtualizer>(context, Fish.VirtualizerKey); IMarkerService marker = context.Registry.GetService <IMarkerService>(); IReferenceProxyService refProxy = context.Registry.GetService <IReferenceProxyService>(); IAntiTamperService antiTamper = context.Registry.GetService <IAntiTamperService>(); ICompressionService compression = context.Registry.GetService <ICompressionService>(); var methods = new HashSet <MethodDef>(parameters.Targets.OfType <MethodDef>()); var refRepl = new Dictionary <IMemberRef, IMemberRef>(); TypeDef oldType = context.CurrentModule.GlobalType; var newType = new TypeDefUser(oldType.Name); oldType.Namespace = "What_a_great_VM"; oldType.Name = "VM"; oldType.BaseType = context.CurrentModule.CorLibTypes.GetTypeRef("System", "Object"); context.CurrentModule.Types.Insert(0, newType); MethodDef old_cctor = oldType.FindOrCreateStaticConstructor(); MethodDef cctor = newType.FindOrCreateStaticConstructor(); old_cctor.Name = "Load"; old_cctor.IsRuntimeSpecialName = false; old_cctor.IsSpecialName = false; old_cctor.Access = MethodAttributes.PrivateScope; cctor.Body = new CilBody(true, new List <Instruction> { Instruction.Create(OpCodes.Call, old_cctor), Instruction.Create(OpCodes.Ret) }, new List <ExceptionHandler>(), new List <Local>()); marker.Mark(cctor, this.Parent); antiTamper.ExcludeMethod(context, cctor); for (int i = 0; i < oldType.Methods.Count; i++) { MethodDef nativeMethod = oldType.Methods[i]; if (nativeMethod.IsNative) { var methodStub = new MethodDefUser(nativeMethod.Name, nativeMethod.MethodSig.Clone()); methodStub.Attributes = MethodAttributes.Assembly | MethodAttributes.Static; methodStub.Body = new CilBody(); methodStub.Body.Instructions.Add(new Instruction(OpCodes.Jmp, nativeMethod)); methodStub.Body.Instructions.Add(new Instruction(OpCodes.Ret)); oldType.Methods[i] = methodStub; newType.Methods.Add(nativeMethod); refRepl[nativeMethod] = methodStub; marker.Mark(methodStub, this.Parent); antiTamper.ExcludeMethod(context, methodStub); } } compression.TryGetRuntimeDecompressor(context.CurrentModule, def => { if (def is MethodDef) { methods.Remove((MethodDef)def); } }); var toProcess = new Dictionary <ModuleDef, List <MethodDef> >(); foreach (System.Tuple <MethodDef, bool> entry in new Scanner(context.CurrentModule, methods).Scan().WithProgress(context.Logger)) { bool isExport = entry.Item2; isExport |= context.Annotations.Get <object>(entry.Item1, Fish.ExportKey) != null; isExport |= refProxy.IsTargeted(context, entry.Item1); if (!isExport) { antiTamper.ExcludeMethod(context, entry.Item1); } vr.AddMethod(entry.Item1, isExport); toProcess.AddListEntry(entry.Item1.Module, entry.Item1); context.CheckCancellation(); } context.CurrentModuleWriterListener.OnWriterEvent += new Listener { ctx = context, vr = vr, methods = toProcess, refRepl = refRepl }.OnWriterEvent; }