Пример #1
0
        void GetStats()
        {
            HttpResponseMessage Msg = Client.GetAsync("https://betking.io/socket-api/stats/my-stats").Result;

            if (Msg.IsSuccessStatusCode)
            {
                string Response = Msg.Content.ReadAsStringAsync().Result;

                BKStat[] tmp = json.JsonDeserialize <BKStat[]>(Response);
                foreach (BKStat x in tmp)
                {
                    foreach (BKCurrency y in Currs.currencies)
                    {
                        if (CurrentCurrency.id == x.currency && CurrentCurrency.symbol.ToLower() == Currency.ToLower())
                        {
                            this.profit  = decimal.Parse(x.profit, System.Globalization.NumberFormatInfo.InvariantInfo) / (decimal)CurrentCurrency.EffectiveScale;
                            this.bets    = int.Parse(x.num_bets, System.Globalization.NumberFormatInfo.InvariantInfo);
                            this.wagered = decimal.Parse(x.wagered, System.Globalization.NumberFormatInfo.InvariantInfo) / (decimal)CurrentCurrency.EffectiveScale;
                        }
                    }
                }
                string      LoadState = Client.GetStringAsync("api/dice/load-state?clientSeed=" + R.Next(0, int.MaxValue) + "&currency=0").Result;
                bkLoadSTate TmpState  = json.JsonDeserialize <bkLoadSTate>(LoadState);
                nonce          = TmpState.nonce;
                clientseed     = TmpState.clientSeed;
                serverseedhash = TmpState.serverSeedHash;


                Parent.updateProfit(profit);
                Parent.updateBets(bets);
                Parent.updateWagered(wagered);
                Parent.updateWins(wins);
                Parent.updateLosses(losses);
            }
        }
Пример #2
0
        public override void Login(string Username, string Password, string twofa)
        {
            try
            {
                ClientHandlr = new HttpClientHandler {
                    UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, AllowAutoRedirect = true
                };
                Client = new HttpClient(ClientHandlr)
                {
                    BaseAddress = new Uri("https://betking.io/")
                };
                Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
                Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));
                cookies = new CookieContainer();
                ClientHandlr.CookieContainer = cookies;
                Client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36");

                string s1 = "";
                HttpResponseMessage resp = Client.GetAsync("").Result;
                if (resp.IsSuccessStatusCode)
                {
                    s1 = resp.Content.ReadAsStringAsync().Result;
                }
                else
                {
                    if (resp.StatusCode == HttpStatusCode.ServiceUnavailable)
                    {
                        s1 = resp.Content.ReadAsStringAsync().Result;
                        System.Threading.Tasks.Task.Factory.StartNew(() =>
                        {
                            System.Windows.Forms.MessageBox.Show("betking.io has their cloudflare protection on HIGH\n\nThis will cause a slight delay in logging in. Please allow up to a minute.");
                        });
                        if (!Cloudflare.doCFThing(s1, Client, ClientHandlr, 0, "betking.io"))
                        {
                            finishedlogin(false);
                            return;
                        }
                    }
                    else
                    {
                    }
                }
                resp = Client.GetAsync("").Result;
                s1   = resp.Content.ReadAsStringAsync().Result;

                s1 = s1.Substring(s1.IndexOf("window.settings"));
                s1 = s1.Substring(s1.IndexOf("\"csrfToken\":\"") + "\"csrfToken\":\"".Length);

                string csrf = s1.Substring(0, s1.IndexOf("\""));
                Client.DefaultRequestHeaders.Add("csrf-token", csrf);

                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                // pairs.Add(new KeyValuePair<string, string>("_csrf", csrf));
                //pairs.Add(new KeyValuePair<string, string>("client_id", "0"));
                pairs.Add(new KeyValuePair <string, string>("fingerprint", "DiceBot-" + Process.GetCurrentProcess().Id));
                pairs.Add(new KeyValuePair <string, string>("loginmethod", Username.Contains("@")?"email": "username"));
                pairs.Add(new KeyValuePair <string, string>("password", Password));
                //pairs.Add(new KeyValuePair<string, string>("redirect_uri", "https://betking.io/bet"));
                pairs.Add(new KeyValuePair <string, string>("otp", twofa));
                pairs.Add(new KeyValuePair <string, string>("rememberme", "false"));
                pairs.Add(new KeyValuePair <string, string>(Username.Contains("@") ? "email" : "username", Username));
                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                HttpResponseMessage   RespMsg = Client.PostAsync("api/auth/login", Content).Result;
                string responseUri            = RespMsg.RequestMessage.RequestUri.ToString();
                string sEmitResponse          = RespMsg.Content.ReadAsStringAsync().Result;

                if (!sEmitResponse.ToLower().Contains("error"))
                {
                    BKAccount tmpAccount = json.JsonDeserialize <BKAccount>(sEmitResponse);
                    this.username = Username;

                    sEmitResponse = Client.GetStringAsync("api/wallet/currencies").Result;
                    Currs         = json.JsonDeserialize <bkGetCurrencies>(sEmitResponse);

                    if (Currs == null)
                    {
                        Parent.DumpLog("Failed to get currencies", 0);
                        finishedlogin(false);
                        return;
                    }
                    foreach (BKCurrency x in Currs.currencies)
                    {
                        if (x.symbol.ToLower() == Currency.ToLower())
                        {
                            CurrentCurrency = x;
                        }
                    }
                    resp = Client.GetAsync("bet/dice").Result;
                    s1   = resp.Content.ReadAsStringAsync().Result;

                    s1 = s1.Substring(s1.IndexOf("window.settings"));
                    s1 = s1.Substring(s1.IndexOf("\"csrfToken\":\"") + "\"csrfToken\":\"".Length);

                    csrf = s1.Substring(0, s1.IndexOf("\""));
                    Client.DefaultRequestHeaders.Remove("csrf-token");
                    Client.DefaultRequestHeaders.Add("csrf-token", csrf);
                    GetBalance();
                    GetStats();


                    string      LoadState = Client.GetStringAsync("api/dice/load-state?clientSeed=" + R.Next(0, int.MaxValue) + "&currency=0").Result;
                    bkLoadSTate TmpState  = json.JsonDeserialize <bkLoadSTate>(LoadState);
                    nonce          = TmpState.nonce;
                    clientseed     = TmpState.clientSeed;
                    serverseedhash = TmpState.serverSeedHash;
                    finishedlogin(true);
                    return;
                }
            }
            catch (Exception e)
            {
                Parent.DumpLog(e.ToString(), 0);
                finishedlogin(false);
                return;
            }
            finishedlogin(false);
        }