示例#1
0
        public UnprotectedAccount(JsonAccounts.JsonAccount json) : base(json)
        {
            _log = LogCreator.Create("GC - " + json.Username + " (Unprotected)");

            _steamClient     = new SteamClient();
            _callbacks       = new CallbackManager(_steamClient);
            _steamUser       = _steamClient.GetHandler <SteamUser>();
            _steamFriends    = _steamClient.GetHandler <SteamFriends>();
            _gameCoordinator = _steamClient.GetHandler <SteamGameCoordinator>();

            _log.Debug("Successfully initialized account object for {0}.", json.Username);
        }
示例#2
0
文件: LoginKey.cs 项目: yajinn/Titan
        public LoginKey(TitanAccount account)
        {
            _log = LogCreator.Create("Login Key - " + account.JsonAccount.Username);

            var dir = new DirectoryInfo(Path.Combine(Titan.Instance.Directory.ToString(), "loginkeys"));

            if (!dir.Exists)
            {
                dir.Create();
            }

            _file = new FileInfo(Path.Combine(dir.ToString(), account.JsonAccount.Username + ".key"));
        }
示例#3
0
        public Sentry(TitanAccount account)
        {
            _log = LogCreator.Create("Sentry - " + account.JsonAccount.Username);

            var dir = new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, "sentries"));

            if (!dir.Exists)
            {
                dir.Create();
            }

            _file = new FileInfo(Path.Combine(dir.ToString(), account.JsonAccount.Username + ".sentry.bin"));
        }
示例#4
0
        public Startup(IConfiguration configuration, IHostingEnvironment env)
        {
            _configuration    = configuration;
            _connectionString = configuration.GetConnectionString("DefaultConnection");

            _isDevelopment   = env.IsDevelopment();
            _webRootPath     = env.WebRootPath;
            _contentRootPath = env.ContentRootPath;

            _appSettings = new AppSettings();
            _configuration.Bind("AppSettings", _appSettings);

            Log.Logger = LogCreator.Create(_connectionString);
            ObjectMapper.RegisterMapping();
        }
示例#5
0
        public UnprotectedAccount(JsonAccounts.JsonAccount json) : base(json)
        {
            _log = LogCreator.Create("GC - " + json.Username + (!Titan.Instance.Options.Secure ? " (Unprotected)" : ""));

            _steamConfig = SteamConfiguration.Create(builder =>
            {
                builder.WithConnectionTimeout(TimeSpan.FromMinutes(1));

                var key = Titan.Instance.WebHandle.GetKey();

                if (!string.IsNullOrEmpty(key))
                {
                    builder.WithWebAPIKey(key);
                    _log.Debug("Initializing with preloaded API key.");
                }
                else
                {
                    _log.Debug("Initializing without API key.");
                }
            });

            _steamClient     = new SteamClient(_steamConfig);
            _callbacks       = new CallbackManager(_steamClient);
            _steamUser       = _steamClient.GetHandler <SteamUser>();
            _steamFriends    = _steamClient.GetHandler <SteamFriends>();
            _gameCoordinator = _steamClient.GetHandler <SteamGameCoordinator>();

            // This clause excludes SteamKit debug mode as that mode is handeled seperately.
            // Normal debug mode doesn't equal SteamKit debug mode.
            if (Titan.Instance.Options.Debug)
            {
                _titanHandle = new TitanHandler();
                _steamClient.AddHandler(_titanHandle);

                // Initialize debug network sniffer when debug mode is enabled
                var dir = new DirectoryInfo(Path.Combine(Titan.Instance.DebugDirectory.ToString(), json.Username));
                if (!dir.Exists)
                {
                    dir.Create();
                }

                _steamClient.DebugNetworkListener = new NetHookNetworkListener(
                    dir.ToString()
                    );
            }

            _log.Debug("Successfully initialized account object for {Username}.", json.Username);
        }
示例#6
0
        public ProtectedAccount(JsonAccounts.JsonAccount json) : base(json)
        {
            _log = LogCreator.Create("GC - " + json.Username + (!Titan.Instance.Options.Secure ? " (Protected)" : ""));

            _steamConfig = SteamConfiguration.Create(builder =>
            {
                builder.WithConnectionTimeout(TimeSpan.FromMinutes(1));
                //builder.WithWebAPIKey(Titan.Instance.WebHandle.GetKey()); Is null at time of this creation - needs fix
            });

            _sentry   = new Sentry.Sentry(this);
            _loginKey = new LoginKey(this);

            _steamClient     = new SteamClient(_steamConfig);
            _callbacks       = new CallbackManager(_steamClient);
            _steamUser       = _steamClient.GetHandler <SteamUser>();
            _steamFriends    = _steamClient.GetHandler <SteamFriends>();
            _gameCoordinator = _steamClient.GetHandler <SteamGameCoordinator>();

            // This clause excludes SteamKit debug mode as that mode is handeled seperately.
            // Normal debug mode doesn't equal SteamKit debug mode.
            if (Titan.Instance.Options.Debug)
            {
                _titanHandle = new TitanHandler();
                _steamClient.AddHandler(_titanHandle);

                // Initialize debug network sniffer when debug mode is enabled
                var dir = new DirectoryInfo(Path.Combine(Titan.Instance.DebugDirectory.ToString(), json.Username));
                if (!dir.Exists)
                {
                    dir.Create();
                }

                _steamClient.DebugNetworkListener = new NetHookNetworkListener(
                    dir.ToString()
                    );
            }

            if (!string.IsNullOrWhiteSpace(JsonAccount.SharedSecret))
            {
                _sharedSecretGenerator = new SharedSecret(this);
            }

            _log.Debug("Successfully initialized account object for " + json.Username + ".");
        }
示例#7
0
        public ProtectedAccount(JsonAccounts.JsonAccount json) : base(json)
        {
            _log = LogCreator.Create("GC - " + json.Username + (!Titan.Instance.Options.Secure ? " (Protected)" : ""));

            _steamConfig = SteamConfiguration.Create(builder =>
            {
                builder.WithConnectionTimeout(TimeSpan.FromMinutes(1));
                //builder.WithWebAPIKey(Titan.Instance.WebHandle.GetKey()); Is null at time of this creation - needs fix
            });

            _sentry = new Sentry.Sentry(this);

            _steamClient     = new SteamClient(_steamConfig);
            _callbacks       = new CallbackManager(_steamClient);
            _steamUser       = _steamClient.GetHandler <SteamUser>();
            _steamFriends    = _steamClient.GetHandler <SteamFriends>();
            _gameCoordinator = _steamClient.GetHandler <SteamGameCoordinator>();

            _titanHandle = new TitanHandler();
            _steamClient.AddHandler(_titanHandle);

            // Initialize debug network sniffer when debug mode is enabled
            if (Titan.Instance.Options.Debug)
            {
                var dir = new DirectoryInfo(Path.Combine(Titan.Instance.DebugDirectory.ToString(), json.Username));
                if (!dir.Exists)
                {
                    dir.Create();
                }

                _steamClient.DebugNetworkListener = new NetHookNetworkListener(
                    dir.ToString()
                    );
            }

            if (json.SharedSecret != null)
            {
                _sgAccount = new SteamGuardAccount
                {
                    SharedSecret = json.SharedSecret
                };
            }

            _log.Debug("Successfully initialized account object for " + json.Username + ".");
        }
