// Form event handlers private void MainForm_Shown(object sender, EventArgs e) { this.labelVersion.Text = String.Format("v{0}", Application.ProductVersion); this.manifest = Manifest.GetManifest(); // Make sure we don't show that welcome dialog again this.manifest.FirstRun = false; this.manifest.Save(); // Tick first time manually to sync time timerSteamGuard_Tick(new object(), EventArgs.Empty); if (manifest.Encrypted) { passKey = manifest.PromptForPassKey(); if (passKey == null) { Application.Exit(); } btnManageEncryption.Text = "Manage Encryption"; } else { btnManageEncryption.Text = "Setup Encryption"; } btnManageEncryption.Enabled = manifest.Entries.Count > 0; loadSettings(); loadAccountsList(); checkForUpdates(); }
// Form event handlers private async void MainForm_Shown(object sender, EventArgs e) { this.labelVersion.Text = String.Format("v{0}", Application.ProductVersion); this.manifest = Manifest.GetManifest(); // Make sure we don't show that welcome dialog again this.manifest.FirstRun = false; this.manifest.Save(); // Tick first time manually to sync time timerSteamGuard_Tick(new object(), EventArgs.Empty); if (manifest.Encrypted) { string passKey = manifest.PromptForPassKey(); btnManageEncryption.Text = "Manage Encryption"; } else { btnManageEncryption.Text = "Setup Encryption"; } btnManageEncryption.Enabled = manifest.Entries.Count > 0; loadSettings(); loadAccountsList(); await UpdateCurrentSession(); // Check for updates here, after a few seconds await Task.Delay(5000); await Squirrel_UpdateAppAsync(false); }
public SettingsForm() { InitializeComponent(); // Get latest manifest manifest = Manifest.GetManifest(true); chkPeriodicChecking.Checked = manifest.PeriodicChecking; numPeriodicInterval.Value = manifest.PeriodicCheckingInterval; }
public MainForm() { InitializeComponent(); this.mManifest = Manifest.GetManifest(); loadAccountsList(); pbTimeout.Maximum = 30; pbTimeout.Minimum = 0; pbTimeout.Value = 30; }
private void btnImportConfig_Click(object sender, EventArgs e) { // Let the user select the config dir FolderBrowserDialog folderBrowser = new FolderBrowserDialog(); folderBrowser.Description = "Select the folder of your old Steam Desktop Authenticator install"; DialogResult userClickedOK = folderBrowser.ShowDialog(); if (userClickedOK == DialogResult.OK) { string path = folderBrowser.SelectedPath; string pathToCopy = null; if (Directory.Exists(path + "/maFiles")) { // User selected the root install dir pathToCopy = path + "/maFiles"; } else if(File.Exists(path + "/manifest.json")) { // User selected the maFiles dir pathToCopy = path; } else { // Could not find either. MessageBox.Show("This folder does not contain either a manifest.json or an maFiles folder.\nPlease select the location where you had Steam Desktop Authenticator installed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Copy the contents of the config dir to the new config dir string currentPath = Manifest.GetExecutableDir(); // Create config dir if we don't have it if (!Directory.Exists(currentPath + "/maFiles")) { Directory.CreateDirectory(currentPath + "/maFiles"); } // Copy all files from the old dir to the new one foreach (string newPath in Directory.GetFiles(pathToCopy, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(pathToCopy, currentPath + "/maFiles"), true); } // Set first run in manifest man = Manifest.GetManifest(true); man.FirstRun = false; man.Save(); // All done! MessageBox.Show("All accounts and settings have been imported! Press OK to continue.", "Import accounts", MessageBoxButtons.OK, MessageBoxIcon.Information); showMainForm(); } }
public MainForm() { InitializeComponent(); this.labelVersion.Text = String.Format("v{0}", Application.ProductVersion); this.mManifest = Manifest.GetManifest(); loadAccountsList(); pbTimeout.Maximum = 30; pbTimeout.Minimum = 0; pbTimeout.Value = 30; checkForUpdates(); }
public static Manifest GetManifest(bool forceLoad = false) { // Check if already staticly loaded if (_manifest != null && !forceLoad) { return _manifest; } // Find config dir and manifest file string maDir = Manifest.GetExecutableDir() + "/maFiles/"; string maFile = maDir + "manifest.json"; // If there's no config dir, create it if (!Directory.Exists(maDir)) { _manifest = _generateNewManifest(); return _manifest; } // If there's no manifest, create it if (!File.Exists(maFile)) { _manifest = _generateNewManifest(true); return _manifest; } try { string manifestContents = File.ReadAllText(maFile); _manifest = JsonConvert.DeserializeObject<Manifest>(manifestContents); if (_manifest.Encrypted && _manifest.Entries.Count == 0) { _manifest.Encrypted = false; _manifest.Save(); } _manifest.RecomputeExistingEntries(); return _manifest; } catch (Exception) { return null; } }
public SettingsForm() { InitializeComponent(); // Get latest manifest manifest = Manifest.GetManifest(true); chkPeriodicChecking.Checked = manifest.PeriodicChecking; numPeriodicInterval.Value = manifest.PeriodicCheckingInterval; chkCheckAll.Checked = manifest.CheckAllAccounts; chkConfirmMarket.Checked = manifest.AutoConfirmMarketTransactions; chkConfirmTrades.Checked = manifest.AutoConfirmTrades; SetControlsEnabledState(chkPeriodicChecking.Checked); fullyLoaded = true; }
public static Manifest GetManifest() { if (_manifest != null) return _manifest; string maDir = Manifest.GetExecutableDir() + "/maFiles/"; string maFile = maDir + "manifest.json"; if (!Directory.Exists(maDir)) { _manifest = _generateNewManifest(); return _manifest; } if (!File.Exists(maFile)) { _manifest = _generateNewManifest(true); return _manifest; } try { string manifestContents = File.ReadAllText(maFile); _manifest = JsonConvert.DeserializeObject<Manifest>(manifestContents); if (_manifest.Encrypted && _manifest.Entries.Count == 0) { _manifest.Encrypted = false; _manifest.Save(); } _manifest.RecomputeExistingEntries(); return _manifest; } catch (Exception e) { return null; } }
public WelcomeForm() { InitializeComponent(); man = Manifest.GetManifest(); }
private void menuSettings_Click(object sender, EventArgs e) { new SettingsForm().ShowDialog(); manifest = Manifest.GetManifest(true); loadSettings(); }
public ImportAccountForm() { InitializeComponent(); this.mManifest = Manifest.GetManifest(); }
private static Manifest _generateNewManifest(bool scanDir = false) { //No directory means no manifest file anyways. Manifest newManifest = new Manifest(); newManifest.Encrypted = false; newManifest.Entries = new List<ManifestEntry>(); //Take a pre-manifest version and generate a manifest for it. if (scanDir) { string maDir = Manifest.GetExecutableDir() + "/maFiles/"; if (Directory.Exists(maDir)) { DirectoryInfo dir = new DirectoryInfo(maDir); var files = dir.GetFiles(); foreach (var file in files) { if (file.Extension != ".maFile") continue; string contents = File.ReadAllText(file.FullName); try { SteamGuardAccount account = JsonConvert.DeserializeObject<SteamGuardAccount>(contents); ManifestEntry newEntry = new ManifestEntry() { Filename = file.Name, SteamID = account.Session.SteamID }; newManifest.Entries.Add(newEntry); } catch (Exception e) { } } if (newManifest.Entries.Count > 0) { newManifest.Save(); newManifest.PromptSetupPassKey("This version of SDA has encryption. Please enter a passkey below, or hit cancel to remain unencrypted"); } } } if (newManifest.Save()) return newManifest; return null; }
private static Manifest _generateNewManifest(bool scanDir = false) { // No directory means no manifest file anyways. Manifest newManifest = new Manifest(); newManifest.Encrypted = false; newManifest.PeriodicCheckingInterval = 5; newManifest.PeriodicChecking = false; newManifest.AutoConfirmMarketTransactions = false; newManifest.AutoConfirmTrades = false; newManifest.AutoFillAuthCode = false; newManifest.Entries = new List <ManifestEntry>(); newManifest.FirstRun = true; // Take a pre-manifest version and generate a manifest for it. if (scanDir) { string maDir = Manifest.GetExecutableDir() + "/maFiles/"; if (Directory.Exists(maDir)) { DirectoryInfo dir = new DirectoryInfo(maDir); var files = dir.GetFiles(); foreach (var file in files) { if (file.Extension != ".maFile") { continue; } string contents = File.ReadAllText(file.FullName); try { SteamGuardAccount account = JsonConvert.DeserializeObject <SteamGuardAccount>(contents); ManifestEntry newEntry = new ManifestEntry() { Filename = file.Name, SteamID = account.Session.SteamID }; newManifest.Entries.Add(newEntry); } catch (Exception) { } } if (newManifest.Entries.Count > 0) { newManifest.Save(); newManifest.PromptSetupPassKey("This version of SDA has encryption. Please enter a passkey below, or hit cancel to remain unencrypted"); } } } if (newManifest.Save()) { return(newManifest); } return(null); }
private void HandleManifest(Manifest man, bool IsRefreshing = false) { string passKey = null; if (man.Entries.Count == 0) { passKey = man.PromptSetupPassKey("Please enter an encryption passkey. Leave blank or hit cancel to not encrypt (VERY INSECURE)."); } else if (man.Entries.Count > 0 && man.Encrypted) { bool passKeyValid = false; while (!passKeyValid) { InputForm passKeyForm = new InputForm("Please enter your current encryption passkey."); passKeyForm.ShowDialog(); if (!passKeyForm.Canceled) { passKey = passKeyForm.txtBox.Text; passKeyValid = man.VerifyPasskey(passKey); if (!passKeyValid) { MessageBox.Show("That passkey is invalid. Please enter the same passkey you used for your other accounts."); } } else { this.Close(); return; } } } man.SaveAccount(androidAccount, passKey != null, passKey); if (IsRefreshing) { MessageBox.Show("Your login session was refreshed."); } else { MessageBox.Show("Mobile authenticator successfully linked. Please write down your revocation code: " + androidAccount.RevocationCode); } this.Close(); }
public bool SaveAccount(SteamGuardAccount account, bool encrypt, string passKey = null) { if (encrypt && String.IsNullOrEmpty(passKey)) { return(false); } if (!encrypt && this.Encrypted) { return(false); } string salt = null; string iV = null; string jsonAccount = JsonConvert.SerializeObject(account); if (encrypt) { salt = FileEncryptor.GetRandomSalt(); iV = FileEncryptor.GetInitializationVector(); string encrypted = FileEncryptor.EncryptData(passKey, salt, iV, jsonAccount); if (encrypted == null) { return(false); } jsonAccount = encrypted; } string maDir = Manifest.GetExecutableDir() + "/maFiles/"; string filename = account.Session.SteamID.ToString() + ".maFile"; ManifestEntry newEntry = new ManifestEntry() { SteamID = account.Session.SteamID, IV = iV, Salt = salt, Filename = filename }; bool foundExistingEntry = false; for (int i = 0; i < this.Entries.Count; i++) { if (this.Entries[i].SteamID == account.Session.SteamID) { this.Entries[i] = newEntry; foundExistingEntry = true; break; } } if (!foundExistingEntry) { this.Entries.Add(newEntry); } bool wasEncrypted = this.Encrypted; this.Encrypted = encrypt || this.Encrypted; if (!this.Save()) { this.Encrypted = wasEncrypted; return(false); } try { File.WriteAllText(maDir + filename, jsonAccount); return(true); } catch (Exception) { return(false); } }
private void btnImportConfig_Click(object sender, EventArgs e) { // Let the user select the config dir FolderBrowserDialog folderBrowser = new FolderBrowserDialog(); folderBrowser.Description = "Select the folder of your old Steam Desktop Authenticator install"; DialogResult userClickedOK = folderBrowser.ShowDialog(); if (userClickedOK == DialogResult.OK) { string path = folderBrowser.SelectedPath; string pathToCopy = null; if (Directory.Exists(path + "/maFiles")) { // User selected the root install dir pathToCopy = path + "/maFiles"; } else if (File.Exists(path + "/manifest.json")) { // User selected the maFiles dir pathToCopy = path; } else { // Could not find either. MessageBox.Show("This folder does not contain either a manifest.json or an maFiles folder.\nPlease select the location where you had Steam Desktop Authenticator installed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Create config dir if we don't have it if (!Directory.Exists(Manifest.MaDir)) { Directory.CreateDirectory(Manifest.MaDir); } // Copy all files from the old dir to the new one foreach (string newPath in Directory.GetFiles(pathToCopy, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(pathToCopy, Manifest.MaDir), true); } // Set first run in manifest try { man = Manifest.GetManifest(true); man.FirstRun = false; man.Save(); } catch (ManifestParseException) { // Manifest file was corrupted, generate a new one. try { MessageBox.Show("Your settings were unexpectedly corrupted and were reset to defaults.", "Steam Desktop Authenticator", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); man = Manifest.GenerateNewManifest(true); } catch (MaFileEncryptedException) { // An maFile was encrypted, we're f****d. MessageBox.Show("Sorry, but SDA was unable to recover your accounts since you used encryption.\nYou'll need to recover your Steam accounts by removing the authenticator.\nClick OK to view instructions.", "Steam Desktop Authenticator", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Diagnostics.Process.Start(@"https://github.com/Jessecar96/SteamDesktopAuthenticator/wiki/Help!-I'm-locked-out-of-my-account"); this.Close(); return; } } // All done! MessageBox.Show("All accounts and settings have been imported! Click OK to continue.", "Import accounts", MessageBoxButtons.OK, MessageBoxIcon.Information); showMainForm(); } }