예제 #1
0
 void GetBalanceThread()
 {
     while (iskd)
     {
         try
         {
             if ((DateTime.Now - lastupdate).TotalSeconds > 30)
             {
                 lastupdate = DateTime.Now;
                 string s = CreateRandomString();
                 //Requests.Add(s,1);
                 NSSocket.Send("[2,\"0." + s + "\",\"ping\",{}]");
                 string  result   = Client.GetStringAsync("php/login/load_login.php").Result;
                 NSLogin tmplogin = json.JsonDeserialize <NSLogin>(result);
                 balance = decimal.Parse(tmplogin.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                 Parent.updateBalance(balance);
                 //GetStats();
             }
         }
         catch { }
     }
 }
예제 #2
0
        public override void Login(string Username, string Password, string twofa)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
                                                   | SecurityProtocolType.Tls11
                                                   | SecurityProtocolType.Tls12
                                                   | SecurityProtocolType.Ssl3;
            ClientHandlr = new HttpClientHandler {
                UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, Proxy = this.Prox, UseProxy = Prox != null
            };
            Client = new HttpClient(ClientHandlr)
            {
                BaseAddress = new Uri("https://nitrogensports.eu/")
            };
            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");


            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("nitrogensports.eu 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, "nitrogensports.eu"))
                        {
                            finishedlogin(false);
                            return;
                        }
                    }
                }
                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>("captcha_code", ""));
                pairs.Add(new KeyValuePair <string, string>("otp", twofa /*==""?"undefined":twofa*/));
                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string  sEmitResponse         = Client.PostAsync("php/login/login.php", Content).Result.Content.ReadAsStringAsync().Result;
                NSLogin tmpLogin = json.JsonDeserialize <NSLogin>(sEmitResponse);
                if (tmpLogin.errno != 0)
                {
                    finishedlogin(false);
                    return;
                }
                else
                {
                    this.balance = decimal.Parse(tmpLogin.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                    token        = tmpLogin.csrf_token;
                    ConnectSocket();
                    balance = decimal.Parse(tmpLogin.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                    Parent.updateBalance(balance);
                    GetStats();
                    this.password = Password;
                    return;
                }
            }
            catch (AggregateException e)
            {
            }
            catch (Exception e)
            {
            }
            finishedlogin(false);
        }