示例#8
0
        public UnprotectedAccount(JsonAccounts.JsonAccount json) : base(json)
        {
            _log = LogCreator.Create("GC - " + json.Username + (!Titan.Instance.Options.Secure ? " (Unprotected)" : ""));

            _steamConfig = new SteamConfiguration
            {
                ConnectionTimeout = TimeSpan.FromMinutes(1),
                WebAPIKey         = Titan.Instance.WebHandle.GetKey() // May be null at this time, but we can accept that for now
            };

            _steamClient     = new SteamClient(_steamConfig);
            _callbacks       = new CallbackManager(_steamClient);
            _steamUser       = _steamClient.GetHandler <SteamUser>();
            _steamFriends    = _steamClient.GetHandler <SteamFriends>();
            _gameCoordinator = _steamClient.GetHandler <SteamGameCoordinator>();

            _titanHandle = new TitanHandler();
            _steamClient.AddHandler(_titanHandle);

            // Initialize debug network sniffer when debug mode is enabled
            if (Titan.Instance.Options.Debug)
            {
                var dir = new DirectoryInfo(Path.Combine(Titan.Instance.DebugDirectory.ToString(), json.Username));
                if (!dir.Exists)
                {
                    dir.Create();
                }

                _steamClient.DebugNetworkListener = new NetHookNetworkListener(
                    dir.ToString()
                    );
            }

            Job = JobBuilder.Create <UnprotectedAccount>()
                  .WithIdentity("Idle Job - " + json.Username + " (Unprotected)", "Titan")
                  .Build();

            _log.Debug("Successfully initialized account object for {Username}.", json.Username);
        }
示例#9
0
        public ProtectedAccount(JsonAccounts.JsonAccount json) : base(json)
        {
            _log = LogCreator.Create("GC - " + json.Username + " (Protected)");

            _file = new FileInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "sentries"),
                                              json.Username + ".sentry"));

            _steamClient     = new SteamClient();
            _callbacks       = new CallbackManager(_steamClient);
            _steamUser       = _steamClient.GetHandler <SteamUser>();
            _steamFriends    = _steamClient.GetHandler <SteamFriends>();
            _gameCoordinator = _steamClient.GetHandler <SteamGameCoordinator>();

            if (json.SharedSecret != null)
            {
                _sgAccount = new SteamGuardAccount
                {
                    SharedSecret = json.SharedSecret
                };
            }

            _log.Debug("Successfully initialized account object for " + json.Username + ".");
        }
示例#10
0
        public ProtectedAccount(JsonAccounts.JsonAccount json) : base(json)
        {
            _log = LogCreator.Create("GC - " + json.Username + " (Protected)");

            _file = new FileInfo(Path.Combine(Path.Combine(Environment.CurrentDirectory, "sentries"),
                                              json.Username + ".sentry"));

            _steamClient     = new SteamClient();
            _callbacks       = new CallbackManager(_steamClient);
            _steamUser       = _steamClient.GetHandler <SteamUser>();
            _steamFriends    = _steamClient.GetHandler <SteamFriends>();
            _gameCoordinator = _steamClient.GetHandler <SteamGameCoordinator>();

            // Initialize debug network sniffer when debug mode is enabled
            if (Titan.Instance.Options.Debug)
            {
                var dir = new DirectoryInfo(Path.Combine(Titan.Instance.DebugDirectory.ToString(), json.Username));
                if (!dir.Exists)
                {
                    dir.Create();
                }

                _steamClient.DebugNetworkListener = new NetHookNetworkListener(
                    dir.ToString()
                    );
            }

            if (json.SharedSecret != null)
            {
                _sgAccount = new SteamGuardAccount
                {
                    SharedSecret = json.SharedSecret
                };
            }

            _log.Debug("Successfully initialized account object for " + json.Username + ".");
        }
