Пример #1
0
		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);
		}
Пример #2
0
 public MarkersController(
     IMarkerService markerService,
     ILogger <MarkersController> logger)
 {
     this.markerService = markerService;
     this.logger        = logger;
 }
Пример #3
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();
                }
            }
        }
Пример #4
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);
                    }
                }
            }
        public MarkerController(IMarkerService markerService, IConfiguration conf)
        {
            var strConn = conf.GetValue <string>("Oracle:ConnStr");

            _markerService = markerService;
            _markerService.Connect(strConn);
        }
Пример #6
0
 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);
 }
Пример #7
0
        // 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));
                }
            }
        }
Пример #8
0
        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);
                }
            }
        }
Пример #9
0
 public HomeController(IMarkerService markerService, IMarkerIconService markerIconService, IRouteLegService routeLegService,
                       IPointService pointService)
 {
     this.markerService     = markerService;
     this.markerIconService = markerIconService;
     this.routeLegService   = routeLegService;
     this.pointService      = pointService;
 }
Пример #10
0
 public void DestroyMarkersDummyData(IMarkerService markerService, params string[] ids)
 {
     foreach (var id in ids)
     {
         markerService.DeleteMarker(new DeleteMarkerRequest {
             MarkerId = id
         });
     }
 }
Пример #11
0
        public MainPage()
        {
            this.Title = "Closest Markers";

            _markerService   = new MarkerService();
            _locationService = new LocationService(this);

            // Required line when using XAML file.
            InitializeComponent();
            //ShowTestButton();
            ShowMarkersList();

            _locationService.InitLocationChangeListener();
        }
Пример #12
0
 public HeatController(IHeatService heatService,
                       IAdminService adminService,
                       IMarkerService markerService,
                       IChipService chipService,
                       ICompetitionService competitionService,
                       IEventService eventService,
                       IResultService resultService)
 {
     _heatService        = heatService;
     _adminService       = adminService;
     _markerService      = markerService;
     _chipService        = chipService;
     _competitionService = competitionService;
     _eventService       = eventService;
     _resultService      = resultService;
 }
Пример #13
0
        public List <string> CreateDummyMarkerData(IMarkerService markerService, int dataCount, string docId, string docOwner)
        {
            var retval = new List <string>();

            for (int i = 0; i < dataCount; i++)
            {
                var marker  = GetMarkerData(docId, docOwner, EMarkerType.Ellipse);
                var request = new CreateMarkerRequest {
                    Marker = marker
                };
                var result = markerService.CreateMarker(request) as CreateMarkerResponseOk;
                retval.Add(result?.Request.Marker.MarkerId);
            }

            return(retval);
        }
Пример #14
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);
                    }
                }
            }
Пример #15
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);
                    }
                }
            }
Пример #16
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);
                    }
                }
            }
 public CompetitionInstanceController(ICompetitionService competitionService,
                                      IMemoryCache cache,
                                      IAccountService accountService,
                                      IDeviceService deviceService,
                                      IEventService eventService,
                                      IMarkerService markerService,
                                      IAdminService adminService,
                                      IHeatService heatService,
                                      IResultService resultService,
                                      IChipService chipService
                                      )
 {
     _competitionService = competitionService;
     _cache          = cache;
     _accountService = accountService;
     _deviceService  = deviceService;
     _eventService   = eventService;
     _markerService  = markerService;
     _adminService   = adminService;
     _heatService    = heatService;
     _resultService  = resultService;
     _chipService    = chipService;
 }
Пример #18
0
        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);
        }
Пример #19
0
        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));
            }
        }
Пример #20
0
        // 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));
                }
            }
        }
            // 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);
            }
        }
 public MarkerController(IServiceProvider serviceProvider, IMarkerService markerService) : base(serviceProvider)
 {
     _markerService = markerService;
 }
 public void Setup()
 {
     _markerService = new MarkerServiceImpl(_drawingDal);
 }
Пример #25
0
        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;
        }
Пример #26
0
 public MarkerController()
 {
     _service = new MarkerService();
 }
Пример #27
0
 public EarthquakeController(IMarkerService markerService)
 {
     _markerService = markerService;
 }
 public void TearDown()
 {
     _markerService = null;
 }
 public Marker(IMarkerService _MarkerService)
 {
     MarkerService = _MarkerService;
 }
Пример #30
0
 public MarkerController(IMarkerService service)
 {
     _service = service;
     _externalUserId = TokenIdentityHelper.GetOwnerIdFromToken();
 }
Пример #31
0
 public MarkerController(IMarkerService markerService)
 {
     _markerService = markerService;
 }