Beispiel #1
0
 public Status GetStatus()
 {
     HttpClient client = new HttpClient();
     if (Key == null)
     {
         throw new Exception("Captcha.GetStatus: Key is null");
     }
     if (CaptchaID == null)
     {
         throw new Exception("Captcha.GetStatus: CaptchaID is null");
     }
     string resp = client.DownloadString("http://antigate.com/res.php?key=" +
                                       Key + "&action=get&id=" + CaptchaID.ToString());
     if (resp.Contains("CAPCHA_NOT_READY"))
     {
         CaptchaStatus = Status.NotReady;
         return Status.NotReady;
     }
     if (resp.Substring(0, 2) == "OK")
     {
         CaptchaText = resp.Substring(3);
         CaptchaStatus = Status.Success;
         return Status.Success;
     }
     CaptchaStatus = Status.Error;
     return Status.Error;
 }
Beispiel #2
0
        public static string[] LoadHideMyAss(string proxyURL)
        {
            HttpClient loader = new HttpClient();
            List<HideMyAssProxyStruct> proxies = new List<HideMyAssProxyStruct>();
            string baseURL = "http://hidemyass.com";
            string portImg = "/proxy-list/img/port";

            string localData;
            string proxyInfo;

            string response = "";

            try
            {
                response = loader.DownloadString(proxyURL);
            }
            catch (Exception e)
            {
                ConsoleLog.WriteLine("LoadHideMyAss: load 1 error. " + e.Message);
            }

            int page = 1;
            ConsoleLog.WriteLine(response, "ProxyLog1.txt");

            while (response.Contains(portImg))
            {
                ConsoleLog.WriteLine(proxyURL + '/' + page.ToString());

                localData = CommonUtils.GetStringBetween(response, "Anonymity</td>", "pagination");
                ConsoleLog.WriteLine(localData, "ProxyLog2.txt");

                while (localData.Contains("<tr class=\"row"))
                {
                    localData = localData.Substring(localData.IndexOf("<tr class=\"row") + 10);

                    //proxyInfo = CommonUtils.GetStringBetween(localData, "<!--", "style=\"margin");
                    proxyInfo = CommonUtils.GetStringBetween(localData, "<!--", "</tr>");
                    ConsoleLog.WriteLine(proxyInfo, "ProxyLog3.txt");
                    if (proxyInfo.Contains("planetlab"))
                    {
                        string proxyIP = CommonUtils.GetStringBetween(proxyInfo, "gif\">", "</td>");
                        ConsoleLog.WriteLine(proxyIP + " - PlanetLab");
                        continue;
                    }

                    HideMyAssProxyStruct proxy = new HideMyAssProxyStruct();

                    proxy.IP = CommonUtils.GetStringBetween(proxyInfo, "<td>", "</td>");

                    if (proxyInfo.Contains("None"))
                    {
                        ConsoleLog.WriteLine(proxy.IP + " - not anonymous");
                        continue;
                    }

                    proxy.PortImgURL = baseURL + CommonUtils.GetStringBetween(proxyInfo, "<img src=\"", "\"");

                    proxies.Add(proxy);
                }

                page++;
                //if (page > 3) break; // Debug
                try
                {
                    response = loader.DownloadString(proxyURL + '/' + page.ToString());
                    ConsoleLog.WriteLine(response, "ProxyLog1.txt");
                }
                catch (Exception e)
                {
                    ConsoleLog.WriteLine("LoadHideMyAss: load 2 error. " + e.Message);
                }
            }

            LoadHideMyAssCaptchaPreloader();

            const int poolSize = 10;
            System.Threading.Thread[] pool = new System.Threading.Thread[poolSize];
            int count = proxies.Count;
            int i;

            i = 0;
            while (i < count)
            {
                int freeThread = -1;

                for (int ft = 0; ft < poolSize; ft++)
                {
                    if ((pool[ft] == null) || (!pool[ft].IsAlive))
                    {
                        freeThread = ft;
                        break;
                    }
                }

                if (freeThread == -1)
                {
                    System.Threading.Thread.Sleep(100);
                    continue;
                }

                ConsoleLog.WriteLine(
                    "Processing proxy " + (i + 1).ToString() + "/" + count.ToString() +
                    ", thread " + (freeThread+1).ToString());
                pool[freeThread] = new System.Threading.Thread(LoadHideMyAssCaptcha);
                pool[freeThread].Start(proxies[i]);

                i++;
            }

            i = 0;
            while (i < poolSize)
            {
                if ((pool[i % poolSize] != null) && (pool[i % poolSize].IsAlive))
                {
                    System.Threading.Thread.Sleep(200);
                    continue;
                }

                i++;
            }

            List<string> result = new List<string>();
            foreach (HideMyAssProxyStruct proxy in proxies)
            {
                if (!String.IsNullOrEmpty(proxy.Port))
                    result.Add(proxy.FullProxy);
            }

            if (result.Count > 0)
            {
                var streamWriter = new StreamWriter(
                    storePath + "\\proxy.txt",
                    false);
                foreach (string proxy in result)
                {
                    streamWriter.WriteLine(proxy);
                }
                streamWriter.Close();
            }

            return result.ToArray();
        }
