示例#1
0
 internal void SetPluginProxy(PluginProxy proxy)
 {
     foreach (var p in proxy.Plugins)
     {
         plugins.Add(new PluginItemViewModel(p));
     }
 }
示例#2
0
        private void StackScanner(ConcurrentQueue <string> queue)
        {
            while (true)
            {
                queue.TryDequeue(out var changedObjectPath);

                if (string.IsNullOrEmpty(changedObjectPath))
                {
                    continue;
                }

                PluginResult scanResult = PluginProxy.Instance(_config).Scan(changedObjectPath, PluginType.File);

                if (scanResult.RiskRate != ThreatRiskRates.NoRisk)
                {
                    bool?sendCommandResult = _pipeServer?.SendCommandToUI(new BeSafePipeCommand
                    {
                        CommandId        = Guid.NewGuid(),
                        Command          = PipeCommands.PluginScanResult,
                        PluginScanResult = scanResult
                    });

                    // Log threat
                    ThreatLog.Log(scanResult);
                }

                Thread.Sleep(500);
            }
        }
示例#3
0
        private void StackScanner(ConcurrentQueue <ChangedValueInfo> queue)
        {
            while (true)
            {
                queue.TryDequeue(out var valueInfo);

                if (valueInfo == null)
                {
                    continue;
                }

                PluginResult scanResult = PluginProxy.Instance(_config).Scan(valueInfo, PluginType.Registry);

                if (scanResult.RiskRate != ThreatRiskRates.NoRisk)
                {
                    bool?sendCommandResult = _pipeServer?.SendCommandToUI(new BeSafePipeCommand
                    {
                        CommandId        = Guid.NewGuid(),
                        Command          = PipeCommands.PluginScanResult,
                        PluginScanResult = scanResult
                    });

                    // Log threat
                    ThreatLog.Log(scanResult);
                }

                Thread.Sleep(500);
            }
        }
示例#4
0
        public void InitPlugin(string pluginPath)
        {
            if (PluginProxy != null)
            {
                throw new Exception("Attempt to load plugin twice");
            }

            PluginProxy = new PluginProxy(pluginPath);
        }
示例#5
0
    public override void OnRegister()
    {
        base.OnRegister();
        _pluginProxy = (PluginProxy) Facade.RetrieveProxy(PluginProxy.NAME);

        List<IPlugin> Plugins = _pluginProxy.GetPluginList();
        for(int i = 0; i < Plugins.Count; i++){
            View.AddPlugin(i, Plugins[i]);
        }
    }
示例#6
0
        private ThreatRiskRates OnFileAccessRequestEvent(string filePath)
        {
            PluginResult scanResult = PluginProxy.Instance(_config).Scan(filePath, PluginType.File);

            if (scanResult.RiskRate != ThreatRiskRates.NoRisk)
            {
                bool?sendCommandResult = _pipeServer?.SendCommandToUI(new BeSafePipeCommand
                {
                    CommandId        = Guid.NewGuid(),
                    Command          = PipeCommands.PluginScanResult,
                    PluginScanResult = scanResult
                });

                // Log threat
                ThreatLog.Log(scanResult);
            }

            return(scanResult.RiskRate);
        }
示例#7
0
        static CSharpPluginLoader()
        {
            Evidence       evidence = new Evidence(Assembly.GetExecutingAssembly().Evidence);
            AppDomainSetup setup    = AppDomain.CurrentDomain.SetupInformation;

            pluginAppDomain = AppDomain.CreateDomain("BukkitNETPlugins", evidence, setup);

            _proxy = (PluginProxy)pluginAppDomain.CreateInstanceAndUnwrap(proxyType.Assembly.FullName, proxyType.FullName);

            AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
            {
                string asmBase = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "plugins");

                Assembly assm             = null;
                string   strTempAssmbPath = string.Empty;

                Assembly       objExecutingAssemblies  = Assembly.GetExecutingAssembly();
                AssemblyName[] arrReferencedAssmbNames = objExecutingAssemblies.GetReferencedAssemblies();

                AssemblyName myAssemblyName = Array.Find <AssemblyName>(arrReferencedAssmbNames, a => a.Name == e.Name);

                if (myAssemblyName != null)
                {
                    assm = Assembly.LoadFrom(myAssemblyName.CodeBase);
                }
                else
                {
                    strTempAssmbPath = Path.Combine(asmBase, e.Name.Substring(0, e.Name.IndexOf(",")) + ".dll");

                    if (!string.IsNullOrEmpty(strTempAssmbPath))
                    {
                        if (File.Exists(strTempAssmbPath))
                        {
                            assm = Assembly.LoadFrom(strTempAssmbPath);
                        }
                    }
                }

                return(assm);
            };
        }
示例#8
0
        public string MapDrive(string virtualPath)
        {
            if (string.IsNullOrEmpty(virtualPath))
            {
                throw new ArgumentNullException(nameof(virtualPath));
            }

            try
            {
                string beSafeDriveLetter = CheckPathAlreadyMapped(virtualPath);
                if (!string.IsNullOrEmpty(beSafeDriveLetter))
                {
                    return(beSafeDriveLetter);
                }

                string unusedDriveLetter     = FirstUnusedDriveLetter();
                string normalizedDriveLetter = NormalizeDriveLetter(unusedDriveLetter);

                Task.Run(() =>
                {
                    BeSafeConfig config          = ConfigLoader.Instance().LoadConfig();
                    IPluginProxy pluginRegulator = new PluginProxy(config);

                    _virtualDriveImpl = new BeSafeFileSystemImpl(virtualPath, pluginRegulator);
                    _virtualDriveImpl.FileAccessRequest += FileAccessRequestEvent;
                    _virtualDriveImpl.Mount(normalizedDriveLetter, DokanOptions.FixedDrive, NumberOfThradsToManageFileSystem);
                });

                return(normalizedDriveLetter);
            }
            catch (Exception ex)
            {
                ex.Log(ExceptionType.SecureVolume, "Can not mount virtual drive");
                return(null);
            }
        }
示例#9
0
 static IntPtr getName()
 {
     return(PluginProxy.getName());
 }
示例#10
0
 static uint messageProc(uint Message, IntPtr wParam, IntPtr lParam)
 {
     return(PluginProxy.messageProc(Message, wParam, lParam));
 }
示例#11
0
 static IntPtr getFuncsArray(ref int nbF)
 {
     return(PluginProxy.getFuncsArray(ref nbF));
 }
示例#12
0
 static void setInfo(NppData notepadPlusData)
 {
     PluginProxy.setInfo(notepadPlusData);
 }
示例#13
0
 static bool isUnicode()
 {
     return(PluginProxy.isUnicode());
 }
示例#14
0
 static UnmanagedExports()
 {
     // Debug.Assert(false);
     PluginProxy.Init();
 }
示例#15
0
 static void beNotified(IntPtr notifyCode)
 {
     PluginProxy.beNotified(notifyCode);
 }