public string PromptForPassKey() { if (!this.Encrypted) { throw new ManifestNotEncryptedException(); } bool passKeyValid = false; string passKey = null; while (!passKeyValid) { InputForm passKeyForm = new InputForm("Please enter your encryption passkey.", true); passKeyForm.ShowDialog(); if (!passKeyForm.Canceled) { passKey = passKeyForm.txtBox.Text; passKeyValid = this.VerifyPasskey(passKey); if (!passKeyValid) { MessageBox.Show("That passkey is invalid."); } } else { return(null); } } return(passKey); }
private void btnDelete_Click(object sender, EventArgs e) { if (mCurrentAccount == null) return; string confCode = mCurrentAccount.GenerateSteamGuardCode(); InputForm confirmationDialog = new InputForm("Removing the authenticator from " + mCurrentAccount.AccountName + ". Enter confirmation code " + confCode); confirmationDialog.ShowDialog(); if (confirmationDialog.Canceled) return; string enteredCode = confirmationDialog.txtBox.Text.ToUpper(); if (enteredCode != confCode) { MessageBox.Show("Confirmation codes do not match. Authenticator has not been unlinked."); return; } bool success = mCurrentAccount.DeactivateAuthenticator(); if (success) { MessageBox.Show("Authenticator unlinked. maFile will be deleted after hitting okay. If you need to make a backup, now's the time."); this.mManifest.RemoveAccount(mCurrentAccount); this.loadAccountsList(); } else { MessageBox.Show("Authenticator unable to be removed."); } }
private void btnManageEncryption_Click(object sender, EventArgs e) { if (mManifest.Encrypted) { InputForm currentPassKeyForm = new InputForm("Enter current passkey", true); currentPassKeyForm.ShowDialog(); if (currentPassKeyForm.Canceled) { return; } string curPassKey = currentPassKeyForm.txtBox.Text; InputForm changePassKeyForm = new InputForm("Enter new passkey, or leave blank to remove encryption."); changePassKeyForm.ShowDialog(); if (changePassKeyForm.Canceled) { return; } InputForm changePassKeyForm2 = new InputForm("Confirm new passkey, or leave blank to remove encryption."); changePassKeyForm2.ShowDialog(); if (changePassKeyForm2.Canceled) { return; } string newPassKey = changePassKeyForm.txtBox.Text; string confirmPassKey = changePassKeyForm2.txtBox.Text; if (newPassKey != confirmPassKey) { MessageBox.Show("Passkeys do not match."); return; } if (newPassKey.Length == 0) { newPassKey = null; } string action = newPassKey == null ? "remove" : "change"; if (!mManifest.ChangeEncryptionKey(curPassKey, newPassKey)) { MessageBox.Show("Unable to " + action + " passkey."); } else { MessageBox.Show("Passkey successfully " + action + "d."); this.loadAccountsList(); } } else { mManifest.PromptSetupPassKey(); this.loadAccountsList(); } }
private void menuDeactivateAuthenticator_Click(object sender, EventArgs e) { if (currentAccount == null) { return; } DialogResult res = MessageBox.Show("Would you like to remove Steam Guard completely?\nYes - Remove Steam Guard completely.\nNo - Switch back to Email authentication.", "Remove Steam Guard", MessageBoxButtons.YesNoCancel); int scheme = 0; if (res == DialogResult.Yes) { scheme = 2; } else if (res == DialogResult.No) { scheme = 1; } else if (res == DialogResult.Cancel) { scheme = 0; } if (scheme != 0) { string confCode = currentAccount.GenerateSteamGuardCode(); InputForm confirmationDialog = new InputForm(String.Format("Removing Steam Guard from {0}. Enter this confirmation code: {1}", currentAccount.AccountName, confCode)); confirmationDialog.ShowDialog(); if (confirmationDialog.Canceled) { return; } string enteredCode = confirmationDialog.txtBox.Text.ToUpper(); if (enteredCode != confCode) { MessageBox.Show("Confirmation codes do not match. Steam Guard not removed."); return; } bool success = currentAccount.DeactivateAuthenticator(scheme); if (success) { MessageBox.Show(String.Format("Steam Guard {0}. maFile will be deleted after hitting okay. If you need to make a backup, now's the time.", (scheme == 2 ? "removed completely" : "switched to emails"))); this.manifest.RemoveAccount(currentAccount); this.loadAccountsList(); } else { MessageBox.Show("Steam Guard failed to deactivate."); } } else { MessageBox.Show("Steam Guard was not removed. No action was taken."); } }
private void menuDeactivateAuthenticator_Click(object sender, EventArgs e) { if (currentAccount == null) { return; } DialogResult res = MessageBox.Show("您想要完全删除Steam令牌吗?完全移除Steam令牌。取消 - 返回电子邮件身份验证。", "删除Steam令牌", MessageBoxButtons.YesNoCancel); int scheme = 0; if (res == DialogResult.Yes) { scheme = 2; } else if (res == DialogResult.No) { scheme = 1; } else if (res == DialogResult.Cancel) { scheme = 0; } if (scheme != 0) { string confCode = currentAccount.GenerateSteamGuardCode(); InputForm confirmationDialog = new InputForm(String.Format("从{0}删除Steam令牌。 输入验证码:{1}", currentAccount.AccountName, confCode)); confirmationDialog.ShowDialog(); if (confirmationDialog.Canceled) { return; } string enteredCode = confirmationDialog.txtBox.Text.ToUpper(); if (enteredCode != confCode) { MessageBox.Show("验证码不匹配。Steam令牌无法删除。"); return; } bool success = currentAccount.DeactivateAuthenticator(scheme); if (success) { MessageBox.Show(String.Format("Steam 令牌{0}。 点击后maFile文件将被删除。 如果您需要进行备份,请现在进行。", (scheme == 2 ? "removed completely" : "switched to emails"))); this.manifest.RemoveAccount(currentAccount); this.loadAccountsList(); } else { MessageBox.Show("Steam令牌无法停用。"); } } else { MessageBox.Show("Steam令牌未被删除。 没有采取任何动作。"); } }
private void btnConnect_Click(object sender, EventArgs e) { InputForm input = new InputForm("Enter IP of the device"); input.ShowDialog(); if (!input.Canceled) { bridge.ConnectWiFi(input.txtBox.Text); } }
private void btnConnect_Click(object sender, EventArgs e) { InputForm input = new InputForm("Enter IP of the device"); input.ShowDialog(); if (!input.Canceled) { bridge.ConnectWiFi(input.txtBox.Text); } }
private void loadAccountsList() { mCurrentAccount = null; listAccounts.Items.Clear(); listAccounts.SelectedIndex = -1; string passKey = null; if (mManifest.Encrypted) { bool passKeyValid = false; while (!passKeyValid) { InputForm passKeyForm = new InputForm("Please enter your encryption passkey.", true); passKeyForm.ShowDialog(); if (!passKeyForm.Canceled) { passKey = passKeyForm.txtBox.Text; passKeyValid = this.mManifest.VerifyPasskey(passKey); if (!passKeyValid) { MessageBox.Show("That passkey is invalid."); } } else { this.Close(); return; } } btnManageEncryption.Text = "Manage Encryption"; } else { btnManageEncryption.Text = "Setup Encryption"; } btnManageEncryption.Enabled = mManifest.Entries.Count > 0; allAccounts = mManifest.GetAllAccounts(passKey); if (allAccounts.Length > 0) { for (int i = 0; i < allAccounts.Length; i++) { SteamGuardAccount account = allAccounts[i]; listAccounts.Items.Add(account.AccountName); } listAccounts.SelectedIndex = 0; } btnDelete.Enabled = btnTradeConfirmations.Enabled = allAccounts.Length > 0; }
private void btnManageEncryption_Click(object sender, EventArgs e) { if (mManifest.Encrypted) { InputForm currentPassKeyForm = new InputForm("Enter current passkey", true); currentPassKeyForm.ShowDialog(); if (currentPassKeyForm.Canceled) return; string curPassKey = currentPassKeyForm.txtBox.Text; InputForm changePassKeyForm = new InputForm("Enter new passkey, or leave blank to remove encryption."); changePassKeyForm.ShowDialog(); if (changePassKeyForm.Canceled) return; InputForm changePassKeyForm2 = new InputForm("Confirm new passkey, or leave blank to remove encryption."); changePassKeyForm2.ShowDialog(); if (changePassKeyForm2.Canceled) return; string newPassKey = changePassKeyForm.txtBox.Text; string confirmPassKey = changePassKeyForm2.txtBox.Text; if (newPassKey != confirmPassKey) { MessageBox.Show("Passkeys do not match."); return; } if (newPassKey.Length == 0) newPassKey = null; string action = newPassKey == null ? "remove" : "change"; if (!mManifest.ChangeEncryptionKey(curPassKey, newPassKey)) MessageBox.Show("Unable to " + action + " passkey."); else { MessageBox.Show("Passkey successfully " + action + "d."); this.loadAccountsList(); } } else { mManifest.PromptSetupPassKey(); this.loadAccountsList(); } }
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("ÄãµÄµÇ¼»á»°ÒѾˢÐÂ."); } else { MessageBox.Show("ÊÖ»úÈÏÖ¤Æ÷Á´½Ó³É¹¦. Çëдϳ·»ØÂë: " + androidAccount.RevocationCode); } this.Close(); }
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(); }
private void HandleManifest(Manifest man, bool IsRefreshing = false) { string passKey = null; if (man.Entries.Count == 0) { passKey = man.PromptSetupPassKey("请输入一个加密密码. 不加密请留空 (非常不安全)."); } else if (man.Entries.Count > 0 && man.Encrypted) { bool passKeyValid = false; while (!passKeyValid) { InputForm passKeyForm = new InputForm("请输入当前的加密密码."); passKeyForm.ShowDialog(); if (!passKeyForm.Canceled) { passKey = passKeyForm.txtBox.Text; passKeyValid = man.VerifyPasskey(passKey); if (!passKeyValid) { MessageBox.Show("这个加密密码不正确. 请输入你用于加密其他账号信息的密码."); } } else { this.Close(); return; } } } man.SaveAccount(account, passKey != null, passKey); if (IsRefreshing) { MessageBox.Show("您的登录状态已刷新。"); } else { MessageBox.Show("成功连接移动验证器。 请记下你的撤销代码: " + account.RevocationCode); } this.Close(); }
public string PromptSetupPassKey(string initialPrompt = "Enter passkey, or hit cancel to remain unencrypted.") { InputForm newPassKeyForm = new InputForm(initialPrompt); newPassKeyForm.ShowDialog(); if (newPassKeyForm.Canceled || newPassKeyForm.txtBox.Text.Length == 0) { MessageBox.Show("WARNING: You chose to not encrypt your files. Doing so imposes a security risk for yourself. If an attacker were to gain access to your computer, they could completely lock you out of your account and steal all your items."); return(null); } InputForm newPassKeyForm2 = new InputForm("Confirm new passkey."); newPassKeyForm2.ShowDialog(); if (newPassKeyForm2.Canceled) { MessageBox.Show("WARNING: You chose to not encrypt your files. Doing so imposes a security risk for yourself. If an attacker were to gain access to your computer, they could completely lock you out of your account and steal all your items."); return(null); } string newPassKey = newPassKeyForm.txtBox.Text; string confirmPassKey = newPassKeyForm2.txtBox.Text; if (newPassKey != confirmPassKey) { MessageBox.Show("Passkeys do not match."); return(null); } if (!this.ChangeEncryptionKey(null, newPassKey)) { MessageBox.Show("Unable to set passkey."); return(null); } else { MessageBox.Show("Passkey successfully set."); } return(newPassKey); }
public string PromptSetupPassKey(string initialPrompt = "输入密码或者点击取消保持不加密。") { InputForm newPassKeyForm = new InputForm(initialPrompt); newPassKeyForm.ShowDialog(); if (newPassKeyForm.Canceled || newPassKeyForm.txtBox.Text.Length == 0) { MessageBox.Show("警告:您选择不加密您的文件。这样做会给自己带来安全风险。如果攻击者要访问您的计算机,他们可以将您完全锁定在您的帐户之外,并窃取您的所有信息。"); return(null); } InputForm newPassKeyForm2 = new InputForm("确认新加密密码."); newPassKeyForm2.ShowDialog(); if (newPassKeyForm2.Canceled) { MessageBox.Show("警告:您选择不加密您的文件。这样做会给自己带来安全风险。如果攻击者要访问您的计算机,他们可以将您完全锁定在您的帐户之外,并窃取您的所有信息。"); return(null); } string newPassKey = newPassKeyForm.txtBox.Text; string confirmPassKey = newPassKeyForm2.txtBox.Text; if (newPassKey != confirmPassKey) { MessageBox.Show("密码不匹配."); return(null); } if (!this.ChangeEncryptionKey(null, newPassKey)) { MessageBox.Show("无法设置加密密码。"); return(null); } else { MessageBox.Show("加密成功"); } return(newPassKey); }
private void btnDelete_Click(object sender, EventArgs e) { if (mCurrentAccount == null) { return; } string confCode = mCurrentAccount.GenerateSteamGuardCode(); InputForm confirmationDialog = new InputForm("Removing the authenticator from " + mCurrentAccount.AccountName + ". Enter confirmation code " + confCode); confirmationDialog.ShowDialog(); if (confirmationDialog.Canceled) { return; } string enteredCode = confirmationDialog.txtBox.Text.ToUpper(); if (enteredCode != confCode) { MessageBox.Show("Confirmation codes do not match. Authenticator has not been unlinked."); return; } bool success = mCurrentAccount.DeactivateAuthenticator(); if (success) { MessageBox.Show("Authenticator unlinked. maFile will be deleted after hitting okay. If you need to make a backup, now's the time."); MobileAuthenticatorFileHandler.DeleteMaFile(mCurrentAccount); this.loadAccountsList(); } else { MessageBox.Show("Authenticator unable to be removed."); } }
public string PromptSetupPassKey(string initialPrompt = "Enter passkey, or hit cancel to remain unencrypted.") { InputForm newPassKeyForm = new InputForm(initialPrompt); newPassKeyForm.ShowDialog(); if (newPassKeyForm.Canceled || newPassKeyForm.txtBox.Text.Length == 0) { MessageBox.Show("WARNING: You chose to not encrypt your files. Doing so imposes a security risk for yourself. If an attacker were to gain access to your computer, they could completely lock you out of your account and steal all your items."); return null; } InputForm newPassKeyForm2 = new InputForm("Confirm new passkey."); newPassKeyForm2.ShowDialog(); if (newPassKeyForm2.Canceled) { MessageBox.Show("WARNING: You chose to not encrypt your files. Doing so imposes a security risk for yourself. If an attacker were to gain access to your computer, they could completely lock you out of your account and steal all your items."); return null; } string newPassKey = newPassKeyForm.txtBox.Text; string confirmPassKey = newPassKeyForm2.txtBox.Text; if (newPassKey != confirmPassKey) { MessageBox.Show("Passkeys do not match."); return null; } if (!this.ChangeEncryptionKey(null, newPassKey)) { MessageBox.Show("Unable to set passkey."); return null; } else MessageBox.Show("Passkey successfully set."); return newPassKey; }
private void btnManageEncryption_Click(object sender, EventArgs e) { if (manifest.Encrypted) { InputForm currentPassKeyForm = new InputForm("输入当前密码", true); currentPassKeyForm.ShowDialog(); if (currentPassKeyForm.Canceled) { return; } string curPassKey = currentPassKeyForm.txtBox.Text; InputForm changePassKeyForm = new InputForm("输入新的密码,或留空以取消密码"); changePassKeyForm.ShowDialog(); if (changePassKeyForm.Canceled && !string.IsNullOrEmpty(changePassKeyForm.txtBox.Text)) { return; } InputForm changePassKeyForm2 = new InputForm("确认新密码,或留空以取消密码"); changePassKeyForm2.ShowDialog(); if (changePassKeyForm2.Canceled && !string.IsNullOrEmpty(changePassKeyForm.txtBox.Text)) { return; } string newPassKey = changePassKeyForm.txtBox.Text; string confirmPassKey = changePassKeyForm2.txtBox.Text; if (newPassKey != confirmPassKey) { MessageBox.Show("密码不匹配"); return; } if (newPassKey.Length == 0) { newPassKey = null; } string action = newPassKey == null ? "移除" : "修改"; if (!manifest.ChangeEncryptionKey(curPassKey, newPassKey)) { MessageBox.Show("不能" + action + "密码."); } else { MessageBox.Show("密码成功" + action + "."); this.loadAccountsList(); } } else { passKey = manifest.PromptSetupPassKey(); this.loadAccountsList(); } }
private void btnSteamLogin_Click(object sender, EventArgs e) { string username = txtUsername.Text; string password = txtPassword.Text; mUserLogin = new UserLogin(username, password); LoginResult response = LoginResult.BadCredentials; while ((response = mUserLogin.DoLogin()) != LoginResult.LoginOkay) { switch (response) { case LoginResult.NeedEmail: InputForm emailForm = new InputForm("Enter the code sent to your email:"); emailForm.ShowDialog(); if (emailForm.Canceled) { this.Close(); return; } mUserLogin.EmailCode = emailForm.txtBox.Text; break; case LoginResult.NeedCaptcha: System.Diagnostics.Process.Start(String.Format("{0}/public/captcha.php?gid={1}", APIEndpoints.COMMUNITY_BASE, mUserLogin.CaptchaGID)); InputForm captchaForm = new InputForm("Enter the captcha that opened in your browser:"); captchaForm.ShowDialog(); if (captchaForm.Canceled) { this.Close(); return; } mUserLogin.CaptchaText = captchaForm.txtBox.Text; break; case LoginResult.Need2FA: MessageBox.Show("This account already has a mobile authenticator linked to it. Please remove that first."); this.Close(); return; break; } } //Login succeeded SessionData session = mUserLogin.Session; AuthenticatorLinker linker = new AuthenticatorLinker(session); AuthenticatorLinker.LinkResult linkResponse = AuthenticatorLinker.LinkResult.GeneralFailure; while ((linkResponse = linker.AddAuthenticator()) != AuthenticatorLinker.LinkResult.AwaitingFinalization) { switch (linkResponse) { case AuthenticatorLinker.LinkResult.MustProvidePhoneNumber: string phoneNumber = ""; while (!PhoneNumberOkay(phoneNumber)) { InputForm phoneNumberForm = new InputForm("Enter your phone number in the following format: +{cC} phoneNumber. EG, +1 123-456-7890"); phoneNumberForm.txtBox.Text = "+1 "; phoneNumberForm.ShowDialog(); if (phoneNumberForm.Canceled) { this.Close(); return; } phoneNumber = FilterPhoneNumber(phoneNumberForm.txtBox.Text); } linker.PhoneNumber = phoneNumber; break; case AuthenticatorLinker.LinkResult.MustRemovePhoneNumber: linker.PhoneNumber = null; break; case AuthenticatorLinker.LinkResult.GeneralFailure: this.Close(); return; break; } } //Save the file immediately; losing this would be bad. if (!MobileAuthenticatorFileHandler.SaveMaFile(linker.LinkedAccount)) { MessageBox.Show("Unable to save mobile authenticator file. The mobile authenticator has not been linked."); this.Close(); return; } MessageBox.Show("The Mobile Authenticator has not yet been linked. Before finalizing the authenticator, please write down your revocation code: " + linker.LinkedAccount.RevocationCode); AuthenticatorLinker.FinalizeResult finalizeResponse = AuthenticatorLinker.FinalizeResult.GeneralFailure; while (finalizeResponse != AuthenticatorLinker.FinalizeResult.Success) { InputForm smsCodeForm = new InputForm("Please input the SMS code sent to your phone."); smsCodeForm.ShowDialog(); if (smsCodeForm.Canceled) { MobileAuthenticatorFileHandler.DeleteMaFile(linker.LinkedAccount); this.Close(); return; } InputForm confirmRevocationCode = new InputForm("Please enter your revocation code to ensure you've saved it."); confirmRevocationCode.ShowDialog(); if (confirmRevocationCode.txtBox.Text.ToUpper() != linker.LinkedAccount.RevocationCode) { MessageBox.Show("Revocation code incorrect; the authenticator has not been linked."); MobileAuthenticatorFileHandler.DeleteMaFile(linker.LinkedAccount); this.Close(); return; } string smsCode = smsCodeForm.txtBox.Text; finalizeResponse = linker.FinalizeAddAuthenticator(smsCode); switch (finalizeResponse) { case AuthenticatorLinker.FinalizeResult.BadSMSCode: continue; break; case AuthenticatorLinker.FinalizeResult.UnableToGenerateCorrectCodes: MessageBox.Show("Unable to generate the proper codes to finalize this authenticator. The authenticator should not have been linked. In the off-chance it was, please write down your revocation code, as this is the last chance to see it: " + linker.LinkedAccount.RevocationCode); MobileAuthenticatorFileHandler.DeleteMaFile(linker.LinkedAccount); this.Close(); return; break; case AuthenticatorLinker.FinalizeResult.GeneralFailure: MessageBox.Show("Unable to finalize this authenticator. The authenticator should not have been linked. In the off-chance it was, please write down your revocation code, as this is the last chance to see it: " + linker.LinkedAccount.RevocationCode); MobileAuthenticatorFileHandler.DeleteMaFile(linker.LinkedAccount); this.Close(); return; } } //Linked, finally. Re-save with FullyEnrolled property. MobileAuthenticatorFileHandler.SaveMaFile(linker.LinkedAccount); MessageBox.Show("Mobile authenticator successfully linked. Please write down your revocation code: " + linker.LinkedAccount.RevocationCode); this.Close(); }
private void btnSteamLogin_Click(object sender, EventArgs e) { string username = txtUsername.Text; string password = txtPassword.Text; mUserLogin = new UserLogin(username, password); LoginResult response = LoginResult.BadCredentials; while ((response = mUserLogin.DoLogin()) != LoginResult.LoginOkay) { switch (response) { case LoginResult.NeedEmail: InputForm emailForm = new InputForm("Enter the code sent to your email:"); emailForm.ShowDialog(); if (emailForm.Canceled) { this.Close(); return; } mUserLogin.EmailCode = emailForm.txtBox.Text; break; case LoginResult.NeedCaptcha: System.Diagnostics.Process.Start(String.Format("{0}/public/captcha.php?gid={1}", APIEndpoints.COMMUNITY_BASE, mUserLogin.CaptchaGID)); InputForm captchaForm = new InputForm("Enter the captcha that opened in your browser:"); captchaForm.ShowDialog(); if (captchaForm.Canceled) { this.Close(); return; } mUserLogin.CaptchaText = captchaForm.txtBox.Text; break; case LoginResult.Need2FA: MessageBox.Show("This account already has a mobile authenticator linked to it. Please remove that first."); this.Close(); return; break; } } //Login succeeded SessionData session = mUserLogin.Session; AuthenticatorLinker linker = new AuthenticatorLinker(session); AuthenticatorLinker.LinkResult linkResponse = AuthenticatorLinker.LinkResult.GeneralFailure; while ((linkResponse = linker.AddAuthenticator()) != AuthenticatorLinker.LinkResult.AwaitingFinalization) { switch (linkResponse) { case AuthenticatorLinker.LinkResult.MustProvidePhoneNumber: string phoneNumber = ""; while (!PhoneNumberOkay(phoneNumber)) { InputForm phoneNumberForm = new InputForm("Enter your phone number in the following format: +{cC} phoneNumber. EG, +1 123-456-7890"); phoneNumberForm.txtBox.Text = "+1 "; phoneNumberForm.ShowDialog(); if (phoneNumberForm.Canceled) { this.Close(); return; } phoneNumber = FilterPhoneNumber(phoneNumberForm.txtBox.Text); } linker.PhoneNumber = phoneNumber; break; case AuthenticatorLinker.LinkResult.MustRemovePhoneNumber: linker.PhoneNumber = null; break; case AuthenticatorLinker.LinkResult.GeneralFailure: this.Close(); return; break; } } //Save the file immediately; losing this would be bad. if (!MobileAuthenticatorFileHandler.SaveMaFile(linker.LinkedAccount)) { MessageBox.Show("Unable to save mobile authenticator file. The mobile authenticator has not been linked."); this.Close(); return; } MessageBox.Show("The Mobile Authenticator has not yet been linked. Before finalizing the authenticator, please write down your revocation code: " + linker.LinkedAccount.RevocationCode); AuthenticatorLinker.FinalizeResult finalizeResponse = AuthenticatorLinker.FinalizeResult.GeneralFailure; while (finalizeResponse != AuthenticatorLinker.FinalizeResult.Success) { InputForm smsCodeForm = new InputForm("Please input the SMS code sent to your phone."); smsCodeForm.ShowDialog(); if (smsCodeForm.Canceled) { MobileAuthenticatorFileHandler.DeleteMaFile(linker.LinkedAccount); this.Close(); return; } InputForm confirmRevocationCode = new InputForm("Please enter your revocation code to ensure you've saved it."); confirmRevocationCode.ShowDialog(); if(confirmRevocationCode.txtBox.Text.ToUpper() != linker.LinkedAccount.RevocationCode) { MessageBox.Show("Revocation code incorrect; the authenticator has not been linked."); MobileAuthenticatorFileHandler.DeleteMaFile(linker.LinkedAccount); this.Close(); return; } string smsCode = smsCodeForm.txtBox.Text; finalizeResponse = linker.FinalizeAddAuthenticator(smsCode); switch (finalizeResponse) { case AuthenticatorLinker.FinalizeResult.BadSMSCode: continue; break; case AuthenticatorLinker.FinalizeResult.UnableToGenerateCorrectCodes: MessageBox.Show("Unable to generate the proper codes to finalize this authenticator. The authenticator should not have been linked. In the off-chance it was, please write down your revocation code, as this is the last chance to see it: " + linker.LinkedAccount.RevocationCode); MobileAuthenticatorFileHandler.DeleteMaFile(linker.LinkedAccount); this.Close(); return; break; case AuthenticatorLinker.FinalizeResult.GeneralFailure: MessageBox.Show("Unable to finalize this authenticator. The authenticator should not have been linked. In the off-chance it was, please write down your revocation code, as this is the last chance to see it: " + linker.LinkedAccount.RevocationCode); MobileAuthenticatorFileHandler.DeleteMaFile(linker.LinkedAccount); this.Close(); return; } } //Linked, finally. Re-save with FullyEnrolled property. MobileAuthenticatorFileHandler.SaveMaFile(linker.LinkedAccount); MessageBox.Show("Mobile authenticator successfully linked. Please write down your revocation code: " + linker.LinkedAccount.RevocationCode); this.Close(); }
private void loadAccountsList() { mCurrentAccount = null; listAccounts.Items.Clear(); listAccounts.SelectedIndex = -1; string passKey = null; if (mManifest.Encrypted) { bool passKeyValid = false; while (!passKeyValid) { InputForm passKeyForm = new InputForm("Please enter your encryption passkey.", true); passKeyForm.ShowDialog(); if (!passKeyForm.Canceled) { passKey = passKeyForm.txtBox.Text; passKeyValid = this.mManifest.VerifyPasskey(passKey); if (!passKeyValid) { MessageBox.Show("That passkey is invalid."); } } else { this.Close(); return; } } btnManageEncryption.Text = "Manage Encryption"; } else { btnManageEncryption.Text = "Setup Encryption"; } btnManageEncryption.Enabled = mManifest.Entries.Count > 0; allAccounts = mManifest.GetAllAccounts(passKey); if (allAccounts.Length > 0) { for (int i = 0; i < allAccounts.Length; i++) { SteamGuardAccount account = allAccounts[i]; listAccounts.Items.Add(account.AccountName); } listAccounts.SelectedIndex = 0; } btnDelete.Enabled = btnTradeConfirmations.Enabled = allAccounts.Length > 0; }
private void btnSteamLogin_Click(object sender, EventArgs e) { string username = txtUsername.Text; string password = txtPassword.Text; if (LoginReason == LoginType.Refresh) { RefreshLogin(username, password); return; } var userLogin = new UserLogin(username, password); LoginResult response = LoginResult.BadCredentials; while ((response = userLogin.DoLogin()) != LoginResult.LoginOkay) { switch (response) { case LoginResult.NeedEmail: InputForm emailForm = new InputForm("Enter the code sent to your email:"); emailForm.ShowDialog(); if (emailForm.Canceled) { this.Close(); return; } userLogin.EmailCode = emailForm.txtBox.Text; break; case LoginResult.NeedCaptcha: CaptchaForm captchaForm = new CaptchaForm(userLogin.CaptchaGID); captchaForm.ShowDialog(); if (captchaForm.Canceled) { this.Close(); return; } userLogin.CaptchaText = captchaForm.CaptchaCode; break; case LoginResult.Need2FA: MessageBox.Show("此帐户已经有一个与其绑定的移动身份验证器。在添入新的验证器之前,请把您的Steam帐户从旧的验证器中删除。", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.BadRSA: MessageBox.Show("错误记录:Steam返回“BadRSA”。", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.BadCredentials: MessageBox.Show("错误记录:用户名或密码不正确。", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.TooManyFailedLogins: MessageBox.Show("错误记录:太多次失败的登录,稍后再试。", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.GeneralFailure: MessageBox.Show("错误记录:Steam返回“GeneralFailure”。", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } } //Login succeeded SessionData session = userLogin.Session; AuthenticatorLinker linker = new AuthenticatorLinker(session); AuthenticatorLinker.LinkResult linkResponse = AuthenticatorLinker.LinkResult.GeneralFailure; while ((linkResponse = linker.AddAuthenticator()) != AuthenticatorLinker.LinkResult.AwaitingFinalization) { switch (linkResponse) { case AuthenticatorLinker.LinkResult.MustProvidePhoneNumber: string phoneNumber = ""; while (!PhoneNumberOkay(phoneNumber)) { InputForm phoneNumberForm = new InputForm("以下列格式输入您的电话号码:+{区号}电话号码。+86 12345678910"); phoneNumberForm.txtBox.Text = "+1 "; phoneNumberForm.ShowDialog(); if (phoneNumberForm.Canceled) { this.Close(); return; } phoneNumber = FilterPhoneNumber(phoneNumberForm.txtBox.Text); } linker.PhoneNumber = phoneNumber; break; case AuthenticatorLinker.LinkResult.MustRemovePhoneNumber: linker.PhoneNumber = null; break; case AuthenticatorLinker.LinkResult.MustConfirmEmail: MessageBox.Show("Steam会先发一封确认添加手机号码的邮件,请先去点击邮件中的添加手机号码按钮,然后点击确认。"); break; case AuthenticatorLinker.LinkResult.GeneralFailure: MessageBox.Show("添加电话号码时出错。Steam返回“GeneralFailure”。"); this.Close(); return; } } Manifest manifest = Manifest.GetManifest(); string passKey = null; if (manifest.Entries.Count == 0) { passKey = manifest.PromptSetupPassKey("请输入加密密码。留下空白或点击取消不加密都非常不安全。"); } else if (manifest.Entries.Count > 0 && manifest.Encrypted) { bool passKeyValid = false; while (!passKeyValid) { InputForm passKeyForm = new InputForm("请输入您当前的加密密码。"); passKeyForm.ShowDialog(); if (!passKeyForm.Canceled) { passKey = passKeyForm.txtBox.Text; passKeyValid = manifest.VerifyPasskey(passKey); if (!passKeyValid) { MessageBox.Show("此密码无效。请输入您用于其他帐户的密码。"); } } else { this.Close(); return; } } } //Save the file immediately; losing this would be bad. if (!manifest.SaveAccount(linker.LinkedAccount, passKey != null, passKey)) { manifest.RemoveAccount(linker.LinkedAccount); MessageBox.Show("无法保存移动身份验证器文件。 移动身份验证器尚未连接。"); this.Close(); return; } MessageBox.Show("移动身份验证器尚未连接。 在最终确认使用桌面验证器之前,请写下您的撤销代码:" + linker.LinkedAccount.RevocationCode); AuthenticatorLinker.FinalizeResult finalizeResponse = AuthenticatorLinker.FinalizeResult.GeneralFailure; while (finalizeResponse != AuthenticatorLinker.FinalizeResult.Success) { InputForm smsCodeForm = new InputForm("请输入发送到您手机的短信代码。"); smsCodeForm.ShowDialog(); if (smsCodeForm.Canceled) { manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; } InputForm confirmRevocationCode = new InputForm("请输入您的撤销代码,以确保您已保存它。"); confirmRevocationCode.ShowDialog(); if (confirmRevocationCode.txtBox.Text.ToUpper() != linker.LinkedAccount.RevocationCode) { MessageBox.Show("撤销代码不正确;无法连接桌面验证器。"); manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; } string smsCode = smsCodeForm.txtBox.Text; finalizeResponse = linker.FinalizeAddAuthenticator(smsCode); switch (finalizeResponse) { case AuthenticatorLinker.FinalizeResult.BadSMSCode: continue; case AuthenticatorLinker.FinalizeResult.UnableToGenerateCorrectCodes: MessageBox.Show("无法生成正确的代码来完成此身份验证器。 验证器没有被连接。 应该是偶发状况,请写下你的撤销代码,因为这是最后一次看到它的机会:" + linker.LinkedAccount.RevocationCode); manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; case AuthenticatorLinker.FinalizeResult.GeneralFailure: MessageBox.Show("无法生成正确的代码来完成此身份验证器。 验证器没有被连接。 应该是偶发状况,请写下你的撤销代码,因为这是最后一次看到它的机会:" + linker.LinkedAccount.RevocationCode); manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; } } //Linked, finally. Re-save with FullyEnrolled property. manifest.SaveAccount(linker.LinkedAccount, passKey != null, passKey); MessageBox.Show("成功连接移动验证器。 请写下你的撤销代码:" + linker.LinkedAccount.RevocationCode); this.Close(); }
public string PromptForPassKey() { if (!this.Encrypted) { throw new ManifestNotEncryptedException(); } bool passKeyValid = false; string passKey = null; while (!passKeyValid) { InputForm passKeyForm = new InputForm("Please enter your encryption passkey.", true); passKeyForm.ShowDialog(); if (!passKeyForm.Canceled) { passKey = passKeyForm.txtBox.Text; passKeyValid = this.VerifyPasskey(passKey); if (!passKeyValid) { MessageBox.Show("That passkey is invalid."); } } else { return null; } } return passKey; }
private void btnSteamLogin_Click(object sender, EventArgs e) { string username = txtUsername.Text; string password = txtPassword.Text; if (LoginReason == LoginType.Android) { FinishExtract(username, password); return; } else if (LoginReason == LoginType.Refresh) { RefreshLogin(username, password); return; } var userLogin = new UserLogin(username, password); LoginResult response = LoginResult.BadCredentials; while ((response = userLogin.DoLogin()) != LoginResult.LoginOkay) { switch (response) { case LoginResult.NeedEmail: InputForm emailForm = new InputForm("Enter the code sent to your email:"); emailForm.ShowDialog(); if (emailForm.Canceled) { this.Close(); return; } userLogin.EmailCode = emailForm.txtBox.Text; break; case LoginResult.NeedCaptcha: CaptchaForm captchaForm = new CaptchaForm(userLogin.CaptchaGID); captchaForm.ShowDialog(); if (captchaForm.Canceled) { this.Close(); return; } userLogin.CaptchaText = captchaForm.CaptchaCode; break; case LoginResult.Need2FA: MessageBox.Show("This account already has a mobile authenticator linked to it.\nRemove the old authenticator from your Steam account before adding a new one.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.BadRSA: MessageBox.Show("Error logging in: Steam returned \"BadRSA\".", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.BadCredentials: MessageBox.Show("Error logging in: Username or password was incorrect.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.TooManyFailedLogins: MessageBox.Show("Error logging in: Too many failed logins, try again later.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.GeneralFailure: MessageBox.Show("Error logging in: Steam returned \"GeneralFailure\".", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } } //Login succeeded SessionData session = userLogin.Session; AuthenticatorLinker linker = new AuthenticatorLinker(session); AuthenticatorLinker.LinkResult linkResponse = AuthenticatorLinker.LinkResult.GeneralFailure; while ((linkResponse = linker.AddAuthenticator()) != AuthenticatorLinker.LinkResult.AwaitingFinalization) { switch (linkResponse) { case AuthenticatorLinker.LinkResult.MustProvidePhoneNumber: string phoneNumber = ""; while (!PhoneNumberOkay(phoneNumber)) { InputForm phoneNumberForm = new InputForm("Enter your phone number in the following format: +{cC} phoneNumber. EG, +1 123-456-7890"); phoneNumberForm.txtBox.Text = "+1 "; phoneNumberForm.ShowDialog(); if (phoneNumberForm.Canceled) { this.Close(); return; } phoneNumber = FilterPhoneNumber(phoneNumberForm.txtBox.Text); } linker.PhoneNumber = phoneNumber; break; case AuthenticatorLinker.LinkResult.MustRemovePhoneNumber: linker.PhoneNumber = null; break; case AuthenticatorLinker.LinkResult.GeneralFailure: MessageBox.Show("Error adding your phone number. Steam returned \"GeneralFailure\"."); this.Close(); return; } } Manifest manifest = Manifest.GetManifest(); string passKey = null; if (manifest.Entries.Count == 0) { passKey = manifest.PromptSetupPassKey("Please enter an encryption passkey. Leave blank or hit cancel to not encrypt (VERY INSECURE)."); } else if (manifest.Entries.Count > 0 && manifest.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 = manifest.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; } } } //Save the file immediately; losing this would be bad. if (!manifest.SaveAccount(linker.LinkedAccount, passKey != null, passKey)) { manifest.RemoveAccount(linker.LinkedAccount); MessageBox.Show("Unable to save mobile authenticator file. The mobile authenticator has not been linked."); this.Close(); return; } MessageBox.Show("The Mobile Authenticator has not yet been linked. Before finalizing the authenticator, please write down your revocation code: " + linker.LinkedAccount.RevocationCode); AuthenticatorLinker.FinalizeResult finalizeResponse = AuthenticatorLinker.FinalizeResult.GeneralFailure; while (finalizeResponse != AuthenticatorLinker.FinalizeResult.Success) { InputForm smsCodeForm = new InputForm("Please input the SMS code sent to your phone."); smsCodeForm.ShowDialog(); if (smsCodeForm.Canceled) { manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; } InputForm confirmRevocationCode = new InputForm("Please enter your revocation code to ensure you've saved it."); confirmRevocationCode.ShowDialog(); if (confirmRevocationCode.txtBox.Text.ToUpper() != linker.LinkedAccount.RevocationCode) { MessageBox.Show("Revocation code incorrect; the authenticator has not been linked."); manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; } string smsCode = smsCodeForm.txtBox.Text; finalizeResponse = linker.FinalizeAddAuthenticator(smsCode); switch (finalizeResponse) { case AuthenticatorLinker.FinalizeResult.BadSMSCode: continue; case AuthenticatorLinker.FinalizeResult.UnableToGenerateCorrectCodes: MessageBox.Show("Unable to generate the proper codes to finalize this authenticator. The authenticator should not have been linked. In the off-chance it was, please write down your revocation code, as this is the last chance to see it: " + linker.LinkedAccount.RevocationCode); manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; case AuthenticatorLinker.FinalizeResult.GeneralFailure: MessageBox.Show("Unable to finalize this authenticator. The authenticator should not have been linked. In the off-chance it was, please write down your revocation code, as this is the last chance to see it: " + linker.LinkedAccount.RevocationCode); manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; } } //Linked, finally. Re-save with FullyEnrolled property. manifest.SaveAccount(linker.LinkedAccount, passKey != null, passKey); MessageBox.Show("Mobile authenticator successfully linked. Please write down your revocation code: " + linker.LinkedAccount.RevocationCode); this.Close(); }
/// <summary> /// Handles logging in after data has been extracted from Android phone /// </summary> /// <param name="username">Steam username</param> /// <param name="password">Steam password</param> private async void FinishExtract(string username, string password) { long steamTime = await TimeAligner.GetSteamTimeAsync(); Manifest man = Manifest.GetManifest(); androidAccount.FullyEnrolled = true; UserLogin mUserLogin = new UserLogin(username, password); LoginResult response = LoginResult.BadCredentials; while ((response = mUserLogin.DoLogin()) != LoginResult.LoginOkay) { switch (response) { case LoginResult.NeedEmail: InputForm emailForm = new InputForm("Enter the code sent to your email:"); emailForm.ShowDialog(); if (emailForm.Canceled) { this.Close(); return; } mUserLogin.EmailCode = emailForm.txtBox.Text; break; case LoginResult.NeedCaptcha: CaptchaForm captchaForm = new CaptchaForm(mUserLogin.CaptchaGID); captchaForm.ShowDialog(); if (captchaForm.Canceled) { this.Close(); return; } mUserLogin.CaptchaText = captchaForm.CaptchaCode; break; case LoginResult.Need2FA: mUserLogin.TwoFactorCode = androidAccount.GenerateSteamGuardCodeForTime(steamTime); break; case LoginResult.BadRSA: MessageBox.Show("Error logging in: Steam returned \"BadRSA\".", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.BadCredentials: MessageBox.Show("Error logging in: Username or password was incorrect.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.TooManyFailedLogins: MessageBox.Show("Error logging in: Too many failed logins, try again later.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.GeneralFailure: MessageBox.Show("Error logging in: Steam returned \"GeneralFailure\".", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } } androidAccount.Session = mUserLogin.Session; HandleManifest(man); }
/// <summary> /// Handles logging in after data has been extracted from Android phone /// </summary> /// <param name="username">Steam username</param> /// <param name="password">Steam password</param> private async void FinishExtract(string username, string password) { long steamTime = await TimeAligner.GetSteamTimeAsync(); Manifest man = Manifest.GetManifest(); androidAccount.FullyEnrolled = true; UserLogin mUserLogin = new UserLogin(username, password); LoginResult response = LoginResult.BadCredentials; while ((response = mUserLogin.DoLogin()) != LoginResult.LoginOkay) { switch (response) { case LoginResult.NeedEmail: InputForm emailForm = new InputForm("Enter the code sent to your email:"); emailForm.ShowDialog(); if (emailForm.Canceled) { this.Close(); return; } mUserLogin.EmailCode = emailForm.txtBox.Text; break; case LoginResult.NeedCaptcha: CaptchaForm captchaForm = new CaptchaForm(mUserLogin.CaptchaGID); captchaForm.ShowDialog(); if (captchaForm.Canceled) { this.Close(); return; } mUserLogin.CaptchaText = captchaForm.CaptchaCode; break; case LoginResult.Need2FA: mUserLogin.TwoFactorCode = androidAccount.GenerateSteamGuardCodeForTime(steamTime); break; case LoginResult.BadRSA: MessageBox.Show("Error logging in: Steam returned \"BadRSA\".", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.BadCredentials: MessageBox.Show("Error logging in: Username or password was incorrect.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.TooManyFailedLogins: MessageBox.Show("Error logging in: Too many failed logins, try again later.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.GeneralFailure: MessageBox.Show("Error logging in: Steam returned \"GeneralFailure\".", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } } androidAccount.Session = mUserLogin.Session; HandleManifest(man); }
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(); }
/// <summary> /// Handles logging in after data has been extracted from Android phone /// </summary> /// <param name="username">Steam username</param> /// <param name="password">Steam password</param> private async void FinishExtract(string username, string password) { long steamTime = await TimeAligner.GetSteamTimeAsync(); Manifest man = Manifest.GetManifest(); //androidAccount.FullyEnrolled = true; UserLogin mUserLogin = new UserLogin(username, password); LoginResult response = LoginResult.BadCredentials; while ((response = mUserLogin.DoLogin()) != LoginResult.LoginOkay) { switch (response) { case LoginResult.NeedEmail: InputForm emailForm = new InputForm("输入发送到你邮箱的验证码:"); emailForm.ShowDialog(); if (emailForm.Canceled) { this.Close(); return; } mUserLogin.EmailCode = emailForm.txtBox.Text; break; case LoginResult.NeedCaptcha: CaptchaForm captchaForm = new CaptchaForm(mUserLogin.CaptchaGID); captchaForm.ShowDialog(); if (captchaForm.Canceled) { this.Close(); return; } mUserLogin.CaptchaText = captchaForm.CaptchaCode; break; // case LoginResult.Need2FA: // mUserLogin.TwoFactorCode = androidAccount.GenerateSteamGuardCodeForTime(steamTime); // break; case LoginResult.BadRSA: MessageBox.Show("错误记录:Steam返回“BadRSA”。", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.BadCredentials: MessageBox.Show("错误记录:用户名或密码不正确。", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.TooManyFailedLogins: MessageBox.Show("错误记录:太多次失败的登录,稍后再试。", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.GeneralFailure: MessageBox.Show("错误记录:Steam返回\"GeneralFailure\".", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } } //androidAccount.Session = mUserLogin.Session; HandleManifest(man); }
private void btnSteamLogin_Click(object sender, EventArgs e) { string username = txtUsername.Text; string password = txtPassword.Text; if (LoginReason == LoginType.Android) { FinishExtract(username, password); return; } else if (LoginReason == LoginType.Refresh) { RefreshLogin(username, password); return; } var userLogin = new UserLogin(username, password); LoginResult response = LoginResult.BadCredentials; while ((response = userLogin.DoLogin()) != LoginResult.LoginOkay) { switch (response) { case LoginResult.NeedEmail: InputForm emailForm = new InputForm("Enter the code sent to your email:"); emailForm.ShowDialog(); if (emailForm.Canceled) { this.Close(); return; } userLogin.EmailCode = emailForm.txtBox.Text; break; case LoginResult.NeedCaptcha: CaptchaForm captchaForm = new CaptchaForm(userLogin.CaptchaGID); captchaForm.ShowDialog(); if (captchaForm.Canceled) { this.Close(); return; } userLogin.CaptchaText = captchaForm.CaptchaCode; break; case LoginResult.Need2FA: MessageBox.Show("This account already has a mobile authenticator linked to it.\nRemove the old authenticator from your Steam account before adding a new one.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.BadRSA: MessageBox.Show("Error logging in: Steam returned \"BadRSA\".", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.BadCredentials: MessageBox.Show("Error logging in: Username or password was incorrect.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.TooManyFailedLogins: MessageBox.Show("Error logging in: Too many failed logins, try again later.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; case LoginResult.GeneralFailure: MessageBox.Show("Error logging in: Steam returned \"GeneralFailure\".", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } } //Login succeeded SessionData session = userLogin.Session; AuthenticatorLinker linker = new AuthenticatorLinker(session); AuthenticatorLinker.LinkResult linkResponse = AuthenticatorLinker.LinkResult.GeneralFailure; while ((linkResponse = linker.AddAuthenticator()) != AuthenticatorLinker.LinkResult.AwaitingFinalization) { switch (linkResponse) { case AuthenticatorLinker.LinkResult.MustProvidePhoneNumber: string phoneNumber = ""; while (!PhoneNumberOkay(phoneNumber)) { InputForm phoneNumberForm = new InputForm("Enter your phone number in the following format: +{cC} phoneNumber. EG, +1 123-456-7890"); phoneNumberForm.txtBox.Text = "+1 "; phoneNumberForm.ShowDialog(); if (phoneNumberForm.Canceled) { this.Close(); return; } phoneNumber = FilterPhoneNumber(phoneNumberForm.txtBox.Text); } linker.PhoneNumber = phoneNumber; break; case AuthenticatorLinker.LinkResult.MustRemovePhoneNumber: linker.PhoneNumber = null; break; case AuthenticatorLinker.LinkResult.GeneralFailure: MessageBox.Show("Error adding your phone number. Steam returned \"GeneralFailure\"."); this.Close(); return; } } Manifest manifest = Manifest.GetManifest(); string passKey = null; if (manifest.Entries.Count == 0) { passKey = manifest.PromptSetupPassKey("Please enter an encryption passkey. Leave blank or hit cancel to not encrypt (VERY INSECURE)."); } else if (manifest.Entries.Count > 0 && manifest.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 = manifest.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; } } } //Save the file immediately; losing this would be bad. if (!manifest.SaveAccount(linker.LinkedAccount, passKey != null, passKey)) { manifest.RemoveAccount(linker.LinkedAccount); MessageBox.Show("Unable to save mobile authenticator file. The mobile authenticator has not been linked."); this.Close(); return; } MessageBox.Show("The Mobile Authenticator has not yet been linked. Before finalizing the authenticator, please write down your revocation code: " + linker.LinkedAccount.RevocationCode); AuthenticatorLinker.FinalizeResult finalizeResponse = AuthenticatorLinker.FinalizeResult.GeneralFailure; while (finalizeResponse != AuthenticatorLinker.FinalizeResult.Success) { InputForm smsCodeForm = new InputForm("Please input the SMS code sent to your phone."); smsCodeForm.ShowDialog(); if (smsCodeForm.Canceled) { manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; } InputForm confirmRevocationCode = new InputForm("Please enter your revocation code to ensure you've saved it."); confirmRevocationCode.ShowDialog(); if (confirmRevocationCode.txtBox.Text.ToUpper() != linker.LinkedAccount.RevocationCode) { MessageBox.Show("Revocation code incorrect; the authenticator has not been linked."); manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; } string smsCode = smsCodeForm.txtBox.Text; finalizeResponse = linker.FinalizeAddAuthenticator(smsCode); switch (finalizeResponse) { case AuthenticatorLinker.FinalizeResult.BadSMSCode: continue; case AuthenticatorLinker.FinalizeResult.UnableToGenerateCorrectCodes: MessageBox.Show("Unable to generate the proper codes to finalize this authenticator. The authenticator should not have been linked. In the off-chance it was, please write down your revocation code, as this is the last chance to see it: " + linker.LinkedAccount.RevocationCode); manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; case AuthenticatorLinker.FinalizeResult.GeneralFailure: MessageBox.Show("Unable to finalize this authenticator. The authenticator should not have been linked. In the off-chance it was, please write down your revocation code, as this is the last chance to see it: " + linker.LinkedAccount.RevocationCode); manifest.RemoveAccount(linker.LinkedAccount); this.Close(); return; } } //Linked, finally. Re-save with FullyEnrolled property. manifest.SaveAccount(linker.LinkedAccount, passKey != null, passKey); MessageBox.Show("Mobile authenticator successfully linked. Please write down your revocation code: " + linker.LinkedAccount.RevocationCode); this.Close(); }
private void menuDeactivateAuthenticator_Click(object sender, EventArgs e) { if (currentAccount == null) return; DialogResult res = MessageBox.Show("Would you like to remove Steam Guard completely?\nYes - Remove Steam Guard completely.\nNo - Switch back to Email authentication.", "Remove Steam Guard", MessageBoxButtons.YesNoCancel); int scheme = 0; if (res == DialogResult.Yes) { scheme = 2; } else if (res == DialogResult.No) { scheme = 1; } else if (res == DialogResult.Cancel) { scheme = 0; } if (scheme != 0) { string confCode = currentAccount.GenerateSteamGuardCode(); InputForm confirmationDialog = new InputForm(String.Format("Removing Steam Guard from {0}. Enter this confirmation code: {1}", currentAccount.AccountName, confCode)); confirmationDialog.ShowDialog(); if (confirmationDialog.Canceled) { return; } string enteredCode = confirmationDialog.txtBox.Text.ToUpper(); if (enteredCode != confCode) { MessageBox.Show("Confirmation codes do not match. Steam Guard not removed."); return; } bool success = currentAccount.DeactivateAuthenticator(scheme); if (success) { MessageBox.Show(String.Format("Steam Guard {0}. maFile will be deleted after hitting okay. If you need to make a backup, now's the time.", (scheme == 2 ? "removed completely" : "switched to emails"))); this.manifest.RemoveAccount(currentAccount); this.loadAccountsList(); } else { MessageBox.Show("Steam Guard failed to deactivate."); } } else { MessageBox.Show("Steam Guard was not removed. No action was taken."); } }