Beispiel #3
0
        public static string[] LoadHideMyAssText(string proxyURL)
        {
            HttpClient loader = new HttpClient();
            List<string> proxies = new List<string>();

            string localData;
            string proxyInfo;

            string response = "";

            try
            {
                response = loader.DownloadString(proxyURL);
            }
            catch (Exception e)
            {
                ConsoleLog.WriteLine("LoadHideMyAss: load 1 error. " + e.Message);
            }

            int page = 1;
            //ConsoleLog.WriteLine(response, "ProxyLog1.txt");

            while (response.Contains("leftborder timestamp"))
            {
                ConsoleLog.WriteLine(proxyURL + '/' + page.ToString());

                localData = CommonUtils.GetStringBetween(response, "Anonymity</td>", "pagination");
                //ConsoleLog.WriteLine(localData, "ProxyLog2.txt");

                while (localData.Contains("<tr class=\"\"  rel=\"") ||
                       localData.Contains("<tr class=\"altshade\"  rel=\""))
                {
                    string proxyIP = "";
                    string proxyPort = "";

                    int index = 0, index1 = 0, index2 = 0;
                    index1 = localData.IndexOf("<tr class=\"\"  rel=\"");
                    index2 = localData.IndexOf("<tr class=\"altshade\"  rel=\"");
                    if (index1 == -1)
                    {
                        index = index2 +18;
                    }
                    else if (index2 == -1)
                    {
                        index = index1 + 10;
                    }
                    else
                    {
                        index = Math.Min(index1 + 10, index2 + 18);
                    }
                    localData = localData.Substring(index);

                    proxyInfo = CommonUtils.GetStringBetween(localData, "<!--", "</tr>");
                    //ConsoleLog.WriteLine(proxyInfo, "ProxyLog3.txt");
                    if (proxyInfo.Contains("planetlab"))
                    {
                        proxyIP = CommonUtils.GetStringBetween(proxyInfo, "title=\"Planet Lab proxy\">", "</span>");
                        ConsoleLog.WriteLine(proxyIP + " - PlanetLab");
                        continue;
                    }

                    proxyIP = CommonUtils.GetStringBetween(proxyInfo, "<td><span>", "</span></td>");
                    proxyPort = CommonUtils.GetStringBetween(proxyInfo, "<td>" + (char)10, "</td>");

                    if (proxyInfo.Contains("None"))
                    {
                        ConsoleLog.WriteLine(proxyIP + " - not anonymous");
                        continue;
                    }

                    proxies.Add(proxyIP + ":" + proxyPort);
                }

                ConsoleLog.WriteLine("Proxies loaded: " + proxies.Count.ToString());
                page++;
                //if (page > 3) break; // Debug
                try
                {
                    response = loader.DownloadString(proxyURL + '/' + page.ToString());
                    //ConsoleLog.WriteLine(response, "ProxyLog1.txt");
                }
                catch (Exception e)
                {
                    ConsoleLog.WriteLine("LoadHideMyAss: load 2 error. " + e.Message);
                }
            }

            if (proxies.Count > 0)
            {
                var streamWriter = new StreamWriter(
                    storePath + "\\proxy.txt",
                    false);
                foreach (string proxy in proxies)
                {
                    streamWriter.WriteLine(proxy);
                }
                streamWriter.Close();
            }

            return proxies.ToArray();
        }
