private static void Run(string[] args) { // ignore all certs ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; // parse program flags if (!CommandLineFlagManager.Parse(args)) { return; } //attach handler for shutdown tasks AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; _log.Trace($"Initiating Ghosts startup - Local time: {DateTime.Now.TimeOfDay} UTC: {DateTime.UtcNow.TimeOfDay}"); //load configuration try { Configuration = ClientConfigurationLoader.Config; } catch (Exception e) { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var o = $"Exec path: {path} - configuration 404: {ApplicationDetails.ConfigurationFiles.Application} - exiting. Exception: {e}"; _log.Fatal(o); Console.WriteLine(o); Console.ReadLine(); return; } DebugManager.Evaluate(); StartupTasks.CheckConfigs(); Thread.Sleep(500); //show window if debugging or if --debug flag passed in var handle = GetConsoleWindow(); if (!IsDebug) { ShowWindow(handle, SwHide); //add hook to manage processes running in order to never tip a machine over StartupTasks.CleanupProcesses(); } //add ghosts to startup StartupTasks.SetStartup(); //add listener on a port or ephemeral file watch to handle ad hoc commands ListenerManager.Run(); //do we have client id? or is this first run? _log.Trace(Comms.CheckId.Id); //connect to command server for 1) client id 2) get updates and 3) sending logs/surveys Comms.Updates.Run(); //local survey gathers information such as drives, accounts, logs, etc. if (Configuration.Survey.IsEnabled) { try { Survey.SurveyManager.Run(); } catch (Exception exc) { _log.Error(exc); } } if (Configuration.HealthIsEnabled) { try { var h = new Health.Check(); h.Run(); } catch (Exception exc) { _log.Error(exc); } } //timeline processing if (Configuration.HandlersIsEnabled) { try { var o = new Orchestrator(); o.Run(); } catch (Exception exc) { _log.Error(exc); } } //ghosts singleton new ManualResetEvent(false).WaitOne(); }