void GetBalanceThread() { while (ispd) { if ((DateTime.Now - lastupdate).TotalSeconds > 30) { try { lastupdate = DateTime.Now; string s = Client.GetStringAsync("https://freebitco.in/cgi-bin/api.pl?op=get_user_stats").Result; FreebtcStats stats = json.JsonDeserialize <FreebtcStats>(s); if (stats != null) { this.balance = stats.balance / 100000000m; bets = (int)stats.rolls_played; //wins = losses = 0; profit = stats.dice_profit / 100000000m; wagered = stats.wagered / 100000000m; Parent.updateBalance(balance); Parent.updateBets(bets); Parent.updateWins(wins); Parent.updateLosses(losses); Parent.updateWagered(wagered); Parent.updateProfit(profit); } } catch (Exception e) { Parent.DumpLog(e.ToString(), -1); } } Thread.Sleep(1000); } }
public override void Login(string Username, string Password, string twofa) { ClientHandlr = new HttpClientHandler { UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, Proxy = this.Prox, UseProxy = Prox != null }; Client = new HttpClient(ClientHandlr) { BaseAddress = new Uri("https://freebitco.in/") }; Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip")); Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate")); ClientHandlr.CookieContainer = Cookies; try { 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; //cflevel = 0; System.Threading.Tasks.Task.Factory.StartNew(() => { System.Windows.Forms.MessageBox.Show("freebitcoin 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, "freebitco.in")) { finishedlogin(false); return; } } } foreach (Cookie x in Cookies.GetCookies(new Uri("https://freebitco.in"))) { if (x.Name == "csrf_token") { csrf = x.Value; } } List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >(); pairs.Add(new KeyValuePair <string, string>("csrf_token", csrf)); pairs.Add(new KeyValuePair <string, string>("op", "login_new")); pairs.Add(new KeyValuePair <string, string>("btc_address", Username)); pairs.Add(new KeyValuePair <string, string>("password", Password)); pairs.Add(new KeyValuePair <string, string>("tfa_code", twofa)); FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs); var EmitResponse = Client.PostAsync("" + accesstoken, Content).Result; if (EmitResponse.IsSuccessStatusCode) { string s = EmitResponse.Content.ReadAsStringAsync().Result; string[] messages = s.Split(':'); if (messages.Length > 2) { address = messages[1]; accesstoken = messages[2]; Cookies.Add(new Cookie("btc_address", address, "/", "freebitco.in")); Cookies.Add(new Cookie("password", accesstoken, "/", "freebitco.in")); Cookies.Add(new Cookie("have_account", "1", "/", "freebitco.in")); s = Client.GetStringAsync("https://freebitco.in/cgi-bin/api.pl?op=get_user_stats").Result; FreebtcStats stats = json.JsonDeserialize <FreebtcStats>(s); if (stats != null) { this.balance = stats.balance / 100000000m; bets = (int)stats.rolls_played; wins = losses = 0; profit = stats.dice_profit / 100000000m; wagered = stats.wagered / 100000000m; Parent.updateBalance(balance); Parent.updateBets(bets); Parent.updateWins(wins); Parent.updateLosses(losses); Parent.updateWagered(wagered); Parent.updateProfit(profit); lastupdate = DateTime.Now; ispd = true; Thread t = new Thread(GetBalanceThread); t.Start(); finishedlogin(true); return; } finishedlogin(false); return; } finishedlogin(false); return; } //Lastbet = DateTime.Now; } catch (Exception e) { Parent.DumpLog(e.ToString(), 1); } finishedlogin(false); return; }