Esempio n. 1
0
        private NameValueCollection BuildPostData(string encryptedPassword, string timestamp)
        {
            NameValueCollection postData = new NameValueCollection();

            postData.Add("username", username);
            postData.Add("password", encryptedPassword);

            postData.Add("twofactorcode", twoFactorCode ?? "");

            postData.Add("captchagid", requiresCaptcha ? CaptchaID : "-1");
            postData.Add("captcha_text", requiresCaptcha ? CaptchaText : "");

            postData.Add("emailsteamid", (requires2FA || requiresEmail) ? steamID.ToString() : "");
            postData.Add("emailauth", requiresEmail ? EmailCode : "");

            postData.Add("rsatimestamp", timestamp);
            postData.Add("remember_login", "false");
            postData.Add("oauth_client_id", "DE45CD61");
            postData.Add("oauth_scope", "read_profile write_profile read_client write_client");
            postData.Add("loginfriendlyname", "#login_emailauth_friendlyname_mobile");
            postData.Add("donotcache", SteamTimeSyncHelper.GetSystemUnixTime().ToString());
            return(postData);
        }
Esempio n. 2
0
 public string GenerateSteamGuardCode()
 {
     return(GenerateSteamGuardCodeForTime(SteamTimeSyncHelper.GetSteamUnixTime()));
 }
Esempio n. 3
0
        public async Task <SteamGuardServiceResponse> SubmitSMSCode(string code)
        {
            var postData = new NameValueCollection();

            postData.Add("steamid", _steamSession.SteamID.ToString());
            postData.Add("access_token", _steamSession.OAuthToken);
            postData.Add("activation_code", code);
            int tries = 0;

            while (tries <= 30)
            {
                postData.Set("authenticator_code", _steamGuardData.GenerateSteamGuardCode());
                postData.Set("authenticator_time", SteamTimeSyncHelper.GetSteamUnixTime().ToString());

                string response = await SteamWebHelper.MobileLoginRequest(SteamAPIEndpoints.STEAMAPI_BASE + "/ITwoFactorService/FinalizeAddAuthenticator/v0001", "POST", postData);

                if (response == null)
                {
                    Error = SteamGuardServiceError.EmptyResponse;
                    return(SteamGuardServiceResponse.Error);
                }

                var finalizeResponse = JsonConvert.DeserializeObject <FinalizeAuthenticatorResponse>(response);

                if (finalizeResponse == null || finalizeResponse.Response == null)
                {
                    Error = SteamGuardServiceError.CorruptResponse;
                    return(SteamGuardServiceResponse.Error);
                }

                if (finalizeResponse.Response.Status == 89)
                {
                    return(SteamGuardServiceResponse.WrongSMSCode);
                }

                if (finalizeResponse.Response.Status == 88)
                {
                    if (tries >= 30)
                    {
                        Error = SteamGuardServiceError.GuardSyncFailed;
                        return(SteamGuardServiceResponse.Error);
                    }
                }

                if (!finalizeResponse.Response.Success)
                {
                    Error = SteamGuardServiceError.SuccessMissing;
                    return(SteamGuardServiceResponse.Error);
                }

                if (finalizeResponse.Response.WantMore)
                {
                    tries++;
                    continue;
                }

                return(SteamGuardServiceResponse.Okay);
            }

            Error = SteamGuardServiceError.General;
            return(SteamGuardServiceResponse.Error);
        }