private CaptchaReturn GetCaptcha() { using (HttpClient client = new HttpClient()) { client.Timeout = new TimeSpan(0, 10, 0); retry: List <KeyValuePair <string, string> > content = new List <KeyValuePair <string, string> >(); content.Add(new KeyValuePair <string, string>("API", StaticVars.CaptchaAPI)); content.Add(new KeyValuePair <string, string>("WebsiteUrl", "https://club.pokemon.com/us/pokemon-trainer-club/parents/sign-up")); content.Add(new KeyValuePair <string, string>("WebsiteKey", "6LdpuiYTAAAAAL6y9JNUZzJ7cF3F8MQGGKko1bCy")); FormUrlEncodedContent sendContent = new FormUrlEncodedContent(content); try { if (StaticVars.stop) { Thread.CurrentThread.Abort(); } string response = client.PostAsync("http://captcha.shuffletanker.com/api/Captcha/GetResponse", sendContent).Result.Content.ReadAsStringAsync().Result; //string response = client.PostAsync("http://localhost:39663/api/Captcha/GetResponse", sendContent).Result.Content.ReadAsStringAsync().Result; CaptchaReturn cr = JsonConvert.DeserializeObject <CaptchaReturn>(response); if (cr.status) { cr.tryCount = 0; return(cr); } else { if (cr.captcha_response.Contains("Zero Balance")) { StaticVars.stop = true; StaticVars.LogText += "No Balance" + Environment.NewLine; Thread.CurrentThread.Abort(); } else if (cr.captcha_response.Contains("Please use your referral account")) { StaticVars.stop = true; StaticVars.LogText += "Please use your 2Captcha referral account" + Environment.NewLine; Thread.CurrentThread.Abort(); } } } catch (Exception e) { Debug.WriteLine(e.Message); } goto retry; } }
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; }