コード例 #1
0
ファイル: NitrogenSports.cs プロジェクト: hbernaciak/Doormat
 protected override void _UpdateStats()
 {
     if (NSSocket != null && NSSocket.State == WebSocketState.Open && iskd)
     {
         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);
         Stats.Balance = decimal.Parse(tmplogin.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
         Thread.Sleep(1);
         string t = CreateRandomString();
         s = "[2,\"0." + t + "\",\"game\",{}]";
         Requests.Add(t, 1);
         NSSocket.Send(s);
     }
     //GetStats();
 }
コード例 #2
0
ファイル: NitrogenSports.cs プロジェクト: hbernaciak/Doormat
        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;
                }
            }
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
                                                   | SecurityProtocolType.Tls11
                                                   | SecurityProtocolType.Tls12;
            ClientHandlr = new HttpClientHandler {
                UseCookies = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
            };
            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;

                        /*
                         * 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", otp /*==""?"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)
                {
                    callLoginFinished(false);
                    return;
                }
                else
                {
                    Stats.Balance = decimal.Parse(tmpLogin.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                    token         = tmpLogin.csrf_token;
                    ConnectSocket();
                    Stats.Balance = decimal.Parse(tmpLogin.balance, System.Globalization.NumberFormatInfo.InvariantInfo);

                    UpdateStats();
                    this.password = Password;
                    return;
                }
            }
            catch (AggregateException e)
            {
            }
            catch (Exception e)
            {
            }
            callLoginFinished(false);
        }