private static RegResult RegisterBot( string NickName, string Password, int Nationality, string EMail, int BirthDay, int BirthMonth, int BirthYear, bool Female, out string Response) { string Referal = null; HttpClient client = new HttpClient(); string TokenScanString = "id=\"_token\" name=\"_token\" value=\""; string Token; //Грузим главную if (!Globals.BotConfig.useTOR) { client.SetProxy(Globals.BotConfig.ProxyList.GetRandomString(), Globals.BotConfig.proxyCredentials); } else { client.SetProxy("127.0.0.1:8118", null);//m_Config.ProxyList.GetString(0); if (!(new TorClient(client.GetProxy(), "")).GetNewIP()) throw new Exception("Error getting new TOR IP"); ConsoleLog.WriteLine("TOR new IP obtained!"); } client.UserAgent = Globals.BotConfig.UserAgentList.GetRandomString(); if (!String.IsNullOrEmpty(Referal)) { Response = client.DownloadString("http://www.erepublik.com/en/referrer/" + Referal); Response = client.DownloadString("http://www.erepublik.com/en/referrer/" + Referal); } else { Response = client.DownloadString("http://www.erepublik.com/"); Response = client.DownloadString("http://www.erepublik.com/en/register"); } //Выковыриваем токен Response = Response.Remove(0, Response.IndexOf(TokenScanString) + TokenScanString.Length); Token = Response.Substring(0, Response.IndexOf("\"")); //Строим запрос //Понеслася ICaptchaProvider CaptchaProvider; if (Globals.BotConfig.precaptchaBufferSize == 0) { if (String.IsNullOrEmpty(Globals.BotConfig.AntiGateKey)) { CaptchaProvider = new WinFormsCaptchaProvider(Globals.BotConfig.bBeep); } else { CaptchaProvider = new AntigateCaptchaProvider(Globals.BotConfig.AntiGateKey); } } else { CaptchaProvider = new PrecaptchaCaptchaProvider(Globals.BotConfig.AntiGateKey, Globals.BotConfig.precaptchaBufferSize, Globals.BotConfig.bBeep); } bool ok = false; string PostData; ResolvedCaptcha captcha = null; for (int attempt = 0; attempt < 3; attempt++) { captcha = CaptchaProvider.GetResolvedCaptcha(); PostData = "_token=" + Token + "&recaptcha_challenge_field=" + captcha.ChallengeID + "&recaptcha_response_field=" + captcha.CaptchaText; Response = client.UploadString("http://www.erepublik.com/ajax_captcha", PostData); if (Response.Contains("success")) { ok = true; break; } } if (!ok) { return RegResult.CaptchaFail; } PostData = "_token=" + Token + "&citizen_name=" + System.Web.HttpUtility.UrlEncode(NickName) + "&citizen_password="******"&country_selected_id=" + country.ToString() + "&country_list=" + country.ToString() + "®ion_list=" + region.ToString() + "®ion_selected_id=" + region.ToString() + "&nationality_list=" + Nationality + "&citizen_email=" + EMail.Replace("@", "%40") + "&recaptcha_challenge_field=" + captcha.ChallengeID + "&recaptcha_response_field=" + captcha.CaptchaText; Response = client.UploadString("http://www.erepublik.com/en/register", PostData); if (Response.Contains("Email validation")) return RegResult.Success; if (Response.Contains("Citizen name already exists")) return RegResult.NameExist; if (Response.Contains("There is already an account created on this email address")) return RegResult.EmailExist; return RegResult.UnknownFail; }
public static void Worker(string[] args) { if (args.Length != 3) { PrintUsage(); return; } int.TryParse(args[1], out delayMin); int.TryParse(args[2], out delayMax); Antigate.phrase = "0"; try { int voteCounter = 0; while (true) { try { voteCounter++; ConsoleLog.WriteLine("Vote, try " + voteCounter.ToString()); client = new HttpClient(); if (!Globals.BotConfig.useTOR) { client.SetProxy(Globals.BotConfig.ProxyList.GetRandomString(), Globals.BotConfig.proxyCredentials); } else { client.SetProxy("127.0.0.1:8118", null);//m_Config.ProxyList.GetString(0); if (!(new TorClient(client.GetProxy(), "")).GetNewIP()) throw new Exception("Error getting new TOR IP"); ConsoleLog.WriteLine("TOR new IP obtained!"); } client.UserAgent = Globals.BotConfig.UserAgentList.GetRandomString(); ConsoleLog.WriteLine("Proxy: " + client.GetProxy()); string lastURL = "http://svetiksch.spb.ru"; if (rnd.Next(1, 3) == 1) { if (rnd.Next(1, 10) <= 5) lastURL = "http://svetiksch.spb.ru"; else lastURL = "http://svetiksch.spb.ru/news/2011-05-27-345"; } else { lastURL = Visiting2(); } if (lastURL == baseURL) { throw new Exception("Visiting2 failed"); } if (!Visiting1(lastURL)) { throw new Exception("Visiting1 failed"); } ConsoleLog.WriteLine("Voting done."); DoSleep(rnd.Next(delayMin, delayMax)); //ConsoleLog.WriteLine("Press any key..."); //Console.ReadKey(); } catch (System.Exception e) { ConsoleLog.WriteLine("Local error: " + e.Message); } } } catch (System.Exception e) { ConsoleLog.WriteLine("Worker error: " + e.Message); } }