示例#11
0
文件: Titan.cs 项目: ra1N1336/Titan
        public static int Main(string[] args)
        {
            Thread.CurrentThread.Name = "Main";

            // Initialize Titan Singleton
            Instance = new Titan
            {
                Options = new Options()
            };

            // Create official Titan logger
            Logger = LogCreator.Create();

            Logger.Debug("Startup: Loading Serilog <-> Common Logging Bridge.");

            // Common Logging <-> Serilog bridge
            Log.Logger = LogCreator.Create("Quartz.NET Scheduler");

            Logger.Debug("Startup: Loading Quartz.NET.");

            // Quartz.NET
            Instance.Scheduler = StdSchedulerFactory.GetDefaultScheduler();
            Instance.Scheduler.Start();

            Logger.Debug("Startup: Refreshing Steam Universe list.");

            // SteamKit
            SteamDirectory.Initialize().Wait();

            Logger.Debug("Startup: Parsing Command Line Arguments.");

            // Parse arguments provided with the starting of this
            if (Parser.Default.ParseArguments(args, Instance.Options))
            {
                Logger.Information("Skipping UI and going directly to botting - Target: {Target} - Match ID: {ID}", Instance.Options.Target, Instance.Options.MatchID);
                Instance.EnableUI = false;
            }
            else
            {
                Logger.Information("The arguments --target and --mode were omitted - opening the UI.");
                Instance.EnableUI = true;
            }

            // Reinitialize logger with new parsed debug option
            Logger = LogCreator.Create();

            // Initialize the Debug directory if Debug mode is enabled
            if (Instance.Options.Debug)
            {
                if (!Instance.DebugDirectory.Exists)
                {
                    Instance.DebugDirectory.Create();
                }
            }

            Logger.Debug("Startup: Loading UI Manager, Victim Tracker, Account Manager and Ban Manager.");

            Instance.UIManager = new UIManager();

            // Initialize Victim Tracker
            Instance.VictimTracker = new VictimTracker();

            // Schedule Victim Tracking
            Instance.Scheduler.ScheduleJob(Instance.VictimTracker.Job, Instance.VictimTracker.Trigger);

            // Initialize Account Manager
            Instance.AccountManager = new AccountManager(new FileInfo(
                                                             Path.Combine(Environment.CurrentDirectory, Instance.Options.File))
                                                         );

            // Initialize Thread Manager
            Instance.ThreadManager = new ThreadManager();

            // Initialize Ban Manager
            Instance.BanManager = new BanManager();

            Logger.Debug("Startup: Registering Shutdown Hook.");

            // Register shutdown hook
            AppDomain.CurrentDomain.ProcessExit += OnShutdown;

            Logger.Debug("Startup: Parsing accounts.json file.");

            if (Instance.AccountManager.ParseAccountFile())
            {
                Logger.Debug("Initializing Forms...");

                Instance.UIManager.InitializeForms();


                Logger.Debug("Startup: Loading Web API Key");

                // Resolve API Key File
                Instance.APIKeyResolver = new WebAPIKeyResolver();
                Instance.APIKeyResolver.ParseKeyFile();

                Logger.Information("Hello and welcome to Titan v1.4.0-Dev.");

                if (Instance.EnableUI)
                {
                    Instance.UIManager.ShowForm(UIType.General);
                }
                else
                {
                    switch (Regex.Replace(Instance.Options.Mode.ToLowerInvariant(), @"\s+", ""))
                    {
                    case "report":
                        Instance.AccountManager.StartReporting(Instance.AccountManager.Index,
                                                               new ReportInfo
                        {
                            SteamID = SteamUtil.Parse(Instance.Options.Target),
                            MatchID = SharecodeUtil.Parse(Instance.Options.MatchID),

                            AbusiveText  = Instance.Options.AbusiveTextChat,
                            AbusiveVoice = Instance.Options.AbusiveVoiceChat,
                            Griefing     = Instance.Options.Griefing,
                            AimHacking   = Instance.Options.AimHacking,
                            WallHacking  = Instance.Options.WallHacking,
                            OtherHacking = Instance.Options.OtherHacking
                        });
                        break;

                    case "commend":
                        Instance.AccountManager.StartCommending(Instance.AccountManager.Index,
                                                                new CommendInfo
                        {
                            SteamID = SteamUtil.Parse(Instance.Options.Target),

                            Friendly = Instance.Options.Friendly,
                            Leader   = Instance.Options.Leader,
                            Teacher  = Instance.Options.Teacher
                        });
                        break;

                    default:
                        Log.Error("Could not parse {Mode} to Mode.", Instance.Options.Mode);

                        Instance.UIManager.ShowForm(UIType.General);
                        break;
                    }
                }

                Instance.UIManager.StartMainLoop();
            }

            // The Shutdown handler gets only called after the last thread finished.
            // Quartz runs a Watchdog until Scheduler#Shutdown is called, so we're calling it
            // before Titan will be calling the Shutdown Hook.
            Logger.Debug("Shutdown: Shutting down Quartz.NET Scheduler.");

            Instance.Scheduler.Shutdown();

            return(0); // OK.
        }
