Esempio n. 1
0
        private async void SubmitPhoneChallengeButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtSubmitPhoneForChallenge.Text) ||
                    string.IsNullOrWhiteSpace(txtSubmitPhoneForChallenge.Text))
                {
                    MessageBox.Show("Please type a valid phone number(with country code).\r\ni.e: +989123456789", "ERR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                var phoneNumber = txtSubmitPhoneForChallenge.Text;
                if (!phoneNumber.StartsWith("+"))
                {
                    phoneNumber = $"+{phoneNumber}";
                }

                var submitPhone = await InstaApi.SubmitPhoneNumberForChallengeRequireAsync(phoneNumber);

                if (submitPhone.Succeeded)
                {
                    VerifyCodeGroupBox.Visible        = true;
                    SubmitPhoneChallengeGroup.Visible = false;
                }
                else
                {
                    MessageBox.Show(submitPhone.Info.Message, "ERR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "EX", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Esempio n. 2
0
        private async void submitPhoneButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(submitPhoneTextBox.Text) ||
                    string.IsNullOrWhiteSpace(submitPhoneTextBox.Text))
                {
                    MessageBox.Show("Please type a valid phone number(with country code).\r\ni.e: +380996664422", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                var phoneNumber = submitPhoneTextBox.Text;
                if (!phoneNumber.StartsWith("+"))
                {
                    phoneNumber = $"+{phoneNumber}";
                }

                var submitPhone = await instaApi.SubmitPhoneNumberForChallengeRequireAsync(phoneNumber);

                if (submitPhone.Succeeded)
                {
                    smsEmailCodePanel.Enabled      = true;
                    smsEmailCodePanel.Visible      = true;
                    submitPhoneNumberPanel.Enabled = false;
                    submitPhoneNumberPanel.Visible = false;
                }
                else
                {
                    MessageBox.Show(submitPhone.Info.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "EX", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
        /// <summary>
        /// Hesap için telefon numarası girme
        /// </summary>
        private async void Button_Insta_TelefonGir_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(textBox_Insta_TelefonGir.Text) ||
                    string.IsNullOrWhiteSpace(textBox_Insta_TelefonGir.Text))
                {
                    BilgiMesaji("hata", "Lütfen geçerli bir telefon numarası girin.\r\ni.e:+989123456789", this.Text, true);
                    return;
                }
                var phoneNumber = textBox_Insta_TelefonGir.Text;
                if (!phoneNumber.StartsWith("+"))
                {
                    phoneNumber = $"+{phoneNumber}";
                }

                var submitPhone = await InstaApi.SubmitPhoneNumberForChallengeRequireAsync(phoneNumber);

                if (submitPhone.Succeeded)
                {
                    group_Insta_TelefonGirme.Visible = false;
                    group_Insta_KodDogrulama.Dock    = DockStyle.Fill;
                    group_Insta_KodDogrulama.Visible = true;
                }
                else
                {
                    if (submitPhone.Info.Message.IndexOf("like your phone number may be incorrect") != -1)
                    {
                        BilgiMesaji("hata", "Telefon numarası hatalı. Ülke kodu ile girin.", this.Text, true);
                    }
                    else
                    {
                        BilgiMesaji("hata", submitPhone.Info.Message, this.Text, true);
                    }
                }
            }
            catch (Exception ex)
            {
                BilgiMesaji("hata", "Hata: " + ex.Message, this.Text, true);
            }
        }
Esempio n. 4
0
        private async Task GetChallenge()
        {
            var currentUser = await InstaApi.LoginAsync();

            if (currentUser.Succeeded)
            {
                SaveSession();
            }
            else
            {
                if (currentUser.Value == InstaLoginResult.ChallengeRequired)
                {
                    var challenge = await InstaApi.GetChallengeRequireVerifyMethodAsync();

                    if (challenge.Succeeded)
                    {
                        if (challenge.Value.SubmitPhoneRequired)
                        {
                            Console.WriteLine("Please type a valid phone number(with country code).\r\ni.e: +989123456789");
                            string phoneNumber = Console.ReadLine();
                            if (!phoneNumber.StartsWith("+"))
                            {
                                phoneNumber = $"+{phoneNumber}";
                            }
                            var submitPhone = await InstaApi.SubmitPhoneNumberForChallengeRequireAsync(phoneNumber);

                            if (submitPhone.Succeeded)
                            {
                                try
                                {
                                    var phoneResult = await InstaApi.RequestVerifyCodeToSMSForChallengeRequireAsync();

                                    if (phoneResult.Succeeded)
                                    {
                                        Console.WriteLine("We sent verify code to this phone number(it's end with this):\n" + phoneResult.Value.StepData.ContactPoint);
                                        await VerifyData();
                                    }
                                    else
                                    {
                                        Console.WriteLine(phoneResult.Info.Message, "ERROR");
                                    }
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Error while trying get challenge from phone number");
                                    throw;
                                }
                            }
                            else
                            {
                                Console.WriteLine("Error while trying get challenge from phone");
                            }
                        }
                        else
                        {
                            try
                            {
                                var email = await InstaApi.RequestVerifyCodeToEmailForChallengeRequireAsync();

                                if (email.Succeeded)
                                {
                                    Console.WriteLine($"We sent verify code to this email:\n{email.Value.StepData.ContactPoint}");
                                    await VerifyData();
                                }
                                else
                                {
                                    Console.WriteLine("Error while trying get challenge from email");
                                }
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("Exception while trying get challenge from email");
                                throw;
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error while trying get challenge");
                    }
                }
                else if (currentUser.Value == InstaLoginResult.TwoFactorRequired)
                {
                    await TwoFactorAuth();
                }
            }
        }
Esempio n. 5
0
        //  Deprecated //

        /*
         * private void RunChallenge()
         * {
         *  Console.WriteLine("Starting chalange auth...");
         *  if (proxydata.host!=null)
         *  {
         *      Console.WriteLine("Using proxy...");
         *      var p = new System.Diagnostics.Process();
         *      p.StartInfo.FileName = "ChallengeRequire.exe";
         *      p.StartInfo.Arguments = userSession.UserName +" " + userSession.Password +" "+ proxydata.host +" "+ proxydata.port +" "+ proxydata.username +" "+ proxydata.password;
         *      p.StartInfo.RedirectStandardOutput = true;
         *      p.StartInfo.UseShellExecute = false;
         *      p.StartInfo.CreateNoWindow = true;
         *      p.Start();
         *  }
         *  else
         *  {
         *      var p = new System.Diagnostics.Process();
         *      p.StartInfo.FileName = "ChallengeRequire.exe";
         *      p.StartInfo.Arguments = userSession.UserName + " " + userSession.Password;
         *      p.StartInfo.RedirectStandardOutput = true;
         *      p.StartInfo.UseShellExecute = false;
         *      p.StartInfo.CreateNoWindow = true;
         *      p.Start();
         *  }
         *  Console.WriteLine("Press 1 if challenge is created");
         *  Console.WriteLine("Press 2 to exit");
         *
         *  var key = Console.ReadLine();
         *  Console.WriteLine(Environment.NewLine);
         *  int answer = Convert.ToInt32(key);
         *  if (answer != 1)
         *  {
         *      Console.WriteLine("Error");
         *      return;
         *  }
         * }
         */

        private async Task GetChallenge()
        {
            var currentUser = await InstaApi.LoginAsync();

            if (currentUser.Succeeded)
            {
                SaveSession();
            }
            else
            {
                if (currentUser.Value == InstaLoginResult.ChallengeRequired)
                {
                    var challenge = await InstaApi.GetChallengeRequireVerifyMethodAsync();

                    if (challenge.Succeeded)
                    {
                        if (challenge.Value.SubmitPhoneRequired)
                        {
                            Console.WriteLine("Please type a valid phone number(with country code).\r\ni.e: +989123456789");
                            string phoneNumber = Console.ReadLine();
                            if (!phoneNumber.StartsWith("+"))
                            {
                                phoneNumber = $"+{phoneNumber}";
                            }
                            var submitPhone = await InstaApi.SubmitPhoneNumberForChallengeRequireAsync(phoneNumber);

                            if (submitPhone.Succeeded)
                            {
                                try
                                {
                                    var phoneResult = await InstaApi.RequestVerifyCodeToSMSForChallengeRequireAsync();

                                    if (phoneResult.Succeeded)
                                    {
                                        Console.WriteLine("We sent verify code to this phone number(it's end with this):\n" + phoneResult.Value.StepData.ContactPoint);
                                        await VerifyData();
                                    }
                                    else
                                    {
                                        Console.WriteLine(ErrorsContract.ACC_CH_PHONE_CONFIRM + phoneResult.Info.Message);
                                        ExceptionUtils.Throw(Error.E_CHALLENGE, ErrorsContract.ACC_CH_PHONE_CONFIRM + phoneResult.Info.Message);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ErrorsContract.ACC_CH_PHONE_ERROR + ex);
                                    ExceptionUtils.Throw(Error.E_CHALLENGE, ErrorsContract.ACC_CH_PHONE_ERROR + ex.Message);
                                }
                            }
                            else
                            {
                                Console.WriteLine(ErrorsContract.ACC_CH_PHONE_ERROR + submitPhone.Info.Message);
                                ExceptionUtils.Throw(Error.E_CHALLENGE, ErrorsContract.ACC_CH_PHONE_ERROR + submitPhone.Info.Message);
                            }
                        }
                        else
                        {
                            try
                            {
                                var email = await InstaApi.RequestVerifyCodeToEmailForChallengeRequireAsync();

                                if (email.Succeeded)
                                {
                                    Console.WriteLine($"We sent verify code to this email:\n{email.Value.StepData.ContactPoint}");
                                    await VerifyData();
                                }
                                else
                                {
                                    Console.WriteLine(ErrorsContract.ACC_CH_EMAIL_CONFIRM_CODE + email.Info.Message);
                                    ExceptionUtils.Throw(Error.E_CHALLENGE, ErrorsContract.ACC_CH_EMAIL_CONFIRM_CODE + email.Info.Message);
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ErrorsContract.ACC_CH_EMAIL_CONFIRM_EX + ex);
                                ExceptionUtils.Throw(Error.E_CHALLENGE, ErrorsContract.ACC_CH_EMAIL_CONFIRM_EX + ex.Message);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine(ErrorsContract.ACC_CH_EMAIL_CONFIRM_FAIL);
                        ExceptionUtils.Throw(Error.E_CHALLENGE, ErrorsContract.ACC_CH_EMAIL_CONFIRM_FAIL);
                    }
                }
                else if (currentUser.Value == InstaLoginResult.TwoFactorRequired)
                {
                    await TwoFactorAuth();
                }
            }
        }