Ejemplo n.º 1
0
        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令牌未被删除。 没有采取任何动作。");
            }
        }
Ejemplo n.º 2
0
        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.");
            }
        }
Ejemplo n.º 3
0
 public void DeactivateAuthenticator()
 {
     if (steamGuardAccount == null)
     {
         Console.WriteLine("Unable to unlink mobile authenticator, is it really linked ?");
     }
     else
     {
         steamGuardAccount.DeactivateAuthenticator();
         Console.WriteLine("Done !");
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Unlink selected account
        /// </summary>
        private void unlinkAuthenticator_Click(object sender, EventArgs e)
        {
            if (accountCurrent != null)
            {
                /*We want to confirm the user is unlinking the right account, and not the wrong one by accident*/
                InputForm confirmForm = new InputForm("Enter the username of the account you want to unlink to proceed.");
                confirmForm.ShowDialog();

                if (!confirmForm.inputCancelled)
                {
                    if (confirmForm.inputText.Text.ToLower() == accountCurrent.AccountName.ToLower())
                    {
                        DialogResult dialogResult = MessageBox.Show(string.Format("This action will unlink the authenticator for the account: {0}\n"
                                                                                  + "Are you sure you want to proceed?",
                                                                                  accountCurrent.AccountName),
                                                                    "Confirm selection",
                                                                    MessageBoxButtons.YesNo);

                        if (dialogResult == DialogResult.Yes)
                        {
                            if (accountCurrent.DeactivateAuthenticator())
                            {
                                MessageBox.Show("Authenticator has been unlinked.", "Success");
                                confirmTimer.Stop();
                                Thread.Sleep(1000);

                                FileHandler.DeleteSGAFile(accountCurrent);
                                loadAccounts();
                                confirmTimer.Start();
                            }
                            else
                            {
                                MessageBox.Show("Unable to unlink authenticator. Please try again.", "Error");
                                return;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Confirmation failed", "Boop beep.");
                    }
                }
            }
        }
Ejemplo n.º 5
0
 private void DoUnlink(IUICommand cmd)
 {
     account.DeactivateAuthenticator(async response => {
         if (response)
         {
             account.FullyEnrolled = false;
             Storage.PushStore(account);
             await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 SteamGuardButton_Click(null, null);
             });
         }
         else
         {
             var dialog   = new MessageDialog("Failed to unlink authenticator");
             dialog.Title = "Error";
             dialog.Commands.Add(new UICommand("Ok"));
             await dialog.ShowAsync();
         }
     });
 }
        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.");
            }
        }