示例#12
0
        public static int Main(string[] args)
        {
            Thread.CurrentThread.Name = "Main";

            Instance = new Titan
            {
                Options = new Options()
            };

            Logger = LogCreator.Create();

            if (Environment.CurrentDirectory != Instance.Directory.ToString())
            {
                Logger.Debug("Run from {currentDir}, switching to work directory in {workingDir}.",
                             Environment.CurrentDirectory, Instance.Directory.ToString());
            }

            // Windows users run the program by double clicking Titan.exe (and then it opens a console window)
            // and in case of exception occurence, this window gets immediatly closed which is bad because
            // they're unable to attach the stacktrace then. Prevent it by waiting until the user presses a key.
            #if !__UNIX__
            AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
            {
                if (eventArgs.IsTerminating)
                {
                    Logger.Error((Exception)eventArgs.ExceptionObject, "An error occured.");

                    // Don't use logging object here incase the exception was thrown by a logger
                    Console.Write("Press any key to exit Titan...");
                    Console.Read();
                }
            };
            #endif

            // The bridge between Common Logging and Serilog uses the global Logger (Log.Logger).
            // As Quartz.NET is the only dependency using Common Logging (and because of our bridge the global logger)
            // we're creating the global logger as Quartz logger (which hides annoying debug messages).
            Log.Logger = LogCreator.CreateQuartzLogger();

            // Quartz.NET
            Instance.Scheduler = StdSchedulerFactory.GetDefaultScheduler().Result;
            Instance.Scheduler.Start();

            Instance.JsonSerializer = new JsonSerializer();

            Instance.HttpClient = new HttpClient();
            Instance.HttpClient.DefaultRequestHeaders.Add(
                "User-Agent", "Titan Report & Commend Bot (https://github.com/Marc3842h/Titan)"
                );

            var parser = new Parser(config =>
            {
                config.IgnoreUnknownArguments = true;
                config.EnableDashDash         = true;
                config.HelpWriter             = TextWriter.Null;
            });

            // Default
            parser.ParseArguments <Options>(args)
            .WithParsed(options =>
            {
                Instance.Options = options;
            });

            // Verbs
            parser.ParseArguments <ReportOptions, CommendOptions>(args)
            .WithParsed <ReportOptions>(options =>
            {
                Instance.EnableUI     = false;
                Instance.ParsedObject = options;
            })
            .WithParsed <CommendOptions>(options =>
            {
                Instance.EnableUI     = false;
                Instance.ParsedObject = options;
            })
            .WithNotParsed(error =>
            {
                if (Instance.ParsedObject == null)
                {
                    Instance.EnableUI = true;
                    Logger.Information("No valid verb has been provided while parsing. Opening UI...");
                }
            });

            new Config.Config().Load();

            // Reinitialize logger with new parsed debug option
            Logger = LogCreator.Create();

            #if __UNIX__
            Instance.IsAdmin = Linux.getuid() == 0;     // UID of root is always 0
            #else
            Instance.IsAdmin = new WindowsPrincipal(WindowsIdentity.GetCurrent())
                               .IsInRole(WindowsBuiltInRole.Administrator);
            #endif

            if (Instance.IsAdmin)
            {
                if (!Instance.Options.AllowAdmin)
                {
                    Logger.Error("Titan is running as administrator or root.");
                    Logger.Error("This is not supported. Titan will refuse to start until you start it as normal " +
                                 "user. If you are unable to do this for any reason, start Titan with the --admin " +
                                 "option to force the usage of administrator rights.");

                    #if !__UNIX__
                    Console.Write("Press any key to exit Titan...");
                    Console.Read();
                    #endif

                    Instance.Scheduler.Shutdown();
                    return((int)ExitCodes.RunningAsAdmin);
                }

                Logger.Warning("Titan has been started as Administrator but will continue to run as the " +
                               "--admin option has been passed. Please note that Steam also doesn't allow to be " +
                               "run from root and that it may be insecure.");
            }

            if (Instance.Options.Debug)
            {
                Instance.DebugDirectory = new DirectoryInfo(Path.Combine(Instance.Directory.ToString(), "debug"));

                if (!Instance.DebugDirectory.Exists)
                {
                    Instance.DebugDirectory.Create();
                }

                if (Instance.Options.SteamKitDebug)
                {
                    DebugLog.AddListener(new TitanListener());
                    DebugLog.Enabled = true;
                }
            }

            if (Instance.Options.Secure)
            {
                Logger.Debug("Secure mode has been enabled. Titan will output no sensitive data.");
            }

            if (Instance.Options.DisableBlacklist)
            {
                Logger.Debug("Blacklist has been disabled by passing the --noblacklist option.");
            }

            Instance.ProfileSaver = new ProfileSaver();

            if (Instance.EnableUI)
            {
                try
                {
                    Instance.UIManager = new UIManager();
                }
                catch (InvalidOperationException ex)
                {
                    if (!string.IsNullOrEmpty(ex.Message) && ex.Message.ToLower().Contains("could not detect platform"))
                    {
                        Logger.Error("---------------------------------------");
                        Logger.Error("A fatal error has been detected!");
                        Logger.Error("Eto.Forms could not detect your current operating system.");

                        #if __UNIX__
                        Logger.Error("Please install {0}, {1}, {2} and {3} before submitting a bug report.",
                                     "Mono (\u22655.4)",
                                     "Gtk 3",
                                     "libNotify",
                                     "libAppindicator3");
                        #else
                        Logger.Error("Please install {0} before submitting a bug report.",
                                     ".NET Framework (\u22654.6.1)");
                        #endif

                        Logger.Error("Contact {Marc} on Discord if the issue still persists after installing " +
                                     "the dependencies listed above.", "Marc3842h#7312");
                        Logger.Error("---------------------------------------");
                        Logger.Debug(ex, "Include the error below if you\'re contacting Marc on Discord.");

                        #if !__UNIX__
                        Console.Write("Press any key to exit Titan...");
                        Console.Read();
                        #endif

                        Instance.Scheduler.Shutdown();
                        return((int)ExitCodes.UIInitFailed);
                    }

                    Logger.Error(ex, "A error occured while loading UI.");
                    throw;
                }
            }


            Instance.AccountManager = new AccountManager(new FileInfo(
                                                             Path.Combine(Instance.Directory.ToString(), Instance.Options.AccountsFile))
                                                         );

            Instance.ThreadManager = new ThreadManager();

            Instance.WebHandle = new SWAHandle();

            Instance.VictimTracker = new VictimTracker();

            AppDomain.CurrentDomain.ProcessExit += OnShutdown;

            Instance.AccountManager.ParseAccountFile();

            Task.Run(() => TimeAligner.AlignTime());

            if (Instance.EnableUI)
            {
                Instance.UIManager.InitializeForms();
            }

            // Load after Forms were initialized
            Instance.WebHandle.Load();

            // VictimTracker depends on the web api key being loaded correctly.
            Instance.VictimTracker.InitTrigger();

            var attribute = Assembly.GetEntryAssembly().GetCustomAttribute <AssemblyInformationalVersionAttribute>();
            var version   = attribute != null ? attribute.InformationalVersion :
                            Assembly.GetEntryAssembly().GetName().Version.Major + "." +
                            Assembly.GetEntryAssembly().GetName().Version.Minor + "." +
                            Assembly.GetEntryAssembly().GetName().Version.Build;

            Logger.Information("Hello and welcome to Titan {version}.", "v" + version);

            if (Instance.EnableUI && Instance.ParsedObject == null || Instance.DummyMode)
            {
                Instance.UIManager.ShowForm(UIType.General);
            }
            else
            {
                if (Instance.ParsedObject.GetType() == typeof(ReportOptions))
                {
                    var opt = (ReportOptions)Instance.ParsedObject;

                    var steamID = SteamUtil.Parse(opt.Target);
                    if (steamID.IsBlacklisted(opt.Game.ToAppID()))
                    {
                        Instance.UIManager.SendNotification(
                            "Restriction applied",
                            "The target you are trying to report is blacklisted from botting " +
                            "in Titan.",
                            () => Process.Start("https://github.com/Marc3842h/Titan/wiki/Blacklist")
                            );
                    }
                    else
                    {
                        Instance.AccountManager.StartReporting(Instance.AccountManager.Index,
                                                               new ReportInfo
                        {
                            SteamID = SteamUtil.Parse(opt.Target),
                            MatchID = SharecodeUtil.Parse(opt.Match),
                            AppID   = opt.Game.ToAppID(),

                            AbusiveText  = opt.AbusiveTextChat,
                            AbusiveVoice = opt.AbusiveVoiceChat,
                            Griefing     = opt.Griefing,
                            AimHacking   = opt.AimHacking,
                            WallHacking  = opt.WallHacking,
                            OtherHacking = opt.OtherHacking
                        });
                    }
                }
                else if (Instance.ParsedObject.GetType() == typeof(CommendOptions))
                {
                    var opt = (CommendOptions)Instance.ParsedObject;

                    Instance.AccountManager.StartCommending(Instance.AccountManager.Index,
                                                            new CommendInfo
                    {
                        SteamID = SteamUtil.Parse(opt.Target),
                        AppID   = TitanAccount.CSGO_APPID,

                        Friendly = opt.Friendly,
                        Leader   = opt.Leader,
                        Teacher  = opt.Teacher
                    });
                }
                else
                {
                    Instance.UIManager.ShowForm(UIType.General);
                }
            }

            Instance.Scheduler.ScheduleJob(Instance.VictimTracker.Job, Instance.VictimTracker.Trigger);

            Logger.Debug("Startup done. Active threads: {threads}", Process.GetCurrentProcess().Threads.Count + 1);

            Instance.StartMainLoop();

            // The Shutdown handler gets only called after the last thread finished.
            // Quartz runs a Watchdog until Scheduler#Shutdown is called, so we're calling it
            // before Titan will be calling the Shutdown Hook.
            Logger.Debug("Shutting down Quartz.NET Scheduler.");

            Instance.Scheduler.Shutdown();

            return((int)ExitCodes.Ok);
        }
