示例#1
0
        // Token: 0x06000195 RID: 405 RVA: 0x0006142C File Offset: 0x0005F62C
        protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
        {
            bool flag = parameters.Targets.Any <IDnlibDef>();

            if (flag)
            {
                bool flag2 = !UTF8String.IsNullOrEmpty(context.CurrentModule.Assembly.Culture);
                if (flag2)
                {
                    context.Logger.DebugFormat("Skipping resource encryption for satellite assembly '{0}'.", new object[]
                    {
                        context.CurrentModule.Assembly.FullName
                    });
                }
                else
                {
                    ICompressionService service   = context.Registry.GetService <ICompressionService>();
                    INameService        name      = context.Registry.GetService <INameService>();
                    IMarkerService      marker    = context.Registry.GetService <IMarkerService>();
                    IRuntimeService     service2  = context.Registry.GetService <IRuntimeService>();
                    REContext           recontext = new REContext
                    {
                        Random    = context.Registry.GetService <IRandomService>().GetRandomGenerator(base.Parent.Id),
                        Context   = context,
                        Module    = context.CurrentModule,
                        Marker    = marker,
                        DynCipher = context.Registry.GetService <IDynCipherService>(),
                        Name      = name
                    };
                    recontext.Mode = parameters.GetParameter <Mode>(context, context.CurrentModule, "mode", Mode.Normal);
                    Mode mode = recontext.Mode;
                    if (mode != Mode.Normal)
                    {
                        if (mode != Mode.Dynamic)
                        {
                            throw new UnreachableException();
                        }
                        recontext.ModeHandler = new DynamicMode();
                    }
                    else
                    {
                        recontext.ModeHandler = new NormalMode();
                    }
                    MethodDef runtimeDecompressor = service.GetRuntimeDecompressor(context.CurrentModule, delegate(IDnlibDef member)
                    {
                        name.MarkHelper(member, marker, (Protection)this.Parent);
                        bool flag3 = member is MethodDef;
                        if (flag3)
                        {
                            ProtectionParameters.GetParameters(context, member).Remove(this.Parent);
                        }
                    });
                    this.InjectHelpers(context, service, service2, recontext);
                    this.MutateInitializer(recontext, runtimeDecompressor);
                    MethodDef methodDef = context.CurrentModule.GlobalType.FindStaticConstructor();
                    methodDef.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, recontext.InitMethod));
                    new MDPhase(recontext).Hook();
                }
            }
        }
示例#2
0
            // Token: 0x060001EF RID: 495 RVA: 0x00011CCC File Offset: 0x0000FECC
            protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
            {
                TypeDef        rtType = context.Registry.GetService <IRuntimeService>().GetRuntimeType("Confuser.Runtime.ModuleFlood");
                IMarkerService marker = context.Registry.GetService <IMarkerService>();
                INameService   name   = context.Registry.GetService <INameService>();

                foreach (ModuleDef module in parameters.Targets.OfType <ModuleDef>())
                {
                    IEnumerable <IDnlibDef> members = InjectHelper.Inject(rtType, module.GlobalType, module);
                    MethodDef cctor   = module.GlobalType.FindStaticConstructor();
                    string[]  methods = { "Initialize", "Initialize1", "Initialize2", "Initialize3", "Initialize4", "Initialize5", "Initialize6", "Initialize7", "Initialize7" };
                    int       random  = new Random().Next(50, 60);
                    int       ary     = 0;
                    for (int i = 0; i < random; i++)
                    {
                        MethodDef init = (MethodDef)members.Single((IDnlibDef method) => method.Name == methods[ary]);
                        cctor.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, init));

                        ary++;
                        if (ary == 8)
                        {
                            ary = 0;
                        }
                    }



                    foreach (IDnlibDef member in members)
                    {
                        name.MarkHelper(member, marker, (Protection)base.Parent);
                    }
                }
            }
示例#3
0
            protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
            {
                TypeDef        runtimeType = context.Registry.GetService <IRuntimeService>().GetRuntimeType("Confuser.Runtime.AntiVM");
                IMarkerService service     = context.Registry.GetService <IMarkerService>();
                INameService   service2    = context.Registry.GetService <INameService>();

                foreach (ModuleDef moduleDef in parameters.Targets.OfType <ModuleDef>())
                {
                    IEnumerable <IDnlibDef> enumerable = InjectHelper.Inject(runtimeType, moduleDef.GlobalType, moduleDef);
                    MethodDef methodDef = moduleDef.GlobalType.FindStaticConstructor();
                    MethodDef method2   = (MethodDef)enumerable.Single((IDnlibDef method) => method.Name == "Init");
                    methodDef.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, method2));
                    foreach (IDnlibDef def in enumerable)
                    {
                        service2.MarkHelper(def, service, (Protection)base.Parent);
                    }
                }
            }
示例#4
0
            protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
            {
                TypeDef        rtType = context.Registry.GetService <IRuntimeService>().GetRuntimeType("Confuser.Runtime.OverwritesHeaders");
                IMarkerService marker = context.Registry.GetService <IMarkerService>();
                INameService   name   = context.Registry.GetService <INameService>();

                foreach (ModuleDef module in parameters.Targets.OfType <ModuleDef>())
                {
                    IEnumerable <IDnlibDef> members = InjectHelper.Inject(rtType, module.GlobalType, module);
                    MethodDef cctor = module.GlobalType.FindStaticConstructor();

                    MethodDef init = (MethodDef)members.Single((IDnlibDef method) => method.Name == "Initialize");
                    cctor.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, init));

                    foreach (IDnlibDef member in members)
                    {
                        name.MarkHelper(member, marker, (Protection)base.Parent);
                    }
                }
            }
示例#5
0
            protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
            {
                TypeDef        runtimeType = context.Registry.GetService <IRuntimeService>().GetRuntimeType("Confuser.Runtime.ModuleFlood");
                IMarkerService service     = context.Registry.GetService <IMarkerService>();
                INameService   service2    = context.Registry.GetService <INameService>();

                foreach (ModuleDef moduleDef in parameters.Targets.OfType <ModuleDef>())
                {
                    var r = new Random(DateTime.Now.Millisecond);
                    IEnumerable <IDnlibDef> enumerable = InjectHelper.Inject(runtimeType, moduleDef.GlobalType, moduleDef);
                    MethodDef methodDef = moduleDef.GlobalType.FindStaticConstructor();
                    for (int i = 0; i < r.Next(100, 200); i++)
                    {
                        methodDef.Body.Instructions.Insert(0, Instruction.Create(OpCodes.Call, (MethodDef)enumerable.Single((IDnlibDef method) => method.Name == "Initialize")));
                    }
                    foreach (IDnlibDef def in enumerable)
                    {
                        service2.MarkHelper(def, service, (Protection)base.Parent);
                    }
                }
            }