Ejemplo n.º 7
0
        static void Setup(string username = "", string passkey = "")
        {
            if (Verbose)
            {
                Console.WriteLine("Opening manifest...");
            }
            Manifest = Manifest.GetManifest(true);

            if (string.IsNullOrWhiteSpace(username))
            {
                Console.Write("Username: "******"Password: "******"Logging in {username}... ");
                LoginResult loginResult = login.DoLogin();
                Console.WriteLine(loginResult);
                if (loginResult == LoginResult.NeedEmail)
                {
                    Console.Write("Email code: ");
                    emailCode = Console.ReadLine();
                    continue;
                }
                else if (loginResult == LoginResult.Need2FA)
                {
                    Console.Write("2FA code: ");
                    twoFactorCode = Console.ReadLine();
                    continue;
                }
                if (!login.LoggedIn)
                {
                    return;
                }
                break;
            }

            AuthenticatorLinker linker = new AuthenticatorLinker(login.Session);

            AuthenticatorLinker.LinkResult linkResult = AuthenticatorLinker.LinkResult.GeneralFailure;

            do
            {
                linkResult = linker.AddAuthenticator();
                Console.WriteLine($"Link result: {linkResult}");
                switch (linkResult)
                {
                case AuthenticatorLinker.LinkResult.MustProvidePhoneNumber:
                    var phonenumber = "";
                    do
                    {
                        Console.WriteLine("Enter your mobile phone number in the following format: +{cC} phoneNumber. EG, +1 123-456-7890");
                        phonenumber        = Console.ReadLine();
                        phonenumber        = FilterPhoneNumber(phonenumber);
                        linker.PhoneNumber = phonenumber;
                    } while (!PhoneNumberOkay(phonenumber));
                    break;

                case AuthenticatorLinker.LinkResult.MustRemovePhoneNumber:
                    linker.PhoneNumber = null;
                    break;

                case AuthenticatorLinker.LinkResult.AwaitingFinalization:
                    break;

                case AuthenticatorLinker.LinkResult.GeneralFailure:
                    Console.WriteLine("error: Unable to add your phone number. Steam returned GeneralFailure");
                    return;

                case AuthenticatorLinker.LinkResult.AuthenticatorPresent:
                    Console.WriteLine("An authenticator is already present.");
                    Console.WriteLine("If you have the revocation code (Rxxxxx), this program can remove it for you.");
                    Console.Write("Would you like to remove the current authenticator using your revocation code? (y/n) ");
                    var answer = Console.ReadLine();
                    if (answer != "y")
                    {
                        continue;
                    }
                    Console.Write("Revocation code (Rxxxxx): ");
                    var revocationCode = Console.ReadLine();
                    var account        = new SteamGuardAccount();
                    account.Session        = login.Session;
                    account.RevocationCode = revocationCode;
                    if (account.DeactivateAuthenticator())
                    {
                        Console.WriteLine("Successfully deactivated the current authenticator.");
                    }
                    else
                    {
                        Console.WriteLine("Deactivating the current authenticator was unsuccessful.");
                    }
                    continue;

                default:
                    Console.WriteLine($"error: Unexpected linker result: {linkResult}");
                    return;
                }
            } while (linkResult != AuthenticatorLinker.LinkResult.AwaitingFinalization);

            string passKey = null;

            if (Manifest.Entries.Count == 0)
            {
                Console.WriteLine("Looks like we are setting up your first account.");
                passKey = Manifest.PromptSetupPassKey(true);
            }
            else if (Manifest.Entries.Count > 0 && Manifest.Encrypted)
            {
                if (string.IsNullOrEmpty(passkey))
                {
                    passkey = Manifest.PromptForPassKey();
                }
            }

            //Save the file immediately; losing this would be bad.
            if (!Manifest.SaveAccount(linker.LinkedAccount, passKey != null, passKey))
            {
                Manifest.RemoveAccount(linker.LinkedAccount);
                Console.WriteLine("Unable to save mobile authenticator file. The mobile authenticator has not been linked.");
                return;
            }

            Console.WriteLine(
                $"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;
            do
            {
                Console.Write("Please input the SMS message sent to your phone number: ");
                string smsCode = Console.ReadLine();

                finalizeResponse = linker.FinalizeAddAuthenticator(smsCode);
                if (Verbose)
                {
                    Console.WriteLine(finalizeResponse);
                }

                switch (finalizeResponse)
                {
                case AuthenticatorLinker.FinalizeResult.BadSMSCode:
                    continue;

                case AuthenticatorLinker.FinalizeResult.UnableToGenerateCorrectCodes:
                    Console.WriteLine(
                        "Unable to generate the proper codes to finalize this authenticator. The authenticator should not have been linked.");
                    Console.WriteLine(
                        $"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);
                    return;

                case AuthenticatorLinker.FinalizeResult.GeneralFailure:
                    Console.WriteLine("Unable to finalize this authenticator. The authenticator should not have been linked.");
                    Console.WriteLine(
                        $"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);
                    return;
                }
            } while (finalizeResponse != AuthenticatorLinker.FinalizeResult.Success);

            //Linked, finally. Re-save with FullyEnrolled property.
            Manifest.SaveAccount(linker.LinkedAccount, passKey != null, passKey);
            Console.WriteLine(
                $"Mobile authenticator successfully linked. Please actually write down your revocation code: {linker.LinkedAccount.RevocationCode}");
        }