static bool Encrypt(string passkey = "") { // NOTE: in this context, `passkey` refers to the old passkey, if there was one Utils.Verbose("Opening manifest..."); Manifest = Manifest.GetManifest(true); Utils.Verbose("Reading accounts from manifest..."); if (Manifest.Encrypted) { if (string.IsNullOrEmpty(passkey)) { passkey = Manifest.PromptForPassKey(); } SteamGuardAccounts = Manifest.GetAllAccounts(passkey); } else { SteamGuardAccounts = Manifest.GetAllAccounts(); } string newPassKey = Manifest.PromptSetupPassKey(); for (int i = 0; i < SteamGuardAccounts.Length; i++) { var account = SteamGuardAccounts[i]; var salt = Manifest.GetRandomSalt(); var iv = Manifest.GetInitializationVector(); bool success = Manifest.SaveAccount(account, true, newPassKey, salt, iv); Utils.Verbose("Encrypted {0}: {1}", account.AccountName, success); if (!success) { return(false); } } return(true); }
static bool Decrypt(string passkey = "") { Utils.Verbose("Opening manifest..."); Manifest = Manifest.GetManifest(true); Utils.Verbose("Reading accounts from manifest..."); if (Manifest.Encrypted) { if (string.IsNullOrEmpty(passkey)) { passkey = Manifest.PromptForPassKey(); } SteamGuardAccounts = Manifest.GetAllAccounts(passkey); } else { Utils.Verbose("Decryption not required."); return(true); } for (int i = 0; i < SteamGuardAccounts.Length; i++) { var account = SteamGuardAccounts[i]; bool success = Manifest.SaveAccount(account, false); Utils.Verbose("Decrypted {0}: {1}", account.AccountName, success); if (!success) { return(false); } } return(true); }
static void AcceptAllTrades(string user = "", string passkey = "") { Utils.Verbose("Opening manifest..."); Manifest = Manifest.GetManifest(true); Utils.Verbose("Reading accounts from manifest..."); if (Manifest.Encrypted) { if (string.IsNullOrEmpty(passkey)) { passkey = Manifest.PromptForPassKey(); } SteamGuardAccounts = Manifest.GetAllAccounts(passkey); } else { SteamGuardAccounts = Manifest.GetAllAccounts(); } if (SteamGuardAccounts.Length == 0) { Console.WriteLine("error: No accounts read."); return; } for (int i = 0; i < SteamGuardAccounts.Length; i++) { SteamGuardAccount account = SteamGuardAccounts[i]; if ((user != "" && account.AccountName.ToLower() == user.ToLower()) || user == "") { Console.WriteLine($"Accepting Confirmations on {account.AccountName}"); Utils.Verbose("Refeshing Session..."); if (account.RefreshSession()) { Utils.Verbose("Session refreshed"); Manifest.SaveAccount(account, Manifest.Encrypted); } else { Utils.Verbose("Failed to refresh session, prompting user..."); if (!promptRefreshSession(account)) { Console.WriteLine("Failed to refresh session, aborting..."); } } Utils.Verbose("Fetching Confirmations..."); var tradesTask = account.FetchConfirmationsAsync(); tradesTask.Wait(); Confirmation[] confirmations = tradesTask.Result; Utils.Verbose("Accepting Confirmations..."); account.AcceptMultipleConfirmations(confirmations); if (user != "") { break; } } } }
static void GenerateCode(string user = "", string passkey = "") { Utils.Verbose("Aligning time..."); TimeAligner.AlignTime(); Utils.Verbose("Opening manifest..."); Manifest = Manifest.GetManifest(true); Utils.Verbose("Reading accounts from manifest..."); if (Manifest.Encrypted) { if (string.IsNullOrEmpty(passkey)) { passkey = Manifest.PromptForPassKey(); } SteamGuardAccounts = Manifest.GetAllAccounts(passkey); } else { SteamGuardAccounts = Manifest.GetAllAccounts(); } if (SteamGuardAccounts.Length == 0) { Console.WriteLine("error: No accounts read."); return; } Utils.Verbose("Selecting account..."); string code = ""; for (int i = 0; i < SteamGuardAccounts.Length; i++) { SteamGuardAccount account = SteamGuardAccounts[i]; if (user != "") { if (account.AccountName.ToLower() == user.ToLower()) { Utils.Verbose("Generating code for {0}...", account.AccountName); code = account.GenerateSteamGuardCode(); break; } } else { Utils.Verbose("Generating code for {0}...", account.AccountName); code = account.GenerateSteamGuardCode(); break; } } if (code != "") { Console.WriteLine(code); } else { Console.WriteLine("error: No Steam accounts found in {0}", SteamGuardAccounts); } }
static void Trade(string user = "", string passkey = "") { if (Verbose) { Console.WriteLine("Opening manifest..."); } Manifest = Manifest.GetManifest(true); if (Verbose) { Console.WriteLine("Reading accounts from manifest..."); } if (Manifest.Encrypted) { if (string.IsNullOrEmpty(passkey)) { passkey = Manifest.PromptForPassKey(); } SteamGuardAccounts = Manifest.GetAllAccounts(passkey); } else { SteamGuardAccounts = Manifest.GetAllAccounts(); } if (SteamGuardAccounts.Length == 0) { Console.WriteLine("error: No accounts read."); return; } foreach (var account in SteamGuardAccounts) { if (user != "") { if (!string.Equals(account.AccountName, user, StringComparison.CurrentCultureIgnoreCase)) { break; } } processConfirmations(account); } }