public LookupModule Process(TypeModel model, BeebyteDeobfuscatorPlugin plugin)
        {
            PluginServices services = PluginServices.For(plugin);

            services.StatusUpdate("Creating model for Mono dll");
            if (plugin.CompilerType.Value != CppCompilerType.MSVC)
            {
                throw new System.ArgumentException("Cross compiler deobfuscation has not been implemented yet");
            }

            MonoDecompiler.MonoDecompiler monoDecompiler = MonoDecompiler.MonoDecompiler.FromFile(plugin.MonoPath);
            if (monoDecompiler == null)
            {
                throw new System.ArgumentException("Could not load unobfuscated application");
            }

            services.StatusUpdate("Creating LookupModel for obfuscated application");

            LookupModule lookupModel = new LookupModule(plugin.NamingRegex);

            lookupModel.Init(model.ToLookupModel(statusCallback: services.StatusUpdate), LookupModel.FromModuleDef(monoDecompiler.Module, statusCallback: services.StatusUpdate), statusCallback: services.StatusUpdate);
            services.StatusUpdate("Deobfuscating binary");
            lookupModel.TranslateTypes(statusCallback: services.StatusUpdate);

            plugin.CompilerType = null;
            return(lookupModel);
        }
Пример #2
0
        public void Initialize(UserSession session, AppInfo appSettings)
        {
            _session     = session;
            _appSettings = appSettings;
            string pluginDirectory = Application.StartupPath + @"\Plugins";

            AppManager    am          = new AppManager(_appSettings.ActiveDbConnectionKey, "FORMS", _session.AuthToken);
            string        pluginOrder = am.GetSetting(_session.UserName + "PluginOrder", false)?.Value;
            List <string> plugins     = new List <string>();

            if (!string.IsNullOrEmpty(pluginOrder))
            {
                plugins.AddRange(pluginOrder.Split(',').ToList());
            }
            else if (Directory.Exists(pluginDirectory))
            {
                PluginServices svcPlugins = new PluginServices();
                //Call the find plugins routine, to search in our Plugins Folder
                List <string> AvailablePlugins = svcPlugins.FindPlugins(pluginDirectory);
                plugins.AddRange(AvailablePlugins);
            }

            foreach (string plugin in plugins)
            {
                lstPlugins.Items.Add(new ListViewItem(plugin));
            }
            lstPlugins.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Пример #3
0
        // Detect and defeat various kinds of XOR encryption
        public void PostProcessImage <T>(FileFormatStream <T> stream, PluginPostProcessImageEventInfo data) where T : FileFormatStream <T>
        {
            if (stream is ElfReader32 stream32)
            {
                elf32 = stream32;
            }
            else if (stream is ElfReader64 stream64)
            {
                elf64 = stream64;
            }
            else
            {
                return;
            }

            PluginServices.For(this).StatusUpdate("Detecting encryption");

            this.stream = stream;
            sections    = stream.GetSections().GroupBy(s => s.Name).ToDictionary(s => s.Key, s => s.First());

            if (HasDynamicEntry(Elf.DT_INIT) && sections.ContainsKey(".rodata"))
            {
                // Use the data section to determine some possible keys
                // If the data section uses striped encryption, bucketing the whole section will not give the correct key
                var roDataBytes            = stream.ReadBytes(sections[".rodata"].ImageStart, sections[".rodata"].ImageLength);
                var xorKeyCandidateStriped = roDataBytes.Take(1024).GroupBy(b => b).OrderByDescending(f => f.Count()).First().Key;
                var xorKeyCandidateFull    = roDataBytes.GroupBy(b => b).OrderByDescending(f => f.Count()).First().Key;

                // Select test nibbles and values for ARM instructions depending on architecture (ARMv7 / AArch64)
                var testValues = new Dictionary <int, (int, int, int, int)> {
        public void FindTestLoggerClassTypeInstancesAddLogAndVerify()
        {
            using (TestPluginManager pluginManager = new TestPluginManager())
            {
                pluginManager.PluginLoad(Assembly.GetExecutingAssembly(), String.Empty, false);
                IPluginClassesService pluginServices = new PluginServices(pluginManager) as IPluginClassesService;

                Assert.IsNotNull(pluginServices);

                List <ILogger> classTypes = pluginServices.GetPluginClasses <ILogger>();

                Assert.AreEqual(classTypes.Count, 2);

                Assert.AreEqual(classTypes[1].GetType().FullName, "PluginManager.Tests.Mocks.TestLogger");

                TestLogger testLogger = classTypes[1] as TestLogger;

                Assert.IsNotNull(testLogger);

                testLogger.AddToLog(LogLevel.Information, "test");

                Assert.AreEqual(testLogger.Logs[0].Data, "test");
                Assert.AreEqual(testLogger.Logs[0].LogLevel, LogLevel.Information);
            }
        }
        /// <summary>
        /// Loads plugin, register it as a service and add its own services
        /// </summary>
        /// <param name="container"></param>
        /// <param name="pluginAssembly"></param>
        /// <returns></returns>
        private static IServiceCollection AddPluginServices(this IServiceCollection container, Assembly pluginAssembly)
        {
            try
            {
                IPlugin        plugin         = PluginFactory.GetPlugin <IPlugin>(pluginAssembly);
                PluginServices pluginServices = plugin.GetPluginServices();

                foreach ((Type serviceType, Type implementationType) in pluginServices.ScopedServices)
                {
                    container.AddScoped(serviceType, implementationType);
                }

                foreach ((Type serviceType, Type implementationType) in pluginServices.TransientServices)
                {
                    container.AddTransient(serviceType, implementationType);
                }

                foreach ((Type serviceType, Type implementationType) in pluginServices.SingletonServices)
                {
                    container.AddSingleton(serviceType, implementationType);
                }
            }
            catch (ApplicationException)
            {
                return(container);
            }
            return(container);
        }
Пример #6
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: hand2xml site file");
                return;
            }

            PluginServices host = PluginServices.Instance;

            host.PluginDirectory = AppDomain.CurrentDomain.BaseDirectory;
            host.AddPlugin("HandParserInterface.IHandParser");
            host.FindPlugins();
            AvailablePlugins parsers = host.Plugins["HandParserInterface.IHandParser"];

            foreach (AvailablePlugin plugin in parsers)
            {
                IHandParser parser = (IHandParser)plugin.Instance;
                if (parser.Switch == args[0])
                {
                    PokerHandXML  hands      = parser.ParseFile(args[1]);
                    TextWriter    output     = new StreamWriter(args[1] + ".xml");
                    XmlSerializer serializer = new XmlSerializer(typeof(PokerHandXML));
                    serializer.Serialize(output, hands);
                    output.Flush();
                    output.Close();
                    return;
                }
            }
        }
Пример #7
0
        public void PluginServicesNamespacesWithInvalidArgsExpectedReturnsEmptyList()
        {
            var services = new PluginServices();
            var result   = services.Namespaces(new PluginSource(), Guid.Empty, Guid.Empty);

            Assert.AreEqual(0, result.Count);
        }
Пример #8
0
        public void PluginServicesMethodsWithReturnsNullArgsExpectedReturnsEmptyList()
        {
            var services = new PluginServices();
            var result   = services.MethodsWithReturns(null, Guid.Empty, Guid.Empty);

            Assert.AreEqual(0, result.Count);
        }
Пример #9
0
        public void PluginServicesConstuctorsWithInvalidArgsExpectedReturnsEmptyList()
        {
            var services = new PluginServices();
            var result   = services.Constructors(new PluginService(), Guid.Empty, Guid.Empty);

            Assert.AreEqual(0, result.Count);
        }
Пример #10
0
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var serializer = new Dev2JsonSerializer();

            try
            {
                var dbSource    = serializer.Deserialize <PluginSourceDefinition>(values["source"]);
                var containsKey = values.ContainsKey("fetchJson");


                var services = new PluginServices();
                var src      = ResourceCatalog.Instance.GetResource <PluginSource>(GlobalConstants.ServerWorkspaceID, dbSource.Id);
                var methods  = containsKey ? services.NamespacesWithJsonObjects(src, Guid.Empty, Guid.Empty).Select(a => a as INamespaceItem).ToList()
                    : services.Namespaces(src, Guid.Empty, Guid.Empty).Select(a => a as INamespaceItem).ToList();
                return(serializer.SerializeToBuilder(new ExecuteMessage()
                {
                    HasError = false,
                    Message = serializer.SerializeToBuilder(methods)
                }));
            }
            catch (Exception e)
            {
                return(serializer.SerializeToBuilder(new ExecuteMessage()
                {
                    HasError = true,
                    Message = new StringBuilder(e.Message)
                }));
            }
        }
Пример #11
0
        public void PluginServicesMethodsWithReturnsWithInvalidArgsExpectedReturnsEmptyList()
        {
            var services = new PluginServices();
            var result   = services.MethodsWithReturns(new PluginService());

            Assert.AreEqual(0, result.Count);
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var serializer = new Dev2JsonSerializer();

            try
            {
                var pluginSource = serializer.Deserialize <PluginSourceDefinition>(values["source"]);
                var ns           = serializer.Deserialize <INamespaceItem>(values["namespace"]);
                // ReSharper disable MaximumChainedReferences
                PluginServices services = new PluginServices();
                var            src      = ResourceCatalog.Instance.GetResource <PluginSource>(GlobalConstants.ServerWorkspaceID, pluginSource.Id);
                //src.AssemblyName = ns.FullName;
                if (ns != null)
                {
                    PluginService svc = new PluginService {
                        Namespace = ns.FullName, Source = src
                    };

                    var serviceMethodList = services.Methods(svc, Guid.Empty, Guid.Empty);
                    var methods           = serviceMethodList.Select(a => new PluginAction
                    {
                        FullName = ns.FullName,
                        Inputs   = a.Parameters.Select(x => new ServiceInput(x.Name, x.DefaultValue ?? "")
                        {
                            Name = x.Name, EmptyIsNull = x.EmptyToNull, RequiredField = x.IsRequired, TypeName = x.TypeName
                        } as IServiceInput).ToList(),
                        Method    = a.Name,
                        Variables = a.Parameters.Select(x => new NameValue()
                        {
                            Name = x.Name + " (" + x.TypeName + ")", Value = ""
                        } as INameValue).ToList(),
                    } as IPluginAction).ToList();
                    return(serializer.SerializeToBuilder(new ExecuteMessage()
                    {
                        HasError = false,
                        Message = serializer.SerializeToBuilder(methods)
                    }));
                }
                // ReSharper disable once RedundantIfElseBlock
                else
                {
                    return(serializer.SerializeToBuilder(new ExecuteMessage()
                    {
                        HasError = false,
                        Message = serializer.SerializeToBuilder(new List <IPluginAction>())
                    }));
                }

                // ReSharper restore MaximumChainedReferences
            }
            catch (Exception e)
            {
                return(serializer.SerializeToBuilder(new ExecuteMessage
                {
                    HasError = true,
                    Message = new StringBuilder(e.Message)
                }));
            }
        }
Пример #13
0
        public static IProject getProject(string fileName, ReturnAttributeValue gav)
        {
            if (_instance == null)
            {
                _instance = new AvailableAssemblies(LibraryDir);
            }
            //XmlReader reader;
            string projectClassName = String.Empty;
            Stream stream           = null;

            try {
                XmlReader reader = ProjectBase.getXmlReader(fileName, out stream);
                reader.ReadToFollowing("project");
                if (reader.MoveToFirstAttribute())
                {
                    do
                    {
                        switch (reader.Name)
                        {
                        case "class":
                            projectClassName = reader.Value;
                            break;
                            //case "spectraCount": break;
                        }
                        if (gav != null)
                        {
                            gav(reader.Name, reader.Value);
                        }
                    } while (reader.MoveToNextAttribute());
                }

                if (projectClassName == String.Empty)
                {
                    throw new SpectrumLoadException("This is not valid LT10 project");
                }
            } catch (Exception) {
                throw new SpectrumLoadException("Project file is damaged, it is not a valid LT10 project file or file is in use by another process.");
            } finally {
                if (stream != null)
                {
                    stream.Close();
                }
            }
            object[] args = new object[] { fileName };
            for (int i = 0; i < _instance._availableProjects.Count; i++)
            {
                //if (String.Equals(modelName, Path.GetFileNameWithoutExtension(_instance._availableModels[i].plugin.assemblyPath),
                string[] pluginClassNameSubs  = _instance._availableProjects[i].plugin.className.Split(classSeparators);
                string[] projectClassNameSubs = projectClassName.Split(classSeparators);
                string   pluginClassName      = pluginClassNameSubs[pluginClassNameSubs.Length - 1];
                projectClassName = projectClassNameSubs[projectClassNameSubs.Length - 1];
                if (String.Equals(projectClassName, pluginClassName,
                                  StringComparison.CurrentCultureIgnoreCase))
                {
                    return((IProject)PluginServices.getPluginInstance(_instance._availableProjects[i].plugin, args));
                }
            }
            throw new SpectrumLoadException(String.Format("Couldn't find project \"{0}\"!", projectClassName));
        }
Пример #14
0
 public PluginsController(
     IRepository <PluginConfig> pluginConfigRepository,
     IRepository <Plugin> pluginRepository,
     PluginServices plugins)
 {
     _pluginConfigRepository = pluginConfigRepository;
     _pluginRepository       = pluginRepository;
     _pluginServices         = plugins;
     SetCrumbs("Plugins", "Plugins");
 }
Пример #15
0
        public AssemblyWatcher(PluginServices pluginServices)
        {
            _pluginServices = pluginServices;

            fileSystemWatcher = new FileSystemWatcher(folderToWatchFor);
            fileSystemWatcher.EnableRaisingEvents = true;
            fileSystemWatcher.Filter   = "Logger*.dll";
            fileSystemWatcher.Deleted += new FileSystemEventHandler(CallLoadPlugin);
            fileSystemWatcher.Created += new FileSystemEventHandler(CallLoadPlugin);
            fileSystemWatcher.Changed += new FileSystemEventHandler(CallLoadPlugin);
        }
Пример #16
0
        public void PluginServicesConstructorsWithValidArgsExpectedReturnsList()
        {
            var service     = CreatePluginService();
            var workspaceID = Guid.NewGuid();

            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new PluginServices();
            var result   = services.Constructors(service, workspaceID, Guid.Empty);

            Assert.AreEqual(2, result.Count);
        }
Пример #17
0
        public void PluginServicesMethodsWithReturnsWithValidArgsExpectedReturnsList()
        {
            var service     = CreatePluginService();
            var workspaceID = Guid.NewGuid();

            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new PluginServices();
            var result   = services.MethodsWithReturns(service);

            Assert.AreEqual(7, result.Count);
        }
Пример #18
0
        private static void LoadPlugins()
        {
            List <PluginServices.AvailablePlugin> pluginz =
                PluginServices.FindPlugins(FileSystemWalker.PluginsDirectory, typeof(IOMLPlugin).Name);

            // Loop through available plugins, creating instances and adding them
            foreach (PluginServices.AvailablePlugin oPlugin in pluginz)
            {
                OMLPlugin objPlugin = (OMLPlugin)PluginServices.CreateInstance(oPlugin);
                objPlugin.FileFound += new OMLPlugin.FileFoundEventHandler(FileFound);
                plugins.Add(objPlugin);
            }
        }
Пример #19
0
        private void PrepareForm()
        {
            Application.DoEvents();
            Cursor = Cursors.WaitCursor;
            List <PluginServices.AvailablePlugin> plugins = new List <PluginServices.AvailablePlugin>();
            string path = FileSystemWalker.PluginsDirectory;

            plugins = PluginServices.FindPlugins(path, PluginTypes.MetadataPlugin);
            IOMLMetadataPlugin objPlugin;

            // Loop through available plugins, creating instances and add them
            if (plugins != null)
            {
                string pluginForProperty = OMLEngine.Settings.SettingsManager.MetaDataMap_PluginForProperty(_propertyName);
                cbDefault.Checked = String.IsNullOrEmpty(pluginForProperty);

                Dictionary <string, object> dataCollection = new Dictionary <string, object>();
                foreach (PluginServices.AvailablePlugin oPlugin in plugins)
                {
                    // Create instance to get plugin list
                    objPlugin = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin);
                    try
                    {
                        foreach (MetaDataPluginDescriptor provider in objPlugin.GetProviders)
                        {
                            // Create instance of the plugin for this particular provider. This would create a unique instance per provider.
                            provider.PluginDLL = (IOMLMetadataPlugin)PluginServices.CreateInstance(oPlugin);

                            // Initialise the plugin and select which provider it serves
                            provider.PluginDLL.Initialize(provider.DataProviderName, new Dictionary <string, string>());

                            provider.PluginDLL.SearchForMovie(_title.Name, OMLEngine.Settings.OMLSettings.MetadataLookupResultsQty);

                            Title title = OMLSDK.SDKUtilities.ConvertOMLSDKTitleToTitle(provider.PluginDLL.GetBestMatch());
                            if (title != null)
                            {
                                AddResult(provider, _propertyInfo.GetValue(title, null), pluginForProperty);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Utilities.DebugLine("[OMLDatabaseEditor] Error loading metadata: " + e.Message);
                        continue;
                    }
                }
                plugins = null;
            }
            Cursor = Cursors.Default;
        }
Пример #20
0
        // This implements IPostProcessMetadata
        // This hook is executed after global-metadata.dat is fully loaded
        public void PostProcessMetadata(Metadata metadata, PluginPostProcessMetadataEventInfo info)
        {
            // This displays a progress update for our plugin in the CLI or GUI
            PluginServices.For(this).StatusUpdate("Decrypting strings");

            // Go through every string literal (string[] metadata.StringLiterals) and ROT each string
            for (var i = 0; i < metadata.StringLiterals.Length; i++)
            {
                metadata.StringLiterals[i] = string.Join("", metadata.StringLiterals[i].Select(x => (char)(x >= 'a' && x <= 'z' ? (x - 'a' + rotKey.Value) % 26 + 'a' : x)));
            }

            // Report back that we modified the metadata
            // Note: we do not set info.FullyProcessed in order to allow other plugins to do further processing
            info.IsDataModified = true;
        }
Пример #21
0
        public void PluginServicesNamespacesWithValidArgsExpectedReturnsList()
        {
            var source      = CreatePluginSource();
            var args        = source.ToString();
            var workspaceID = Guid.NewGuid();

            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new PluginServices();
            var result   = services.Namespaces(source, workspaceID, Guid.Empty);

            // DO NOT assert equality on Count as this will
            // change as new namespaces are added to this assembly!
            Assert.IsTrue(result.Count > 0);
        }
        public void FindAllILoggerClassTypes()
        {
            using (TestPluginManager pluginManager = new TestPluginManager())
            {
                IPluginClassesService pluginServices = new PluginServices(pluginManager) as IPluginClassesService;

                Assert.IsNotNull(pluginServices);

                List <Type> classTypes = pluginServices.GetPluginClassTypes <ILogger>();

                Assert.AreEqual(classTypes.Count, 1);

                Assert.AreEqual(classTypes[0].FullName, "PluginManager.Internal.DefaultLogger");
            }
        }
Пример #23
0
        // This executes just as Il2CppInspector is about to read all of the .NET identifier strings (eg. type names).
        // We can use this to acquire the strings ourselves instead
        public void GetStrings(Metadata metadata, PluginGetStringsEventInfo data)
        {
            // Don't do anything if this isn't for us
            if (!IsOurs)
            {
                return;
            }

            // Tell the user what is happening in case it takes a while
            PluginServices.For(this).StatusUpdate("Decrypting strings");

            // miHoYo workloads use encrypted strings, and we need to know the correct string indexes
            // to pass to UnityPlayer.dll's GetStringFromIndex function.

            // To find them, we scan every definition in the metadata that refers to a string index,
            // combine them, put them in order and remove duplicates
            var stringIndexes =
                metadata.Images.Select(x => x.nameIndex)
                .Concat(metadata.Assemblies.Select(x => x.aname.nameIndex))
                .Concat(metadata.Assemblies.Select(x => x.aname.cultureIndex))
                .Concat(metadata.Assemblies.Select(x => x.aname.hashValueIndex))
                .Concat(metadata.Assemblies.Select(x => x.aname.publicKeyIndex))
                .Concat(metadata.Events.Select(x => x.nameIndex))
                .Concat(metadata.Fields.Select(x => x.nameIndex))
                .Concat(metadata.Methods.Select(x => x.nameIndex))
                .Concat(metadata.Params.Select(x => x.nameIndex))
                .Concat(metadata.Properties.Select(x => x.nameIndex))
                .Concat(metadata.Types.Select(x => x.nameIndex))
                .Concat(metadata.Types.Select(x => x.namespaceIndex))
                .Concat(metadata.GenericParameters.Select(x => x.nameIndex))
                .OrderBy(x => x)
                .Distinct()
                .ToList();

            // Create a delegate which internally is a function pointer to the GetStringFromIndex function in the DLL
            var pGetStringFromIndex = (GetStringFromIndex)
                                      Marshal.GetDelegateForFunctionPointer(ModuleBase + Offsets[game.Value].GetStringFromIndex, typeof(GetStringFromIndex));

            // For each index, call the delegate with the decrypted metadata byte array and index as arguments
            foreach (var index in stringIndexes)
            {
                data.Strings.Add(index, Marshal.PtrToStringAnsi(pGetStringFromIndex(metadataBlob, (uint)index)));
            }

            // This tells Il2CppInspector we have handled the strings and not to attempt to read them itself
            // The strings will be copied from data.Strings to metadata.Strings automatically
            data.IsDataModified = true;
        }
Пример #24
0
        public static IGroupGUI GetGroupGUI(Type projectType, DataGridView grid, List <ISpectrum> spectra, GroupDefinition groupDefinition, GroupTabPage groupTabPage)
        {
            //find plugin with accurate project type
            AvailableGUIAssemblies assemblies = GetAvailableGUIAssembliesInstance();

            foreach (GUIDescription gd in assemblies._availableGUIs)
            {
                if (gd.projectType == projectType)
                {
                    return((IGroupGUI)PluginServices.getPluginInstance(gd.plugin, new object[] { grid, spectra, groupDefinition, groupTabPage }));
                }
            }

            //if there is no gui for this projectType use default gui
            return(new DefaultGroupGUI(grid, spectra, groupDefinition, groupTabPage));
        }
        public void FindTestLoggerClassTypeInstances()
        {
            using (TestPluginManager pluginManager = new TestPluginManager())
            {
                pluginManager.PluginLoad(Assembly.GetExecutingAssembly(), String.Empty, false);
                IPluginClassesService pluginServices = new PluginServices(pluginManager) as IPluginClassesService;

                Assert.IsNotNull(pluginServices);

                List <ILogger> classTypes = pluginServices.GetPluginClasses <ILogger>();

                Assert.AreEqual(classTypes.Count, 2);

                Assert.AreEqual(classTypes[1].GetType().FullName, "PluginManager.Tests.Mocks.TestLogger");
            }
        }
Пример #26
0
        // A "package" is the combination of global-metadata.dat, the application binary,
        // and some analysis which links them both together into a single unit, the Il2CppInspector object.

        // This executes after all the low-level processing and analysis of the application is completed,
        // but before any higher-level abstractions are created, such as the .NET type model or C++ application model.

        // Therefore this is a good place to make any final changes to the data that the high level models and output modules will rely on
        // In this case, we are going to acquire all of the string literals that we deferred earlier
        public void PostProcessPackage(Il2CppInspector.Il2CppInspector package, PluginPostProcessPackageEventInfo data)
        {
            // Don't do anything if this isn't for us
            if (!IsOurs)
            {
                return;
            }

            // Tell the user what is happening in case it takes a while
            PluginServices.For(this).StatusUpdate("Decrypting string literals");

            // Calculate the number of string literals
            // This calculation depends on being able to scan MetadataUsages for all of the StringLiteral uses
            // and finding the one with the highest index. The creation of MetadataUsages requires data
            // from both global-metadata.dat and the application binary; this data is merged together
            // when the Il2CppInspector object is initialized, so this is the earliest opportunity we have to examine it
            var stringLiteralCount = package.MetadataUsages.Where(u => u.Type == MetadataUsageType.StringLiteral).Max(u => u.SourceIndex) + 1;

            // Create a delegate which internally is a function pointer to the GetStringLiteralFromIndex function in the DLL
            var pGetStringLiteralFromIndex = (GetStringLiteralFromIndex)
                                             Marshal.GetDelegateForFunctionPointer(ModuleBase + Offsets[game.Value].GetStringLiteralFromIndex, typeof(GetStringLiteralFromIndex));

            var stringLiterals = new List <string>();
            var length         = 0;

            // For each index, call the delegate with the decrypted metadata byte array, index and a pointer as arguments
            // In this case, the function returns an array of UTF8-encoded characters,
            // and populates 'length' with the number of bytes returned
            for (uint index = 0; index < stringLiteralCount; index++)
            {
                var decryptedBytesUnmanaged = pGetStringLiteralFromIndex(metadataBlob, index, ref length);
                var str = new byte[length];
                Marshal.Copy(decryptedBytesUnmanaged, str, 0, length);

                stringLiterals.Add(Encoding.UTF8.GetString(str));
            }

            // If we had used IGetStringLiterals above, we would have set data.StringLiterals,
            // but here we modify the package (the Il2CppInspector object) directly instead
            package.Metadata.StringLiterals = stringLiterals.ToArray();

            // We don't set FullyProcessed so that other plugins can perform further post-processing modifications
            // IsDataModified tells Il2CppInspector that the contents of its internal data structures have been changed
            // Note this is different from IsStreamModified; changing the data in memory
            // does not automatically rewrite the stream.
            data.IsDataModified = true;
        }
Пример #27
0
        public DirectoryScanner()
        {
            timer           = new System.Timers.Timer();
            timer.AutoReset = false;
            timer.Elapsed  += new System.Timers.ElapsedEventHandler(timer_Elapsed);

            badWatcherTimer           = new System.Timers.Timer();
            badWatcherTimer.AutoReset = false;
            badWatcherTimer.Interval  = CHANGE_TIMER_TIMEOUT;
            badWatcherTimer.Elapsed  += new System.Timers.ElapsedEventHandler(badWatcherTimer_Elapsed);

            // Load the plugins
            _metadataPlugins = new List <MetaDataPluginDescriptor>();
            PluginServices plg = new PluginServices();

            plg.LoadMetadataPlugins(PluginTypes.MetadataPlugin, _metadataPlugins);
        }
Пример #28
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Test Plugin Service");
                StringBuilder resourceDefinition;

                values.TryGetValue("PluginService", out resourceDefinition);
                IPluginService src = serializer.Deserialize <IPluginService>(resourceDefinition);


                // ReSharper disable MaximumChainedReferences
                var parameters = src.Inputs?.Select(a => new MethodParameter {
                    EmptyToNull = a.EmptyIsNull, IsRequired = a.RequiredField, Name = a.Name, Value = a.Value, TypeName = a.TypeName
                }).ToList() ?? new List <MethodParameter>();
                // ReSharper restore MaximumChainedReferences
                var pluginsrc = ResourceCatalog.Instance.GetResource <PluginSource>(GlobalConstants.ServerWorkspaceID, src.Source.Id);
                var res       = new PluginService
                {
                    Method       = new ServiceMethod(src.Action.Method, src.Name, parameters, new OutputDescription(), new List <MethodOutput>(), "test"),
                    Namespace    = src.Action.FullName,
                    ResourceName = src.Name,
                    ResourceID   = src.Id,
                    Source       = pluginsrc
                };

                string serializedResult;
                var    result = PluginServices.Test(serializer.SerializeToBuilder(res).ToString(), out serializedResult);
                msg.HasError = false;
                msg.Message  = serializer.SerializeToBuilder(new RecordsetListWrapper {
                    Description = result.Description, RecordsetList = result, SerializedResult = serializedResult
                });
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err);
            }

            return(serializer.SerializeToBuilder(msg));
        }