示例#13
0
文件: 2FAForm.cs 项目: Tylsew/Titan
        public _2FAForm(ProtectedAccount account, string eMail = null)
        {
            Title     = "Titan - 2FA Action required - " + account.JsonAccount.Username;
            Resizable = false;
            Topmost   = true;
            Icon      = Titan.Instance.UIManager.SharedResources.TITAN_ICON;

            _log = LogCreator.Create("2FA Form - " + account.JsonAccount.Username + " (Protected)");

            TextControl txtBoxCode;

            if (Titan.Instance.Options.Secure)
            {
                txtBoxCode = new PasswordBox {
                    PasswordChar = '\u2022'
                };
            }
            else
            {
                txtBoxCode = new TextBox {
                    PlaceholderText = "GHC9Y"
                };
            }

            var btnSubmit = new Button {
                Text = "Submit"
            };

            btnSubmit.Click += (sender, args) =>
            {
                if (!string.IsNullOrWhiteSpace(txtBoxCode.Text))
                {
                    if (eMail != null)
                    {
                        account.FeedWithAuthToken(txtBoxCode.Text);
                        if (!Titan.Instance.Options.Secure)
                        {
                            _log.Debug("Feeding {account} with auth token: {token}", account.JsonAccount.Username,
                                       txtBoxCode.Text);
                        }
                    }
                    else
                    {
                        account.FeedWith2FACode(txtBoxCode.Text);
                        if (!Titan.Instance.Options.Secure)
                        {
                            _log.Debug("Feeding {account} with 2FA code: {code}", account.JsonAccount.Username,
                                       txtBoxCode.Text);
                        }
                    }

                    Close();
                }
                else
                {
                    Titan.Instance.UIManager.SendNotification(
                        "Titan - Error",
                        "Please provide a valid auth token or 2FA code.",
                        () => txtBoxCode.Focus()
                        );
                }
            };

            Content = new TableLayout
            {
                Spacing = new Size(5, 5),
                Padding = new Padding(10, 10, 10, 10),
                Rows    =
                {
                    new GroupBox
                    {
                        Text    = "Steam Guard",
                        Content = new TableLayout
                        {
                            Spacing = new Size(5, 5),
                            Padding = new Padding(10, 10, 10, 10),
                            Rows    =
                            {
                                new TableRow(
                                    new TableCell(new Label
                                {
                                    Text = "Steam Guard has been activated for " + account.JsonAccount.Username +
                                           ". \n" + (eMail != null ?
                                                     "Please input the code sent to your eMail at " + eMail + "." :
                                                     "Please input the code from the Steam Guard mobile app.")
                                })
                                    ),
                                new TableRow(
                                    new TableCell(txtBoxCode)
                                    )
                            }
                        }
                    },
                    new TableLayout
                    {
                        Spacing = new Size(5, 5),
                        Padding = new Padding(10, 10, 10, 10),
                        Rows    =
                        {
                            new TableRow(
                                new TableCell(new Panel(), true),
                                new TableCell(new Panel(), true),
                                new TableCell(btnSubmit)
                                ),
                            new TableRow {
                                ScaleHeight = true
                            }
                        }
                    }
                }
            };
        }
示例#14
0
文件: Titan.cs 项目: GAMEBOOK/Titan
        public static int Main(string[] args)
        {
            Thread.CurrentThread.Name = "Main";

            Instance = new Titan
            {
                Options = new Options()
            };

            Logger = LogCreator.Create();

            Logger.Debug("Startup: Loading Serilog <-> Common Logging Bridge.");

            // Common Logging <-> Serilog bridge
            Log.Logger = LogCreator.Create("Quartz.NET Scheduler");

            Logger.Debug("Startup: Loading Quartz.NET.");

            // Quartz.NET
            Instance.Scheduler = StdSchedulerFactory.GetDefaultScheduler();
            Instance.Scheduler.Start();

            Logger.Debug("Startup: Refreshing Steam Universe list.");

            SteamDirectory.Initialize().Wait();

            Logger.Debug("Startup: Parsing Command Line Arguments.");

            if (Parser.Default.ParseArguments(args, Instance.Options))
            {
                Logger.Information("Skipping UI and going directly to botting - Target: {Target} - Match ID: {ID}",
                                   Instance.Options.Target, Instance.Options.MatchID);
                Instance.EnableUI = false;
            }
            else
            {
                Logger.Information("The arguments --target and --mode were omitted - opening the UI.");
                Instance.EnableUI = true;
            }

            // Reinitialize logger with new parsed debug option
            Logger = LogCreator.Create();

            if (Instance.Options.Debug)
            {
                if (!Instance.DebugDirectory.Exists)
                {
                    Instance.DebugDirectory.Create();
                }
            }

            Logger.Debug("Startup: Loading UI Manager, Victim Tracker, Account Manager and Ban Manager.");

            try
            {
                Instance.UIManager = new UIManager();
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(InvalidOperationException))
                {
                    var osEx = (InvalidOperationException)ex;

                    if (osEx.Message.ToLower().Contains("could not detect platform"))
                    {
                        Log.Error("---------------------------------------");
                        Log.Error("A fatal error has been detected!");
                        Log.Error("You are missing a Eto.Forms platform assembly.");
                        if (Type.GetType("Mono.Runtime") != null)
                        {
                            Log.Error("Please read the README.md file and install all required dependencies.");
                        }
                        Log.Error("Either {0} or {1} Titan. Titan will now shutdown.", "redownload", "rebuild");
                        Log.Error("Contact {Marc} on Discord for more information.", "Marc3842h#7312");
                        Log.Error("---------------------------------------");

                        Environment.Exit(-1);
                    }
                }

                Log.Error(ex, "A error occured while loading UI.");
                throw;
            }

            Instance.VictimTracker = new VictimTracker();

            Instance.Scheduler.ScheduleJob(Instance.VictimTracker.Job, Instance.VictimTracker.Trigger);

            Instance.AccountManager = new AccountManager(new FileInfo(
                                                             Path.Combine(Environment.CurrentDirectory, Instance.Options.File))
                                                         );

            Instance.ThreadManager = new ThreadManager();

            Instance.BanManager = new BanManager();

            Logger.Debug("Startup: Registering Shutdown Hook.");

            AppDomain.CurrentDomain.ProcessExit += OnShutdown;

            Logger.Debug("Startup: Parsing accounts.json file.");

            if (Instance.AccountManager.ParseAccountFile())
            {
                Logger.Debug("Initializing Forms...");

                Instance.UIManager.InitializeForms();


                Logger.Debug("Startup: Loading Web API Key");

                // Resolve API Key File
                Instance.APIKeyResolver = new WebAPIKeyResolver();
                Instance.APIKeyResolver.ParseKeyFile();

                Logger.Information("Hello and welcome to Titan v1.5.0-Dev.");

                if (Instance.EnableUI)
                {
                    Instance.UIManager.ShowForm(UIType.General);
                }
                else
                {
                    switch (Regex.Replace(Instance.Options.Mode.ToLowerInvariant(), @"\s+", ""))
                    {
                    case "report":
                        Instance.AccountManager.StartReporting(Instance.AccountManager.Index,
                                                               new ReportInfo
                        {
                            SteamID = SteamUtil.Parse(Instance.Options.Target),
                            MatchID = SharecodeUtil.Parse(Instance.Options.MatchID),

                            AbusiveText  = Instance.Options.AbusiveTextChat,
                            AbusiveVoice = Instance.Options.AbusiveVoiceChat,
                            Griefing     = Instance.Options.Griefing,
                            AimHacking   = Instance.Options.AimHacking,
                            WallHacking  = Instance.Options.WallHacking,
                            OtherHacking = Instance.Options.OtherHacking
                        });
                        break;

                    case "commend":
                        Instance.AccountManager.StartCommending(Instance.AccountManager.Index,
                                                                new CommendInfo
                        {
                            SteamID = SteamUtil.Parse(Instance.Options.Target),

                            Friendly = Instance.Options.Friendly,
                            Leader   = Instance.Options.Leader,
                            Teacher  = Instance.Options.Teacher
                        });
                        break;

                    default:
                        Logger.Error("Could not parse {Mode} to Mode.", Instance.Options.Mode);

                        Instance.UIManager.ShowForm(UIType.General);
                        break;
                    }
                }

                Instance.UIManager.StartMainLoop();
            }

            // The Shutdown handler gets only called after the last thread finished.
            // Quartz runs a Watchdog until Scheduler#Shutdown is called, so we're calling it
            // before Titan will be calling the Shutdown Hook.
            Logger.Debug("Shutdown: Shutting down Quartz.NET Scheduler.");

            Instance.Scheduler.Shutdown();

            return(0); // OK.
        }
