Esempio n. 1
0
        private async Task <RSAResponse> GetRSAResponse(CookieContainer cookieContainer)
        {
            NameValueCollection postData = new NameValueCollection();

            postData.Add("username", username);
            string response = await SteamWebHelper.MobileLoginRequest(SteamAPIEndpoints.COMMUNITY_BASE + "/login/getrsakey", "POST", postData, cookieContainer);

            return(JsonConvert.DeserializeObject <RSAResponse>(response));
        }
Esempio n. 2
0
        public async void RequestSMSCode()
        {
            // adding a phone to Steam should not be handled by Bitwarden
            bool hasPhone = await HasPhoneAttached();

            if (!hasPhone)
            {
                throw new Exception("USER HAS TO APPEND A PHONE NUMBER");
            }


            var postData = new NameValueCollection();

            postData.Add("access_token", _steamSession.OAuthToken);
            postData.Add("steamid", _steamSession.SteamID.ToString());
            postData.Add("authenticator_type", "1");
            postData.Add("device_identifier", _steamGuardData.DeviceID);
            postData.Add("sms_phone_id", "1");

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

            if (response == null)
            {
                throw new Exception("GENERAL EXCEPTION");
            }

            var addAuthenticatorResponse = JsonConvert.DeserializeObject <AddAuthenticatorResponse>(response);

            if (addAuthenticatorResponse == null || addAuthenticatorResponse.Response == null)
            {
                throw new Exception("GENERAL EXCEPTION");
            }

            if (addAuthenticatorResponse.Response.Status == 29)
            {
                throw new Exception("ALLREADY LINKED TO STEAM AUTHENTICATOR");
            }

            if (addAuthenticatorResponse.Response.Status != 1)
            {
                throw new Exception("GENERAL EXCEPTION");
            }

            _steamGuardData = addAuthenticatorResponse.Response;
        }
Esempio n. 3
0
        private async Task <bool> HasPhoneAttached()
        {
            var postData = new NameValueCollection();

            postData.Add("op", "has_phone");
            postData.Add("arg", "null");
            postData.Add("sessionid", _steamSession.SessionID);

            CookieContainer cookieContainer = new CookieContainer();

            cookieContainer.Add(new Cookie("mobileClientVersion", "0 (2.1.3)", "/", ".steamcommunity.com"));
            cookieContainer.Add(new Cookie("mobileClient", "android", "/", ".steamcommunity.com"));

            cookieContainer.Add(new Cookie("steamid", _steamSession.SteamID.ToString(), "/", ".steamcommunity.com"));
            cookieContainer.Add(new Cookie("steamLogin", _steamSession.SteamLogin, "/", ".steamcommunity.com")
            {
                HttpOnly = true
            });

            cookieContainer.Add(new Cookie("steamLoginSecure", _steamSession.SteamLoginSecure, "/", ".steamcommunity.com")
            {
                HttpOnly = true,
                Secure   = true
            });
            cookieContainer.Add(new Cookie("Steam_Language", "english", "/", ".steamcommunity.com"));
            cookieContainer.Add(new Cookie("dob", "", "/", ".steamcommunity.com"));
            cookieContainer.Add(new Cookie("sessionid", _steamSession.SessionID, "/", ".steamcommunity.com"));

            string response = await SteamWebHelper.Request(SteamAPIEndpoints.COMMUNITY_BASE + "/steamguard/phoneajax", "POST", postData, cookieContainer);

            if (response == null)
            {
                return(false);
            }

            var hasPhoneResponse = JsonConvert.DeserializeObject <HasPhoneResponse>(response);

            return(hasPhoneResponse.HasPhone);
        }
Esempio n. 4
0
        public async Task <(Status, SteamSession)> TryCreateSession()
        {
            CookieContainer cookieContainer = new CookieContainer();

            cookieContainer.Add(new Cookie("mobileClientVersion", "0 (2.1.3)", "/", ".steamcommunity.com"));
            cookieContainer.Add(new Cookie("mobileClient", "android", "/", ".steamcommunity.com"));
            cookieContainer.Add(new Cookie("Steam_Language", "english", "/", ".steamcommunity.com"));

            NameValueCollection headers = new NameValueCollection();

            headers.Add("X-Requested-With", "com.valvesoftware.android.steam.community");

            await SteamWebHelper.MobileLoginRequest(@"https://steamcommunity.com/login?oauth_client_id=DE45CD61&oauth_scope=read_profile%20write_profile%20read_client%20write_client", "GET", null, cookieContainer, headers);

            RSAResponse rsaResponse = await GetRSAResponse(cookieContainer);

            if (!rsaResponse.Success)
            {
                return(Status.BadRSA, null);
            }

            string encryptedPassword = EncryptPassword(rsaResponse.Exponent, rsaResponse.Modulus);

            NameValueCollection postData = BuildPostData(encryptedPassword, rsaResponse.Timestamp);

            string response = await SteamWebHelper.MobileLoginRequest(SteamAPIEndpoints.COMMUNITY_BASE + "/login/dologin", "POST", postData, cookieContainer);

            if (response == null)
            {
                return(Status.Error_EmptyResponse, null);
            }

            var loginResponse = JsonConvert.DeserializeObject <LoginResponse>(response);

            return(EvaluateLoginResponse(loginResponse, cookieContainer));
        }
Esempio n. 5
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);
        }