Пример #29
0
 private static void LoadPlugins()
 {
     if (availablePlugins.Count == 0)
     {
         List <PluginServices.AvailablePlugin> Pluginz = new List <PluginServices.AvailablePlugin>();
         string path = Path.GetDirectoryName(FileSystemWalker.PluginsDirectory + @"\\Plugins");
         OMLApplication.DebugLine("Path is: " + path);
         Pluginz = PluginServices.FindPlugins(path, "OMLSDK.IOMLPlugin");
         OMLPlugin objPlugin;
         // Loop through available plugins, creating instances and adding them
         foreach (PluginServices.AvailablePlugin oPlugin in Pluginz)
         {
             objPlugin = (OMLPlugin)PluginServices.CreateInstance(oPlugin);
             availablePlugins.Add(objPlugin);
         }
         Pluginz = null;
     }
 }
        public LookupModel Process(TypeModel model, BeebyteDeobfuscatorPlugin plugin)
        {
            if (!plugin.CompilerType.HasValue)
            {
                return(null);
            }

            PluginServices services = PluginServices.For(plugin);

            services.StatusUpdate("Loading unobfuscated application");
            var il2cppClean = Il2CppInspector.Il2CppInspector.LoadFromPackage(new[] { plugin.BinaryPath }, statusCallback: services.StatusUpdate);

            if (il2cppClean == null)
            {
                il2cppClean = Il2CppInspector.Il2CppInspector.LoadFromFile(plugin.BinaryPath, plugin.MetadataPath, statusCallback: services.StatusUpdate);
            }

            if (il2cppClean == null)
            {
                throw new System.ArgumentException("Could not load unobfuscated application");
            }

            if (plugin.CompilerType.Value != CppCompiler.GuessFromImage(il2cppClean[0].BinaryImage))
            {
                throw new System.ArgumentException("Cross compiler deobfuscation has not been implemented yet");
            }
            services.StatusUpdate("Creating type model for unobfuscated application");
            var modelClean = new TypeModel(il2cppClean[0]);

            if (modelClean == null)
            {
                throw new System.ArgumentException("Could not create type model for unobfuscated application");
            }

            services.StatusUpdate("Creating LookupModel for obfuscated application");
            LookupModel lookupModel = new LookupModel(plugin.NamingRegex);

            lookupModel.Init(model.ToLookupModule(lookupModel, statusCallback: services.StatusUpdate), modelClean.ToLookupModule(lookupModel, statusCallback: services.StatusUpdate));
            services.StatusUpdate("Deobfuscating binary");
            lookupModel.TranslateTypes(true, statusCallback: services.StatusUpdate);

            plugin.CompilerType = null;
            return(lookupModel);
        }
Пример #31
0
 public virtual void Initialize(PluginServices services)
 {
 }
Пример #32
0
 public void Initialize(PluginServices services)
 {
     services.Resolver.AddBefore(typeof(ThrowsPendingActivatorResolver), new ParentContainerActivatorResolver(_container));
 }
Пример #33
0
 public virtual void Initialize(PluginServices services)
 {
     services.Container.AddListener(this);
 }
Пример #34
0
 public virtual void ReadyForServices(PluginServices services)
 {
 }