示例#15
0
文件: Titan.cs 项目: jud3/Titan
        public static int Main(string[] args)
        {
            Thread.CurrentThread.Name = "Main";

            Instance = new Titan
            {
                Options = new Options()
            };

            Logger = LogCreator.Create();

            Logger.Debug("Startup: Loading Serilog <-> Common Logging Bridge.");

            // Common Logging <-> Serilog bridge
            Log.Logger = LogCreator.Create("Quartz.NET Scheduler");

            Logger.Debug("Startup: Loading Quartz.NET.");

            // Quartz.NET
            Instance.Scheduler = StdSchedulerFactory.GetDefaultScheduler().Result;
            Instance.Scheduler.Start();

            Logger.Debug("Startup: Parsing Command Line Arguments.");

            Parser.Default.ParseArguments <Options, ReportOptions, CommendOptions, IdleOptions>(args)
            .WithParsed <ReportOptions>(options =>
            {
                Instance.EnableUI     = false;
                Instance.ParsedObject = options;
            })
            .WithParsed <CommendOptions>(options =>
            {
                Instance.EnableUI     = false;
                Instance.ParsedObject = options;
            })
            .WithParsed <IdleOptions>(options =>
            {
                Instance.EnableUI     = false;
                Instance.ParsedObject = options;
            })
            .WithNotParsed(error =>
            {
                Instance.EnableUI = true;
                Logger.Information("No valid verb has been provided while parsing. Opening UI...");
            });

            // Reinitialize logger with new parsed debug option
            Logger = LogCreator.Create();

            if (Instance.Options.Debug)
            {
                if (!Instance.DebugDirectory.Exists)
                {
                    Instance.DebugDirectory.Create();
                }
            }

            if (Instance.Options.DisableBlacklist)
            {
                Logger.Debug("Blacklist has been disabled by passing the --noblacklist option.");
            }

            Logger.Debug("Startup: Loading UI Manager, Victim Tracker, Account Manager and Ban Manager.");

            try
            {
                Instance.UIManager = new UIManager();
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(InvalidOperationException))
                {
                    var osEx = (InvalidOperationException)ex;

                    if (osEx.Message.ToLower().Contains("could not detect platform"))
                    {
                        Log.Error("---------------------------------------");
                        Log.Error("A fatal error has been detected!");
                        Log.Error("You are missing a Eto.Forms platform assembly.");
                        if (Type.GetType("Mono.Runtime") != null)
                        {
                            Log.Error("Please read the README.md file and install all required dependencies.");
                        }
                        Log.Error("Either {0} or {1} Titan. Titan will now shutdown.", "redownload", "rebuild");
                        Log.Error("Contact {Marc} on Discord for more information.", "Marc3842h#7312");
                        Log.Error("---------------------------------------");

                        Environment.Exit(-1);
                    }
                }

                Log.Error(ex, "A error occured while loading UI.");
                throw;
            }

            Instance.VictimTracker = new VictimTracker();

            Instance.Scheduler.ScheduleJob(Instance.VictimTracker.Job, Instance.VictimTracker.Trigger);

            Instance.AccountManager = new AccountManager(new FileInfo(
                                                             Path.Combine(Environment.CurrentDirectory, Instance.Options.AccountsFile))
                                                         );

            Instance.ThreadManager = new ThreadManager();

            Instance.BanManager = new BanManager();

            Logger.Debug("Startup: Registering Shutdown Hook.");

            AppDomain.CurrentDomain.ProcessExit += OnShutdown;

            Logger.Debug("Startup: Parsing accounts.json file.");

            if (Instance.AccountManager.ParseAccountFile())
            {
                Logger.Debug("Initializing Forms...");

                Instance.UIManager.InitializeForms();


                Logger.Debug("Startup: Loading Web API Key");

                // Resolve API Key File
                Instance.APIKeyResolver = new WebAPIKeyResolver();
                Instance.APIKeyResolver.ParseKeyFile();

                Logger.Information("Hello and welcome to Titan v1.5.0-Dev.");

                if (Instance.EnableUI || Instance.ParsedObject == null)
                {
                    Instance.UIManager.ShowForm(UIType.General);
                }
                else
                {
                    if (Instance.ParsedObject.GetType() == typeof(ReportOptions))
                    {
                        var opt = (ReportOptions)Instance.ParsedObject;

                        var steamID = SteamUtil.Parse(opt.Target);
                        if (Blacklist.IsBlacklisted(steamID))
                        {
                            Instance.UIManager.SendNotification(
                                "Restriction applied",
                                "The target you are trying to report is blacklisted from botting " +
                                "in Titan.",
                                delegate { Process.Start("https://github.com/Marc3842h/Titan/wiki/Blacklist"); }
                                );
                        }
                        else
                        {
                            Instance.AccountManager.StartReporting(Instance.AccountManager.Index,
                                                                   new ReportInfo
                            {
                                SteamID = SteamUtil.Parse(opt.Target),
                                MatchID = SharecodeUtil.Parse(opt.Match),

                                AbusiveText  = opt.AbusiveTextChat,
                                AbusiveVoice = opt.AbusiveVoiceChat,
                                Griefing     = opt.Griefing,
                                AimHacking   = opt.AimHacking,
                                WallHacking  = opt.WallHacking,
                                OtherHacking = opt.OtherHacking
                            });
                        }
                    }
                    else if (Instance.ParsedObject.GetType() == typeof(CommendOptions))
                    {
                        var opt = (CommendOptions)Instance.ParsedObject;

                        Instance.AccountManager.StartCommending(Instance.AccountManager.Index,
                                                                new CommendInfo
                        {
                            SteamID = SteamUtil.Parse(opt.Target),

                            Friendly = opt.Friendly,
                            Leader   = opt.Leader,
                            Teacher  = opt.Teacher
                        });
                    }
                    else if (Instance.ParsedObject.GetType() == typeof(IdleOptions))
                    {
                        var opt = (IdleOptions)Instance.ParsedObject;

                        // TODO: Parse the idle options as soon as idling is implemented
                    }
                    else
                    {
                        Instance.UIManager.ShowForm(UIType.General);
                    }
                }

                Instance.UIManager.StartMainLoop();
            }

            // The Shutdown handler gets only called after the last thread finished.
            // Quartz runs a Watchdog until Scheduler#Shutdown is called, so we're calling it
            // before Titan will be calling the Shutdown Hook.
            Logger.Debug("Shutdown: Shutting down Quartz.NET Scheduler.");

            Instance.Scheduler.Shutdown();

            return(0); // OK.
        }
