Example #1
0
        public void LoginProgress(object sender, DoWorkEventArgs e)
        {
            LoginProcess = true;
            Logged       = false;

            var accInfo = SteamParseSite.GetNameBalance(cookieCont);

            if (accInfo != null)
            {
                doMessage(flag.Already_logged, 0, accInfo, true);
                LoginProcess = false;
                Logged       = true;
                return;
            }

            string mailCode  = string.Empty;
            string guardDesc = string.Empty;
            string capchaId  = string.Empty;
            string capchaTxt = string.Empty;
            string mailId    = string.Empty;

            //Login cycle
begin:

            var rRSA = GetRSA("toshigawa_tori", cookieCont);

            if (rRSA == null)
            {
                SteamLibrary.AddtoLog("Network Problem");
                doMessage(flag.Login_cancel, 0, "Network Problem", true);
                LoginProcess = false;
                return;
            }

            string finalpass = SteamLibrary.EncryptPassword(Password, rRSA.Module, rRSA.Exponent);

            string MainReq = string.Format(SteamLibrary.loginReq, finalpass, UserName, mailCode, guardDesc, capchaId,
                                           capchaTxt, mailId, rRSA.TimeStamp);

            string BodyResp = SteamParsing.SendPost(MainReq, SteamLibrary._dologin, SteamLibrary._ref, cookieCont, true);

            //Checking login problem
            if (BodyResp.Contains("message"))
            {
                var rProcess = JsonConvert.DeserializeObject <SteamLibrary.RespProcess>(BodyResp);

                //Checking Incorrect Login
                if (rProcess.Message.Contains("Incorrect"))
                {
                    SteamLibrary.AddtoLog("Incorrect login");
                    doMessage(flag.Login_cancel, 0, "Incorrect login", true);
                    LoginProcess = false;
                    return;
                }
                else
                {
                    //Login correct, checking message type...
                    Dialog guardCheckForm = new Dialog();

                    if ((rProcess.isCaptcha) && (rProcess.Message.Contains("humanity")))
                    {
                        //Verifying humanity, loading capcha
                        guardCheckForm.capchgroupEnab = true;
                        guardCheckForm.codgroupEnab   = false;

                        string newcap = SteamLibrary._capcha + rProcess.Captcha_Id;
                        SteamParsing.SteamSite.loadImg(newcap, guardCheckForm.capchImg, false, false);
                    }
                    else
                    if (rProcess.isEmail)
                    {
                        //Steam guard wants email code
                        guardCheckForm.capchgroupEnab = false;
                        guardCheckForm.codgroupEnab   = true;
                    }
                    else
                    {
                        //Whoops!
                        goto begin;
                    }

                    //Re-assign main request values
                    if (guardCheckForm.ShowDialog() == DialogResult.OK)
                    {
                        mailCode  = guardCheckForm.MailCode;
                        guardDesc = guardCheckForm.GuardDesc;
                        capchaId  = rProcess.Captcha_Id;
                        capchaTxt = guardCheckForm.capchaText;
                        mailId    = rProcess.Email_Id;
                        guardCheckForm.Dispose();
                    }
                    else
                    {
                        SteamLibrary.AddtoLog("Dialog has been cancelled!");
                        doMessage(flag.Login_cancel, 0, "Dialog has been cancelled!", true);
                        e.Cancel     = true;
                        Logged       = false;
                        LoginProcess = false;
                        guardCheckForm.Dispose();
                        return;
                    }

                    goto begin;
                }
            }
            else
            {
                //No Messages, Success!
                var rFinal = JsonConvert.DeserializeObject <SteamLibrary.RespFinal>(BodyResp);

                if (rFinal.Success && rFinal.isComplete)
                {
                    //Okay
                    var accInfo2 = SteamParseSite.GetNameBalance(cookieCont);

                    doMessage(flag.Login_success, 0, accInfo2, true);

                    Logged = true;
                    SteamLibrary.AddtoLog("Login Success");
                }
                else
                {
                    //Fail
                    goto begin;
                }
            }

            LoginProcess = false;
        }