Пример #1
0
        public string EncryptPassword(RsaParameters rsaParam)
        {
            // Convert the public keys to BigIntegers
            var modulus  = CreateBigInteger(rsaParam.Modulus);
            var exponent = CreateBigInteger(rsaParam.Exponent);

            // (modulus.ToByteArray().Length - 1) * 8
            //modulus has 256 bytes multiplied by 8 bits equals 2048
            var encryptedNumber = Pkcs1Pad2(rsaParam.Password, (2048 + 7) >> 3);

            // And now, the RSA encryption
            encryptedNumber = BigInteger.ModPow(encryptedNumber, exponent, modulus);

            //Reverse number and convert to base64
            var encryptedString = Convert.ToBase64String(encryptedNumber.ToByteArray().Reverse().ToArray());

            return(encryptedString);
        }
Пример #2
0
        public async Task <bool> WithLogPass(string password, string login, string code)
        {
            //Первый запрос стиму
            request = await client.GetAsync($"https://steamcommunity.com/login/getrsakey?username="******"==")
            {
                //RSA шифрование пароля
                encrypted = EncryptPassword(rsaParam);
            }

            //Создание и заполнение библиотеки для отправки в следующем запросе
            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("username", login);
            data.Add("password", encrypted);
            data.Add("twofactorcode", code);
            data.Add("emailauth", "");
            data.Add("loginfriendlyname", "");
            data.Add("captchagid", "-1");
            data.Add("captcha_text", "");
            data.Add("emailsteamid", "");
            data.Add("rsatimestamp", rsaKey.timestamp);
            data.Add("remember_login", "true");

            //Отправка 2го запроса с нужными данными
            request = await client.PostAsync($"https://steamcommunity.com/login/dologin/", new FormUrlEncodedContent(data));

            //Ответ
            result = await request.Content.ReadAsStringAsync();

            //Достаём результаты авторизации
            LoginResult loginResult = JsonConvert.DeserializeObject <LoginResult>(result);

            //Проверка флага авторизации в результатах
            if (loginResult.success)
            {
                //Вытаскиваем нужные нам Печеньки
                IEnumerable <Cookie> responseCookies = cookieContainer.GetCookies(new Uri("https://steamcommunity.com/login/dologin")).Cast <Cookie>();

                //Чистим список старых пеенек
                cookieList.Clear();

                Cookie tmp;

                //Перебираем данные полученных печенек и пихаем их в список
                foreach (var cookie in responseCookies)
                {
                    tmp            = new Cookie();
                    tmp.Comment    = cookie.Comment;
                    tmp.CommentUri = cookie.CommentUri;
                    tmp.HttpOnly   = cookie.HttpOnly;
                    tmp.Discard    = cookie.Discard;
                    tmp.Domain     = cookie.Domain;
                    tmp.Expired    = cookie.Expired;
                    tmp.Expires    = cookie.Expires;
                    tmp.Name       = cookie.Name;
                    tmp.Path       = cookie.Path;
                    tmp.Port       = cookie.Port;
                    tmp.Secure     = cookie.Secure;
                    tmp.Value      = cookie.Value;
                    tmp.Version    = cookie.Version;
                    cookieList.Add(tmp);
                }

                Console.WriteLine("Successfully logged in.");
                Console.WriteLine(result);

                //Сохраняем полученные Печеньки в json
                File.WriteAllText("Cookes.json", JsonConvert.SerializeObject(cookieList, Formatting.Indented));

                return(true);
            }
            else
            {
                //Вывод сообщения о работе



                Console.WriteLine("Couldn't login...");
                Console.WriteLine(result);
                return(false);
            }
        }