コード例 #1
0
        private void Load_Plugins()
        {
            var files = Directory.EnumerateFiles(System.AppDomain.CurrentDomain.BaseDirectory);

            foreach (string file in files)
            {
                if (System.IO.Path.GetExtension(file) == ".dll")
                {
                    Assembly asm   = Assembly.LoadFile(file);
                    Type[]   tlist = asm.GetTypes();
                    foreach (Type t in tlist)
                    {
                        var i = t.GetInterface("IPlugin");
                        if (i != null)
                        {
                            IPlugin myPlugin = Activator.CreateInstance(t) as IPlugin;
                            Plugins.Add(myPlugin);
                            PluginNames.Add(t.Name);
                            break;
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void ParseArguments(string[] args)
        {
            var enumerator = args.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var arg = (string)enumerator.Current;

                if (arg == "--plugins")
                {
                    enumerator.MoveNext();
                    PluginPaths.Add((string)enumerator.Current);
                }

                if (arg == "--plugin-name")
                {
                    enumerator.MoveNext();
                    var v = (string)enumerator.Current;
                    var s = v.Split('@');
                    if (s.Length > 1)
                    {
                        PluginNames.Add(new KeyValuePair <string, string>(s[0], s[1]));
                    }
                    else
                    {
                        PluginNames.Add(new KeyValuePair <string, string>(s[0], string.Empty));
                    }
                }

                if (arg == "-s")
                {
                    enumerator.MoveNext();
                    SolutionRoot = Path.GetFullPath((string)enumerator.Current);
                }
            }

            BootstrapPath        = Path.GetDirectoryName(_appEnv.ApplicationBasePath);
            OmnisharpProjectPath = Path.Combine(BootstrapPath, "OmniSharp.Host", "project.json");
            if (!File.Exists(OmnisharpProjectPath))
            {
                OmnisharpProjectPath = Path.Combine(OmnisharpProjectPath, "OmniSharp.Host", "1.0.0", "root", "project.json");
            }

            if (!string.IsNullOrEmpty(SolutionRoot))
            {
                var pluginsFolder = Path.Combine(SolutionRoot, ".omnisharp", "plugins");
                if (Directory.Exists(pluginsFolder))
                {
                    PluginPaths.Add(pluginsFolder);
                }

                var omnisharpJsonPath = Path.Combine(SolutionRoot, "omnisharp.json");
                if (File.Exists(omnisharpJsonPath))
                {
                    var omnisharpJson = JObject.Parse(File.ReadAllText(omnisharpJsonPath));
                    if (omnisharpJson["plugins"] != null)
                    {
                        var omnisharpJsonPlugins = omnisharpJson["plugins"];
                        foreach (var plugin in omnisharpJsonPlugins)
                        {
                            if (plugin is JObject)
                            {
                                var pluginJobject = plugin as JObject;
                                PluginNames.Add(new KeyValuePair <string, string>(pluginJobject["name"].ToString(), pluginJobject["version"].ToString()));
                            }
                            else if (plugin is JToken)
                            {
                                var pluginString      = plugin.ToString();
                                var pluginSplitString = pluginString.Split('@');
                                if (pluginSplitString.Length > 1)
                                {
                                    PluginNames.Add(new KeyValuePair <string, string>(pluginSplitString[0], pluginSplitString[1]));
                                }
                                else
                                {
                                    PluginNames.Add(new KeyValuePair <string, string>(pluginSplitString[0], string.Empty));
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: Parser.cs プロジェクト: vaginessa/NetworkScanViewer
        /// <summary>
        ///
        /// </summary>
        /// <param name="itemType"></param>
        /// <param name="value"></param>
        private void AddItem(ItemType itemType, object value)
        {
            if (value.ToString().Length == 0)
            {
                return;
            }

            switch (itemType)
            {
            case ItemType.IpAddress:
                var ipAddresses = from ipAddress in IpAddresses where ipAddress.Text.ToUpper() == ((string)value).ToUpper() select ipAddress;
                if (ipAddresses.Count() == 0)
                {
                    IpAddress ipAddress = new IpAddress();
                    ipAddress.Text = (string)value;
                    IpAddresses.Add(ipAddress);
                }
                break;

            case ItemType.HostName:
                var hosts = from host in HostNames where host.ToUpper() == ((string)value).ToUpper() select host;
                if (hosts.Count() == 0)
                {
                    HostNames.Add((string)value);
                }
                break;

            case ItemType.Port:
                var ports = from port in Ports where port == (int)value select port;
                if (ports.Count() == 0)
                {
                    Ports.Add((int)value);
                }
                break;

            case ItemType.Protocol:
                var protocols = from protocol in Protocols where protocol.ToUpper() == ((string)value).ToUpper() select protocol;
                if (protocols.Count() == 0)
                {
                    Protocols.Add(((string)value).ToUpper());
                }
                break;

            case ItemType.Service:
                var services = from service in Services where service.ToUpper() == ((string)value).ToUpper() select service;
                if (services.Count() == 0)
                {
                    Services.Add((string)value);
                }
                break;

            case ItemType.State:
                var states = from state in States where state.ToUpper() == ((string)value).ToUpper() select state;
                if (states.Count() == 0)
                {
                    States.Add((string)value);
                }
                break;

            case ItemType.Severities:
                var severities = from severity in Severities where severity.ToUpper() == ((string)value).ToUpper() select severity;
                if (severities.Count() == 0)
                {
                    Severities.Add((string)value);
                }
                break;

            case ItemType.PluginFamily:
                var pluginFamilies = from pluginFamily in PluginFamilys where pluginFamily.ToUpper() == ((string)value).ToUpper() select pluginFamily;
                if (pluginFamilies.Count() == 0)
                {
                    PluginFamilys.Add((string)value);
                }
                break;

            case ItemType.PluginId:
                var pluginIds = from pluginId in PluginIds where pluginId.ToString().ToUpper() == ((string)value).ToUpper() select pluginId;
                if (pluginIds.Count() == 0)
                {
                    PluginIds.Add(int.Parse(value.ToString()));
                }
                break;

            case ItemType.PluginName:
                var pluginNames = from pluginName in PluginNames where pluginName.ToUpper() == ((string)value).ToUpper() select pluginName;
                if (pluginNames.Count() == 0)
                {
                    PluginNames.Add((string)value);
                }
                break;

            case ItemType.Product:
                var products = from product in Products where product.ToUpper() == ((string)value).ToUpper() select product;
                if (products.Count() == 0)
                {
                    Products.Add((string)value);
                }
                break;

            case ItemType.Versions:
                var versions = from version in Versions where version.ToUpper() == ((string)value).ToUpper() select version;
                if (versions.Count() == 0)
                {
                    Versions.Add((string)value);
                }
                break;

            case ItemType.ExploitAvailable:
                var exploitAvailable = from e in ExploitAvailable where e.ToUpper() == ((string)value).ToUpper() select e;
                if (exploitAvailable.Count() == 0)
                {
                    ExploitAvailable.Add((string)value);
                }
                break;

            default:
                break;
            }
        }