Exemple #1
0
        // _perform_auth_request
        private async Task <Dictionary <string, string> > PerformAuthRequest(Dictionary <string, string> data)
        {
            var nvc = new List <KeyValuePair <string, string> >();

            foreach (var kvp in data)
            {
                nvc.Add(new KeyValuePair <string, string>(kvp.Key.ToString(), kvp.Value.ToString()));
            }

            using (System.Net.Http.HttpClient client = new System.Net.Http.HttpClient())
            {
                client.DefaultRequestHeaders.Add("User-Agent", userAgent);
                string result;
                try
                {
                    var response = await client.PostAsync(authUrl, new FormUrlEncodedContent(nvc));

                    result = await response.Content.ReadAsStringAsync();
                }
                catch (Exception e)
                {
                    result = e.Message;
                }

                return(GoogleKeyUtils.ParseAuthResponse(result));
            }
        }
Exemple #2
0
        // _perform_auth_request
        private Dictionary <string, string> PerformAuthRequest(Dictionary <string, string> data)
        {
            NameValueCollection nvc = new NameValueCollection();

            foreach (var kvp in data)
            {
                nvc.Add(kvp.Key.ToString(), kvp.Value.ToString());
            }
            using (WebClient client = new WebClient()
            {
                Proxy = Proxy
            })
            {
                client.Headers.Add(HttpRequestHeader.UserAgent, userAgent);
                string result;
                try
                {
                    byte[] response = client.UploadValues(authUrl, nvc);
                    result = Encoding.UTF8.GetString(response);
                }
                catch (WebException e)
                {
                    result = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
                }
                return(GoogleKeyUtils.ParseAuthResponse(result));
            }
        }
Exemple #3
0
        // signature
        public static string CreateSignature(string email, string password, RSAParameters key)
        {
            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

            rsa.ImportParameters(key);
            SHA1 sha1 = SHA1.Create();

            byte[] prefix    = { 0x00 };
            byte[] hash      = sha1.ComputeHash(GoogleKeyUtils.KeyToStruct(key)).Take(4).ToArray();
            byte[] encrypted = rsa.Encrypt(Encoding.UTF8.GetBytes(email + "\x00" + password), true);
            return(DataTypeUtils.UrlSafeBase64(DataTypeUtils.CombineBytes(prefix, hash, encrypted)));
        }
Exemple #4
0
        // signature
        public static string CreateSignature(string email, string password, RSAParameters key)
        {
            var rsa       = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithmNames.RsaOaepSha1);
            var keyBlob   = CryptographicBuffer.DecodeFromBase64String(b64KeyBlob);
            var publicKey = rsa.ImportPublicKey(keyBlob, CryptographicPublicKeyBlobType.Capi1PublicKey);

            byte[] prefix = { 0x00 };
            HashAlgorithmProvider hashAlgorithm = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha1);
            var hash = hashAlgorithm.HashData(GoogleKeyUtils.KeyToStruct(key).AsBuffer()).ToArray().Take(4).ToArray();

            byte[] encrypted = CryptographicEngine.Encrypt(publicKey, Encoding.UTF8.GetBytes(email + "\x00" + password).AsBuffer(), null).ToArray();
            return(DataTypeUtils.UrlSafeBase64(DataTypeUtils.CombineBytes(prefix, hash, encrypted)));
        }
Exemple #5
0
        // perform_master_login
        public Dictionary <string, string> PerformMasterLogin(string service       = "ac2dm",
                                                              string deviceCountry = "us", string operatorCountry = "us", string lang = "en", int sdkVersion = 21)
        {
            string signature = GoogleKeyUtils.CreateSignature(email, password, androidKey);
            var    dict      = new Dictionary <string, string> {
                { "accountType", "HOSTED_OR_GOOGLE" },
                { "Email", email },
                { "has_permission", 1.ToString() },
                { "add_account", 1.ToString() },
                { "EncryptedPasswd", signature },
                { "service", service },
                { "source", "android" },
                { "device_country", deviceCountry },
                { "operatorCountry", operatorCountry },
                { "lang", lang },
                { "sdk_version", sdkVersion.ToString() }
            };

            return(PerformAuthRequest(dict));
        }
Exemple #6
0
        // _perform_auth_request
        private Dictionary <string, string> PerformAuthRequest(Dictionary <string, string> data)
        {
            var nvc = new NameValueCollection();

            if (data == null)
            {
                return new Dictionary <string, string> {
                           { "Error", "Data looks like null, are u sure u used Application specific password?" }
                }
            }
            ;
            foreach (var kvp in data)
            {
                nvc.Add(kvp.Key, kvp.Value);
            }
            using (var client = new WebClient()
            {
                Proxy = _proxy
            })
            {
                client.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
                var result = "";
                try
                {
                    var response = client.UploadValues(AuthUrl, nvc);
                    result = Encoding.UTF8.GetString(response);
                }
                catch (WebException e)
                {
                    var resp = e.Response?.GetResponseStream();
                    if (resp != null)
                    {
                        result = new StreamReader(resp).ReadToEnd();
                    }
                }
                return(GoogleKeyUtils.ParseAuthResponse(result));
            }
        }
Exemple #7
0
        // _perform_auth_request
        private async Task <Dictionary <string, string> > PerformAuthRequest(Dictionary <string, string> data)
        {
            var nvc = new List <KeyValuePair <string, string> >();

            foreach (var kvp in data)
            {
                nvc.Add(new KeyValuePair <string, string>(kvp.Key, kvp.Value));
            }

            string result;

            try
            {
                var response = await HttpClient.PostAsync(_authUrl, new FormUrlEncodedContent(nvc));

                result = await response.Content.ReadAsStringAsync();
            }
            catch (Exception e)
            {
                result = e.Message;
            }

            return(GoogleKeyUtils.ParseAuthResponse(result));
        }