Beispiel #4
0
 public Captcha(string Referer)
 {
     try
     {
         HttpClient client = new HttpClient();
         client.Referer = Referer;
         //Вытаскиваем токен каптчи
         string CaptchaData = client.DownloadString(Captcha.CaptchaAPIURL);
         CaptchaData = CaptchaData.Remove(0, CaptchaData.IndexOf(Captcha.ChallengeScanString) +
                                        ChallengeScanString.Length);
         CaptchaData = CaptchaData.Remove(0, CaptchaData.IndexOf(Captcha.ChallengeScanString2) +
                                        ChallengeScanString2.Length);
         CaptchaData = CaptchaData.Trim();
         if (CaptchaData[0] == '\'') CaptchaData = CaptchaData.Remove(0, 1);
         CaptchaData = CaptchaData.Remove(CaptchaData.IndexOf('\''));
         /*
         client.Referer=Referer;
         string CaptchaImageURL=client.DownloadString(Captcha.CaptchaGAPIURL);
         CaptchaImageURL=CaptchaImageURL.Substring(CaptchaImageURL.IndexOf('\'')+1);
         CaptchaImageURL=CaptchaImageURL.Remove(CaptchaImageURL.IndexOf('\''));
         */
         string CaptchaImageURL = Captcha.CaptchaURLBase + CaptchaData;
         //Грузим картинку с каптчей
         client.Referer = null;
         Image = client.DownloadData(CaptchaImageURL);
         ChallengeID = CaptchaData;
     }
     catch (Exception e)
     {
         ConsoleLog.WriteLine("Unable to load captcha: " + e.Message);
         throw e;
     }
 }
Beispiel #5
0
        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() +
                "&region_list=" + region.ToString() + "&region_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;
        }
Beispiel #6
0
        public bool SendLogInfo(string[] taskAndParams, int botCount)
        {
            return true;
            StringBuilder logCommand = new StringBuilder();

            string ticks = System.DateTime.Today.Ticks.ToString();

            logCommand.Append(logURL);
            logCommand.Append("HashKey=" + key);
            logCommand.Append("&task=" + taskAndParams[0]);
            //logCommand.Append("&taskParams=" + "here_will_be_params");
            logCommand.Append("&nBot=" + botCount.ToString());
            logCommand.Append("&nData=" + ticks);

            byte[] expectedReply = encodeMD5(ticks);

            string callURL = logCommand.ToString();

            //ConsoleLog.WriteLine("Log URL: " + callURL);
            HttpClient client = new HttpClient();
            string response = "";

            for (int i = 1; i <= 20; i++)
            {
                try
                {
                    ConsoleLog.WriteLine("Authorising on NorthCitadel server, try " + i.ToString());
                    response = client.DownloadString(callURL);
                    string[] respLines = response.Split('\n');

                    if ((client.Referer == callURL) && (respLines.Length >= 2))
                    {
                        if (validateReply(respLines[0], expectedReply))
                        {
                            if (respLines[1].Contains("ALLOWED"))
                            {
                                ConsoleLog.WriteLine("Authorisation successfull");
                                return true;
                            }
                            if (respLines[1].Contains("DENIED"))
                            {
                                ConsoleLog.WriteLine("Authorisation failed: " + respLines[1]);
                                return false;
                            }
                            ConsoleLog.WriteLine("Authorisation error: " + respLines[1]);
                        }
                        else
                            ConsoleLog.WriteLine("Authorisation error: signature validation failed.");
                    }
                }
                catch (Exception e)
                {
                    //ConsoleLog.WriteLine(response, "AuthorisationLog.txt");
                    ConsoleLog.WriteLine("Authorisation failed: " + e.Message);
                }

                Thread.Sleep(15 * 1000);
            }

            return false;
        }