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>(); // 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() ); } _log.Debug("Successfully initialized account object for {0}.", json.Username); }
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)); //builder.WithWebAPIKey(Titan.Instance.WebHandle.GetKey()); Is null at time of this creation - needs fix }); _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() ); } _log.Debug("Successfully initialized account object for {Username}.", json.Username); }
public override List <TitanAccount> ParseAccounts() { var result = new List <TitanAccount>(); if (!System.IO.File.Exists(File)) { return(result); } var lines = System.IO.File.ReadLines(File); foreach (var line in lines) { string[] parts = line.Split(':'); if (parts.Length < 2) { continue; } var jsonAccount = new JsonAccounts.JsonAccount { Username = Regex.Replace(parts[0].Trim(), @"\t|\n|\r", ""), Password = Regex.Replace(parts[1].Trim(), @"\t|\n|\r", ""), Sentry = false, // Generic username:password lists don't have SteamGuard enabled in most cases. Enabled = true, SharedSecret = null }; result.Add(new UnprotectedAccount(jsonAccount)); } return(result); }
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)); 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."); } }); _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 + "."); }
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); }
public ProtectedAccount(JsonAccounts.JsonAccount json) : base(json) { _log = LogCreator.Create("GC - " + json.Username + (!Titan.Instance.Options.Secure ? " (Protected)" : "")); _steamConfig = new SteamConfiguration { ConnectionTimeout = TimeSpan.FromMinutes(3), WebAPIKey = Titan.Instance.WebHandle.GetKey() // May be null at this time, but we can accept that for now }; _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 + "."); }
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); }
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 + "."); }
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 + "."); }
internal TitanAccount(JsonAccounts.JsonAccount json) { JsonAccount = json; }
private TabPage GetAccountsTabPage() { var grid = new GridView { AllowMultipleSelection = false }; RefreshList(ref grid); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Enabled") { TextAlignment = TextAlignment.Center }, HeaderText = "Enabled" }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Index") { TextAlignment = TextAlignment.Center }, HeaderText = "Index" }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Username"), HeaderText = "Username" }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Password"), HeaderText = "Password" }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Sentry") { TextAlignment = TextAlignment.Center }, HeaderText = "Steam Guard" }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Secret"), HeaderText = "Shared Secret" }); var txtBoxUsername = new TextBox { PlaceholderText = "Username" }; var txtBoxPassword = new TextBox { PlaceholderText = "Password" }; var cbSentry = new CheckBox { Text = "Steam Guard", Checked = false }; var btnAddUpdate = new Button { Text = "Add / Update" }; btnAddUpdate.Click += delegate { if (!string.IsNullOrWhiteSpace(txtBoxUsername.Text) && !string.IsNullOrWhiteSpace(txtBoxPassword.Text)) { if (Titan.Instance.AccountManager.TryGetAccount(txtBoxUsername.Text.Trim(), out var account)) { account.JsonAccount.Username = txtBoxUsername.Text.Trim(); account.JsonAccount.Password = txtBoxPassword.Text.Trim(); account.JsonAccount.Sentry = cbSentry.Checked != null && (bool)cbSentry.Checked; _uiManager.SendNotification("Titan", "Successfully updated account " + account.JsonAccount.Username); } else { var jsonAccount = new JsonAccounts.JsonAccount { Username = txtBoxUsername.Text.Trim(), Password = txtBoxPassword.Text.Trim(), Sentry = cbSentry.Checked != null && (bool)cbSentry.Checked, Enabled = true, SharedSecret = null }; TitanAccount acc; if (jsonAccount.Sentry) { acc = new ProtectedAccount(jsonAccount); } else { acc = new UnprotectedAccount(jsonAccount); } Titan.Instance.AccountManager.AddAccount(acc); _uiManager.SendNotification("Titan", "Successfully added account " + acc.JsonAccount.Username); var tabControl = (TabControl)Content; foreach (var page in tabControl.Pages) { page.Enabled = true; } if (Titan.Instance.DummyMode) { _log.Information("There are now accounts specified. Turning dummy mode {off}.", "off"); Titan.Instance.DummyMode = false; } } RefreshList(ref grid); } else { _uiManager.SendNotification("Titan - Error", "Please input a username and password."); } }; var btnRemove = new Button { Text = "Remove" }; btnRemove.Click += delegate { dynamic selected = grid.SelectedItem; if (selected != null) { _log.Information("{Type}: {@Info}", selected.GetType(), selected); var username = selected.Username; if (username != null) { if (Titan.Instance.AccountManager.TryGetAccount(username, out TitanAccount account)) { Titan.Instance.AccountManager.RemoveAccount(account); RefreshList(ref grid); } else { _uiManager.SendNotification("Titan - Error", "The account doesn't exist."); } } else { _uiManager.SendNotification("Titan", "The account could not be found."); } } else { _uiManager.SendNotification("Titan - Error", "Please select a account before removing it."); } if (Titan.Instance.AccountManager.Count() < 1) { var tabControl = (TabControl)Content; foreach (var page in tabControl.Pages) { if (!page.Text.Equals("Accounts")) { page.Enabled = false; } } if (!Titan.Instance.DummyMode) { _log.Warning("There are no longer accounts specified. Turning dummy mode back {on}.", "on"); Titan.Instance.DummyMode = true; } } }; return(new TabPage { Text = "Accounts", Content = new TableLayout { Spacing = new Size(5, 5), Padding = new Padding(10, 10, 10, 10), Rows = { new TableRow(new TableCell(grid, true)) { ScaleHeight = true }, new GroupBox { Text = "Edit", Content = new TableLayout { Spacing = new Size(5, 5), Padding = new Padding(10, 10, 10, 10), Rows = { new TableRow( new TableCell(txtBoxUsername, true), new TableCell(txtBoxPassword, true), new TableCell(cbSentry) ) } } }, 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(btnRemove), new TableCell(btnAddUpdate) ) } } } } }); }
public override TabPage GetTabPage() { var grid = new GridView { AllowMultipleSelection = false }; RefreshList(ref grid); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Enabled") { TextAlignment = TextAlignment.Center }, HeaderText = "Enabled" }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Index") { TextAlignment = TextAlignment.Center }, HeaderText = "Index" }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Username"), HeaderText = "Username" }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Password"), HeaderText = "Password", Visible = !Titan.Instance.Options.Secure }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Sentry") { TextAlignment = TextAlignment.Center }, HeaderText = "Steam Guard", Visible = !Titan.Instance.Options.Secure }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Secret"), HeaderText = "Shared Secret", Visible = !Titan.Instance.Options.Secure }); grid.Columns.Add(new GridColumn { DataCell = new TextBoxCell("Cooldown"), HeaderText = "Cooldown" }); var txtBoxUsername = new TextBox { PlaceholderText = "Username" }; TextControl txtBoxPassword; if (Titan.Instance.Options.Secure) { txtBoxPassword = new PasswordBox { PasswordChar = '\u2022' }; } else { txtBoxPassword = new TextBox { PlaceholderText = "Password" }; } var cbSentry = new CheckBox { Text = "Steam Guard", Checked = false }; var btnAddUpdate = new Button { Text = "Add / Update" }; btnAddUpdate.Click += (sender, args) => { if (!string.IsNullOrWhiteSpace(txtBoxUsername.Text) && !string.IsNullOrWhiteSpace(txtBoxPassword.Text)) { if (Titan.Instance.AccountManager.TryGetAccount(txtBoxUsername.Text.Trim(), out var account)) { if (account.JsonAccount.Sentry != (cbSentry.Checked != null && (bool)cbSentry.Checked)) { var clone = account.JsonAccount.Clone(); Titan.Instance.AccountManager.RemoveAccount(account); if (cbSentry.Checked != null && (bool)cbSentry.Checked) { account = new ProtectedAccount(clone); } else { account = new UnprotectedAccount(clone); } Titan.Instance.AccountManager.AddAccount(account); } account.JsonAccount.Username = txtBoxUsername.Text.Trim(); account.JsonAccount.Password = txtBoxPassword.Text.Trim(); account.JsonAccount.Sentry = cbSentry.Checked != null && (bool)cbSentry.Checked; UIManager.SendNotification("Titan", "Successfully updated account " + account.JsonAccount.Username); } else { var jsonAccount = new JsonAccounts.JsonAccount { Username = txtBoxUsername.Text.Trim(), Password = txtBoxPassword.Text.Trim(), Sentry = cbSentry.Checked != null && (bool)cbSentry.Checked, Enabled = true, SharedSecret = null }; TitanAccount acc; if (jsonAccount.Sentry) { acc = new ProtectedAccount(jsonAccount); } else { acc = new UnprotectedAccount(jsonAccount); } Titan.Instance.AccountManager.AddAccount(acc); UIManager.SendNotification("Titan", "Successfully added account " + acc.JsonAccount.Username); var tabControl = (TabControl)_generalUI.Content; foreach (var page in tabControl.Pages) { page.Enabled = true; } if (Titan.Instance.DummyMode) { _log.Information("There are now accounts specified. Turning dummy mode {off}.", "off"); Titan.Instance.DummyMode = false; } } Titan.Instance.AccountManager.SaveAccountsFile(); RefreshList(ref grid); } else { UIManager.SendNotification("Titan - Error", "Please input a username and password."); } }; var btnRemove = new Button { Text = "Remove" }; btnRemove.Click += (sender, args) => { dynamic selected = grid.SelectedItem; if (selected != null) { var username = selected.Username; if (username != null) { if (Titan.Instance.AccountManager.TryGetAccount(username, out TitanAccount account)) { Titan.Instance.AccountManager.RemoveAccount(account); Titan.Instance.AccountManager.SaveAccountsFile(); RefreshList(ref grid); } else { UIManager.SendNotification("Titan - Error", "The account doesn't exist."); } } else { UIManager.SendNotification("Titan", "The account could not be found."); } } else { UIManager.SendNotification("Titan - Error", "Please select a account before removing it."); } if (Titan.Instance.AccountManager.Count() < 1) { var tabControl = (TabControl)_generalUI.Content; foreach (var page in tabControl.Pages) { if (!page.Text.Equals("Accounts")) { page.Enabled = false; } } if (!Titan.Instance.DummyMode) { _log.Warning("There are no longer accounts specified. Turning dummy mode back {on}.", "on"); Titan.Instance.DummyMode = true; } } }; var btnImport = new Button { Text = "Import" }; btnImport.Click += (sender, args) => { var dialog = new OpenFileDialog { Title = "Select file to import", Filters = { new FileFilter("Legacy account files", ".txt") }, MultiSelect = false }; var result = UIManager.ShowForm(UIType.FilePicker, dialog); if (result != DialogResult.Ok) { return; } if (!dialog.Filenames.Any()) { UIManager.SendNotification("Titan", "Please select a file."); return; } AccountImporter importer = new GenericAccountListImporter(dialog.Filenames.First()); var accounts = importer.ParseAccounts(); if (accounts == null || accounts.Count <= 0) { UIManager.SendNotification("Titan", "No accounts were imported."); return; } foreach (var account in accounts) { Titan.Instance.AccountManager.AddAccount(account); } UIManager.SendNotification("Titan", "Successfully imported " + accounts.Count + " accounts."); // Disable dummy mode now that accounts are here. var tabControl = (TabControl)_generalUI.Content; foreach (var page in tabControl.Pages) { page.Enabled = true; } if (Titan.Instance.DummyMode) { _log.Information("There are now accounts specified. Turning dummy mode {off}.", "off"); Titan.Instance.DummyMode = false; } RefreshList(ref grid); }; return(new TabPage { Text = "Accounts", Content = new TableLayout { Spacing = new Size(5, 5), Padding = new Padding(10, 10, 10, 10), Rows = { new TableRow(new TableCell(grid, true)) { ScaleHeight = true }, new GroupBox { Text = "Edit", Content = new TableLayout { Spacing = new Size(5, 5), Padding = new Padding(10, 10, 10, 10), Rows = { new TableRow( new TableCell(txtBoxUsername, true), new TableCell(txtBoxPassword, true), new TableCell(cbSentry) ) } } }, 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(btnImport), new TableCell(btnRemove), new TableCell(btnAddUpdate) ) } } } } }); }