示例#16
0
文件: Titan.cs 项目: BoberMod/Titan
        public static int Main(string[] args)
        {
            Thread.CurrentThread.Name = "Main";

            Logger.Debug("Startup: Loading Titan Bootstrapper.");

            // Initialize Titan Singleton
            Instance = new Titan
            {
                Options = new Options()
            };

            Logger.Debug("Startup: Loading Serilog <-> Common Logging Bridge.");

            // Common Logging <-> Serilog bridge
            Log.Logger = LogCreator.Create("Quartz.NET Scheduler");

            Logger.Debug("Startup: Loading Quartz.NET.");

            // Quartz.NET
            Instance.Scheduler = StdSchedulerFactory.GetDefaultScheduler();
            Instance.Scheduler.Start();

            // SteamKit
            Logger.Debug("Startup: Refreshing Steam Universe list.");

            SteamDirectory.Initialize().Wait();

            Logger.Debug("Startup: Parsing Command Line Arguments.");

            /* Parse arguments provided with the starting of this */
            if (Parser.Default.ParseArguments(args, Instance.Options))
            {
                Logger.Information("Skipping UI and going directly to botting - Target: {Target} - Match ID: {Id}", Instance.Options.Target, Instance.Options.MatchId);
                Instance.EnableUI = false;
            }
            else
            {
                Logger.Information("The arguments --target and --mode were omitted - opening the UI.");
                Instance.EnableUI = true;
            }

            Logger.Debug("Startup: Initializing Gui Manager, Victim Tracker, Account Manager and Ban Manager.");

            Instance.UIManager = new UIManager();

            Instance.VictimTracker = new VictimTracker();

            // Schedule Victim Tracking
            Instance.Scheduler.ScheduleJob(Instance.VictimTracker.Job, Instance.VictimTracker.Trigger);

            var file = string.IsNullOrEmpty(Instance.Options.File) ? "accounts.json" : Instance.Options.File;

            Instance.AccountManager = new AccountManager(new FileInfo(Path.Combine(Environment.CurrentDirectory, file)));

            Instance.ThreadManager = new ThreadManager();

            Instance.BanManager = new BanManager();
            Instance.BanManager.ParseApiKeyFile();

            Logger.Debug("Startup: Registering Shutdown Hook.");

            // Register hook
            AppDomain.CurrentDomain.ProcessExit += OnShutdown;

            Logger.Debug("Startup: Parsing accounts.json file.");

            if (Instance.AccountManager.ParseAccountFile())
            {
                Logger.Information("Hello and welcome to Titan v1.4.0-Dev.");

                if (Instance.EnableUI)
                {
                    Instance.UIManager.ShowForm(UIType.Main);
                }
                else
                {
                    var mode = BotModeParser.Parse(Instance.Options.Mode);

                    if (mode == BotMode.Report)
                    {
                        Instance.AccountManager.StartBotting(mode, SteamUtil.Parse(Instance.Options.Target),
                                                             Instance.Options.MatchId != null ? Convert.ToUInt64(Instance.Options.MatchId) : 8);
                    }
                }

                Instance.UIManager.StartMainLoop();
            }

            // The Shutdown handler gets only called after the last thread finished.
            // Quartz runs a Watchdog until Scheduler#Shutdown is called, so we're calling it
            // before Titan will be calling the Shutdown Hook.
            Logger.Debug("Shutdown: Shutting down Quartz.NET Scheduler.");

            Instance.Scheduler.Shutdown();

            return(0); // OK.
        }
