예제 #1
0
        public void Start()
        {
            if (isStarted) throw new Exception("Server has already been started!");
            isStarted = true;

            Log.Debug("Starting Server...");

            // Load existing or default server configuration
            ServerConfiguration.Load();

            UserMgr.Directory = Configuration.Directory;
            
            if (!UserMgr.Initialize())
                DefaultSecurityGroups.Initialize(UserMgr);

            Http.Initialize();

            MessageRegistry.Scan(Assembly.GetExecutingAssembly());
            MessageRegistry.Scan(typeof(ILibraryAssembly).Assembly);
            MessageRegistry.Scan(typeof(IFrameworkAssembly).Assembly);

            // TODO: Cache Project Package Index?
            //ProjectPackages.Initialize();

            Sessions.Start();
            Queue.Start();

            var taskVariables = Task.Run(() => Variables.Load(Configuration.VariablesDirectory));
            var taskHttp = Task.Run(() => Http.Start());
            var taskAgents = Task.Run(() => Agents.Load());
            var taskProjects = Task.Run(() => Projects.Load());

            Task.WaitAll(
                taskVariables,
                taskAgents,
                taskProjects,
                taskHttp);

            ProjectPackageCache.Initialize()
                .GetAwaiter().GetResult();

            HealthChecks.Start();

            Log.Info("Server started.");
        }
예제 #2
0
        static void Main(string[] args)
        {
            try {
                // Default: Load WindowsBaseSecurity
                Console.WriteLine("Cyberarms Intrusion Detection Command line plugin test tool");
                System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();
                Agents.Load(p.MainModule.FileName.Remove(p.MainModule.FileName.LastIndexOf('\\')) + "\\Plugins\\Cyberarms.IntrusionDetection.Base.Plugins.dll");
                StartAgent("WindowsSecurityBase");

                if (args.Length > 0)
                {
                    foreach (string arg in args)
                    {
                        if (arg.StartsWith("-assemblyName="))
                        {
                            Agents.Load(arg.Remove(0, 14));
                        }
                    }
                    foreach (string arg in args)
                    {
                        if (arg.StartsWith("-startAgent="))
                        {
                            string agentName = arg.Remove(0, 12);
                            StartAgent(agentName);
                        }
                    }
                }

                while (true)
                {
                    ;
                }
            } catch {
                ShowUsage();
            }
        }