コード例 #1
0
ファイル: Creator.cs プロジェクト: henriquemaciel/PTC-Creator
 public Creator(HttpClientItem c)
 {
     lock (c)
     {
         c.inUse = true;
         client = c;
     }
 }
コード例 #2
0
ファイル: Creator.cs プロジェクト: henriquemaciel/PTC-Creator
        private bool doWork(HttpClientItem client)
        {
            // check which captcha service to use
            try
            {
                string pageSource = "";
                // start registration
                pageSource = client.GetAsync("/us/pokemon-trainer-club/sign-up").Result;

                //Get csrf token
                Regex re = new Regex(@"csrfmiddlewaretoken' value='\w+");
                string csrf = re.Match(pageSource).Value.Replace("csrfmiddlewaretoken' value='", "");
                if (csrf != "")
                {
                    pageSource = client.PostAsync("/us/pokemon-trainer-club/sign-up/", getAgeVerify(csrf)).Result;
                    int count = 0;
                    while (true)
                    {
                        //Check page passed age verification
                        if (!pageSource.Contains("With a Pokémon Trainer Club account, you can:"))
                        {
                            break;
                        }
                        count += 1;
                        if (count > 10) //Check for 10 times, if none works, proxy dead
                        {
                            StaticVars.LogText += DateTime.Now.ToString() + ": Proxy " + client.proxy + " failed to view club.pokemon.com website" + Environment.NewLine;
                            client.failCount += 1;
                            return false;
                        }
                        Thread.Sleep(1000);
                        pageSource = client.PostAsync("/us/pokemon-trainer-club/sign-up/", getAgeVerify(csrf)).Result;
                    }
                    if (StaticVars.stop)
                    {
                        return false;
                    }
                    //get new captcha

                    CaptchaReturn captcha = GetCaptcha();
                    //Post registration to server
                    FormUrlEncodedContent createForm = AccountContent(csrf, captcha.captcha_response);
                    pageSource = client.PostAsync("/us/pokemon-trainer-club/parents/sign-up", createForm).Result;
                    //Check registration successful or not
                    if (pageSource.Contains("Hello! Thank you for creating an account!"))
                    {
                        return true;
                    }
                    else if (pageSource.Contains("Verify Age"))
                    {
                        client.failCount += 1;
                        StaticVars.LogText += DateTime.Now.ToString() + ": " + m.Username + " failed while using proxy " + client.proxy + Environment.NewLine;
                    }
                    else if (pageSource.Contains("There is a problem with your email address.") || pageSource.Contains("Unexpected Error"))
                    {
                        StaticVars.LogText += DateTime.Now.ToString() + ": " + m.Username + " failed with unexpected error from Niantic website" + Environment.NewLine;
                    }
                    else if (pageSource.Contains("Access Denied"))
                    {
                        client.failCount += 1;
                        StaticVars.LogText += DateTime.Now.ToString() + ": " + m.Username + " failed with access denied from Niantic website" + Environment.NewLine;
                    }
                    else
                    {
                        /*
                        if (StaticVars.addToDB)
                        {
                            WriteErrorMessage(pageSource);
                        }*/
                        //PostBadCaptcha(captcha.server_index, captcha.captcha_id);
                        client.failCount += 1;
                    }
                    StaticVars.title.fail += 1;
                }
                else
                {
                    Debug.WriteLine(Thread.CurrentThread.Name + " No csrf Token");
                    client.failCount += 1;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                client.failCount += 1;
            }
            return false;
        }