示例#17
0
        public static int Main(string[] args)
        {
            Thread.CurrentThread.Name = "Main";

            Instance = new Titan
            {
                Options = new Options()
            };

            Logger = LogCreator.Create();

            #if __UNIX__
            Instance.IsAdmin = Syscall.getuid() == 0;     // UID of root is always 0
            #else
            Instance.IsAdmin = new WindowsPrincipal(WindowsIdentity.GetCurrent())
                               .IsInRole(WindowsBuiltInRole.Administrator);
            #endif

            if (Instance.IsAdmin)
            {
                Logger.Error("Titan is running as administrator or root.");
                Logger.Error("This is not supported. Titan will refuse to start until you start it as normal user.");

                #if !__UNIX__
                Console.Write("Press any key to exit Titan...");
                Console.Read();
                #endif

                return(-1);
            }

            Logger.Debug("Titan was called from: {dir}", Environment.CurrentDirectory);
            Logger.Debug("Working in directory: {dir}", Instance.Directory.ToString());

            // Workaround for Mono related issue regarding System.Net.Http.
            // More detail: https://github.com/dotnet/corefx/issues/19914

            var systemNetHttpDll = new FileInfo(Path.Combine(Instance.Directory.ToString(), "System.Net.Http.dll"));

            if (systemNetHttpDll.Exists && !PlatformUtil.IsWindows())
            {
                systemNetHttpDll.Delete();
            }

            // Windows users run the program by double clicking Titan.exe (and then it opens a console window)
            // and in case of exception occurence, this window gets immediatly closed which is bad because
            // they're unable to attach the stacktrace then. Prevent it by waiting until the user presses a key.
            AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
            {
                if (eventArgs.IsTerminating)
                {
                    #if !__UNIX__
                    Console.Write("Press any key to exit Titan...");
                    Console.Read();
                    #endif
                }
            };

            Logger.Debug("Startup: Loading Serilog <-> Common Logging Bridge.");

            // The bridge between Common Logging and Serilog uses the global Logger (Log.Logger).
            // As Quartz.NET is the only dependency using Common Logging (and because of our bridge the global logger)
            // we're creating the global logger as Quartz logger (which hides annoying debug messages).
            Log.Logger = LogCreator.CreateQuartzLogger();

            Logger.Debug("Startup: Loading Quartz.NET.");

            // Quartz.NET
            Instance.Scheduler = StdSchedulerFactory.GetDefaultScheduler().Result;
            Instance.Scheduler.Start();

            Logger.Debug("Startup: Parsing Command Line Arguments.");

            var parser = new Parser(config =>
            {
                config.IgnoreUnknownArguments = true;
                config.EnableDashDash         = true;
                config.HelpWriter             = TextWriter.Null;
            });

            // Default
            parser.ParseArguments <Options>(args)
            .WithParsed(options =>
            {
                Instance.Options = options;
            });

            // Verbs
            parser.ParseArguments <ReportOptions, CommendOptions>(args)
            .WithParsed <ReportOptions>(options =>
            {
                Instance.EnableUI     = false;
                Instance.ParsedObject = options;
            })
            .WithParsed <CommendOptions>(options =>
            {
                Instance.EnableUI     = false;
                Instance.ParsedObject = options;
            })
            .WithNotParsed(error =>
            {
                if (Instance.ParsedObject == null)
                {
                    Instance.EnableUI = true;
                    Logger.Information("No valid verb has been provided while parsing. Opening UI...");
                }
            });

            // Reinitialize logger with new parsed debug option
            Logger = LogCreator.Create();

            if (Instance.Options.Debug)
            {
                Instance.DebugDirectory = new DirectoryInfo(Path.Combine(Instance.Directory.ToString(), "debug"));

                if (!Instance.DebugDirectory.Exists)
                {
                    Instance.DebugDirectory.Create();
                }

                DebugLog.AddListener(new TitanListener());
                DebugLog.Enabled = true;
            }

            if (Instance.Options.Secure)
            {
                Logger.Debug("Secure mode has been enabled. Titan will output no sensitive data.");
            }

            if (Instance.Options.DisableBlacklist)
            {
                Logger.Debug("Blacklist has been disabled by passing the --noblacklist option.");
            }

            Logger.Debug("Startup: Loading UI Manager, Victim Tracker, Account Manager and Ban Manager.");

            Instance.JsonSerializer = new JsonSerializer();

            try
            {
                Instance.UIManager = new UIManager();
            }
            catch (InvalidOperationException ex)
            {
                if (!string.IsNullOrEmpty(ex.Message) && ex.Message.ToLower().Contains("could not detect platform"))
                {
                    Logger.Error("---------------------------------------");
                    Logger.Error("A fatal error has been detected!");
                    Logger.Error("Eto.Forms could not detect your current operating system.");
                    if (Type.GetType("Mono.Runtime") != null)
                    {
                        Logger.Error("Please install {0}, {1}, {2}, {3} and {4} before submitting a bug report.",
                                     "Mono (\u22655.4)",
                                     "Gtk 3",
                                     "Gtk# 3 (GTK Sharp)",
                                     "libNotify",
                                     "libAppindicator3");
                    }
                    else
                    {
                        Logger.Error("Please install {0} before submitting a bug report.",
                                     ".NET Framework (\u22654.6.1)");
                    }
                    Logger.Error("Contact {Marc} on Discord if the issue still persists after installing " +
                                 "the dependencies listed above.", "Marc3842h#7312");
                    Logger.Error("---------------------------------------");
                    Logger.Debug(ex, "Include the error below if you\'re contacting Marc on Discord.");

                    #if !__UNIX__
                    Console.Write("Press any key to exit Titan...");
                    Console.Read();
                    #endif

                    Instance.Scheduler.Shutdown();
                    return(-1);
                }

                Logger.Error(ex, "A error occured while loading UI.");
                throw;
            }

            Instance.VictimTracker = new VictimTracker();

            Instance.Scheduler.ScheduleJob(Instance.VictimTracker.Job, Instance.VictimTracker.Trigger);

            Instance.AccountManager = new AccountManager(new FileInfo(
                                                             Path.Combine(Instance.Directory.ToString(), Instance.Options.AccountsFile))
                                                         );

            Instance.ThreadManager = new ThreadManager();

            Instance.WebHandle = new SWAHandle();

            Logger.Debug("Startup: Registering Shutdown Hook.");

            AppDomain.CurrentDomain.ProcessExit += OnShutdown;

            Logger.Debug("Startup: Parsing accounts.json file.");

            Instance.AccountManager.ParseAccountFile();

            Logger.Debug("Startup: Initializing Forms...");

            Instance.UIManager.InitializeForms();

            // Load after Forms were initialized
            Instance.WebHandle.Load();

            Logger.Information("Hello and welcome to Titan v1.6.0-EAP.");

            if (Instance.EnableUI && Instance.ParsedObject == null || Instance.DummyMode)
            {
                Instance.UIManager.ShowForm(UIType.General);
            }
            else
            {
                if (Instance.ParsedObject.GetType() == typeof(ReportOptions))
                {
                    var opt = (ReportOptions)Instance.ParsedObject;

                    var steamID = SteamUtil.Parse(opt.Target);
                    if (Blacklist.IsBlacklisted(steamID))
                    {
                        Instance.UIManager.SendNotification(
                            "Restriction applied",
                            "The target you are trying to report is blacklisted from botting " +
                            "in Titan.",
                            delegate { Process.Start("https://github.com/Marc3842h/Titan/wiki/Blacklist"); }
                            );
                    }
                    else
                    {
                        Instance.AccountManager.StartReporting(Instance.AccountManager.Index,
                                                               new ReportInfo
                        {
                            SteamID = SteamUtil.Parse(opt.Target),
                            MatchID = SharecodeUtil.Parse(opt.Match),
                            AppID   = TitanAccount.CSGO_APPID,

                            AbusiveText  = opt.AbusiveTextChat,
                            AbusiveVoice = opt.AbusiveVoiceChat,
                            Griefing     = opt.Griefing,
                            AimHacking   = opt.AimHacking,
                            WallHacking  = opt.WallHacking,
                            OtherHacking = opt.OtherHacking
                        });
                    }
                }
                else if (Instance.ParsedObject.GetType() == typeof(CommendOptions))
                {
                    var opt = (CommendOptions)Instance.ParsedObject;

                    Instance.AccountManager.StartCommending(Instance.AccountManager.Index,
                                                            new CommendInfo
                    {
                        SteamID = SteamUtil.Parse(opt.Target),
                        AppID   = TitanAccount.CSGO_APPID,

                        Friendly = opt.Friendly,
                        Leader   = opt.Leader,
                        Teacher  = opt.Teacher
                    });
                }
                else
                {
                    Instance.UIManager.ShowForm(UIType.General);
                }
            }

            Instance.UIManager.StartMainLoop();

            // The Shutdown handler gets only called after the last thread finished.
            // Quartz runs a Watchdog until Scheduler#Shutdown is called, so we're calling it
            // before Titan will be calling the Shutdown Hook.
            Logger.Debug("Shutdown: Shutting down Quartz.NET Scheduler.");

            Instance.Scheduler.Shutdown();

            return(0); // OK.
        }