Пример #1
0
        protected override void _UpdateStats()
        {
            try
            {
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                pairs.Add(new KeyValuePair <string, string>("token", accesstoken));

                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string    sEmitResponse       = Client.PostAsync("balance.php", Content).Result.Content.ReadAsStringAsync().Result;
                KDBalance tmpbal = json.JsonDeserialize <KDBalance>(sEmitResponse);
                if (tmpbal.code == "SUCCESS")
                {
                    pairs = new List <KeyValuePair <string, string> >();
                    pairs.Add(new KeyValuePair <string, string>("username", username));
                    pairs.Add(new KeyValuePair <string, string>("token", accesstoken));
                    Content       = new FormUrlEncodedContent(pairs);
                    sEmitResponse = Client.PostAsync("stats/profile.php", Content).Result.Content.ReadAsStringAsync().Result;
                    KDStat tmpstats = json.JsonDeserialize <KDStat>(sEmitResponse);
                    Stats.Wagered = tmpstats.wagered / 100000000m;
                    Stats.Profit  = tmpstats.profit / 100000000m;
                    Stats.Bets    = (int)tmpstats.rolls;
                    Stats.Balance = tmpbal.balance / 100000000m;
                }
            }
            catch (Exception e)
            {
                Logger.DumpLog(e);
            }
        }
Пример #2
0
        protected override void _Login(LoginParamValue[] LoginParams)
        {
            string Username = "";
            string Password = "";
            string otp      = "";

            foreach (LoginParamValue x in LoginParams)
            {
                if (x.Param.Name.ToLower() == "username")
                {
                    Username = x.Value;
                }
                if (x.Param.Name.ToLower() == "password")
                {
                    Password = x.Value;
                }
                if (x.Param.Name.ToLower() == "2fa code")
                {
                    otp = x.Value;
                }
            }
            ClientHandlr = new HttpClientHandler {
                UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
            };
            Client = new HttpClient(ClientHandlr)
            {
                BaseAddress = new Uri("https://kingdice.com/api/")
            };
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));
            Client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0");
            Client.DefaultRequestHeaders.Add("Host", "kingdice.com");
            Client.DefaultRequestHeaders.Add("Origin", "https://kingdice.com");
            Client.DefaultRequestHeaders.Add("Referer", "https://kingdice.com");

            try
            {
                this.username = Username;
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                pairs.Add(new KeyValuePair <string, string>("username", Username));
                pairs.Add(new KeyValuePair <string, string>("password", Password));
                pairs.Add(new KeyValuePair <string, string>("sdb", "8043d46408307f3ac9d14931ba27c9015349bf21b7b7"));
                pairs.Add(new KeyValuePair <string, string>("2facode", otp /*==""?"undefined":twofa*/));
                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string sEmitResponse          = Client.PostAsync("login.php", Content).Result.Content.ReadAsStringAsync().Result;

                KDLogin tmplogin = json.JsonDeserialize <KDLogin>(sEmitResponse);
                if (tmplogin.code == "SUCCESS")
                {
                    accesstoken = tmplogin.token;
                    pairs       = new List <KeyValuePair <string, string> >();
                    pairs.Add(new KeyValuePair <string, string>("token", accesstoken));
                    Content       = new FormUrlEncodedContent(pairs);
                    sEmitResponse = Client.PostAsync("logged.php", Content).Result.Content.ReadAsStringAsync().Result;
                    //sEmitResponse2 = Client.GetStringAsync("logged.php").Result;
                    KDLoggedIn tmpStats = json.JsonDeserialize <KDLoggedIn>(sEmitResponse);
                    if (tmpStats.code == "SUCCESS")
                    {
                        Stats.Balance = tmpStats.balance / 100000000m;

                        pairs = new List <KeyValuePair <string, string> >();
                        pairs.Add(new KeyValuePair <string, string>("token", accesstoken));
                        Content       = new FormUrlEncodedContent(pairs);
                        sEmitResponse = Client.PostAsync("nextroll.php", Content).Result.Content.ReadAsStringAsync().Result;
                        KDNextRoll tmphash = json.JsonDeserialize <KDNextRoll>(sEmitResponse);
                        if (tmphash.code == "SUCCESS")
                        {
                            LastHash = tmphash.round_hash;
                            pairs    = new List <KeyValuePair <string, string> >();
                            pairs.Add(new KeyValuePair <string, string>("username", username));
                            pairs.Add(new KeyValuePair <string, string>("token", accesstoken));
                            Content       = new FormUrlEncodedContent(pairs);
                            sEmitResponse = Client.PostAsync("stats/profile.php", Content).Result.Content.ReadAsStringAsync().Result;
                            KDStat tmpstats = json.JsonDeserialize <KDStat>(sEmitResponse);
                            Stats.Wagered = tmpstats.wagered / 100000000m;
                            Stats.Profit  = tmpstats.profit / 100000000m;
                            Stats.Bets    = (int)tmpstats.rolls;
                            iskd          = true;
                            Thread t = new Thread(GetBalanceThread);
                            t.Start();

                            callLoginFinished(true);
                            return;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.DumpLog(e.ToString(), 1);
            }
            callLoginFinished(false);
        }