示例#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;
 }
        public string GenerateNick()
        {
            if (generatorType == GeneratorTypes.normalGenerator)
            {
                if (m_names == null)
                {
                    m_names = System.IO.File.ReadAllLines("data/dic_names.txt");
                }
                if (m_surnames == null)
                {
                    m_surnames = System.IO.File.ReadAllLines("data/dic_surnames.txt");
                }
                int type = m_Random.Next(0, 5);
                string s = "";
                int n;
                switch (type)
                {
                    case 0: //тип: ник+цифры
                        s = m_Dic[m_Random.Next(m_Dic.Length)].Trim();
                        //добавить циферок
                        n = m_Random.Next(1, 4);
                        for (int i = 0; i < n; i++)
                        {
                            s += m_Random.Next(10);
                        }
                        break;
                    case 1: //тип: имя+фамилия
                    case 2:
                        s = m_names[m_Random.Next(m_names.Length)].Trim() + " " +
                            m_surnames[m_Random.Next(m_surnames.Length)].Trim();
                        break;
                    case 3: //тип ник+фамилия
                        s = m_Dic[m_Random.Next(0, m_Dic.Length - 1)] + " " +
                            m_surnames[m_Random.Next(m_surnames.Length)].Trim();
                        break;
                    case 4: //старый метод ник+ник (не вызывается)
                        for (int c = 0; c < 2; c++)
                        {
                            s = m_Dic[m_Random.Next(0, m_Dic.Length - 1)] + " " + s;
                            s = Char.ToUpper(s[0]) + s.Substring(1);
                        }
                        s = s.Trim();
                        break;
                }
                return s;
            }

            if (generatorType == GeneratorTypes.webLoader)
            {
                if (httpClient == null)
                    httpClient = new HttpClient();

                if (webNames.Count == 0)
                {
                    string response = httpClient.DownloadString(webSource);
                    webNames.AddRange(response.Split(new char[] { '\x000D', '\x000A' }));
                }

                if (webNames.Count == 0)
                {
                    throw new Exception("Unable to load webNames");
                }

                string name = webNames[0];
                webNames.RemoveAt(0);

                return name;
            }

            return null;
        }
示例#3
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();
        }
示例#4
0
        // update Port in proxy class
        private static void LoadHideMyAssCaptcha(HideMyAssProxyStruct proxy)
        {
            HttpClient connection = new HttpClient();

            string num = "";
            byte[] bitmapData = null;

            try
            {
                bitmapData = connection.DownloadData(proxy.PortImgURL);
            }
            catch (Exception e)
            {
                ConsoleLog.WriteLine("LoadHideMyAss: load 3 error. " + e.Message);
                return;
            }

            //Bitmap source = new Bitmap(new MemoryStream(bitmapData));
            //source.Save(@"C:\source" + count.ToString() + ".bmp");
            Bitmap captcha = LoadHideMyAssCaptchaCutSource(new Bitmap(new MemoryStream(bitmapData)), 0);
            //Bitmap captcha = CaptchaCutSource(new Bitmap(@"C:\source.bmp"));
            //captcha.Save(@"C:\cut" + count.ToString() + ".bmp");

            for (int captchaX = 0; captchaX < captcha.Width - hidemyassSamplesMaxWidth; captchaX++)
            {
                foreach (Bitmap trySample in hidemyassSamples)
                {
                    Bitmap lSample;
                    lock (locker)
                    {
                        lSample = new Bitmap(trySample);
                    }

                    if (LoadHideMyAssCaptchaCompareSamples(captcha, captchaX, lSample))
                    {
                        num += hidemyassSamples.IndexOf(trySample).ToString();
                        break;
                    }
                }
            }

            proxy.Port = num.ToString();

            return;
        }
示例#5
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();
        }
示例#6
0
        public bool UploadCaptcha(byte[] jpeg)
        {
            HttpClient m_Client = new HttpClient();
            string m_Response = "";
            //Формируем тело POST-запроса
            string boundary = "----------" + DateTime.Now.Ticks.ToString("x");
            string NameAffix = "--" + boundary + "\r\nContent-Disposition: form-data; name=\"";
            string NameSuffix = "\"\r\n\r\n";

            System.IO.MemoryStream postdata = new System.IO.MemoryStream();
            //Данные формы
            string formdata = "";
            formdata += NameAffix + "method" + NameSuffix + "post" + "\r\n";
            formdata += NameAffix + "soft_id" + NameSuffix + "223\r\n";
            formdata += NameAffix + "key" + NameSuffix + Key + "\r\n";
            formdata += NameAffix + "phrase" + NameSuffix + phrase + "\r\n";

            //Заголовок для файла
            formdata += NameAffix + "file\"; filename=\"captcha.jpg\"\r\n";
            formdata += "Content-Type: image/jpeg\r\n\r\n";

            //Пишемс
            postdata.Write(Encoding.ASCII.GetBytes(formdata), 0, formdata.Length);
            postdata.Write(jpeg, 0, jpeg.Length);
            //Готовим окончание
            formdata = "\r\nContent-Disposition: form-data; name=\"commit\"\r\nMake changes\r\n";
            formdata += "--" + boundary + "--";
            //Пишемс
            postdata.Write(Encoding.ASCII.GetBytes(formdata), 0, formdata.Length);
            byte[] buffer = new byte[postdata.Length];
            postdata.Seek(0, System.IO.SeekOrigin.Begin);
            postdata.Read(buffer, 0, buffer.Length);
            //System.IO.File.WriteAllBytes("log.txt", buffer);
            //ConsoleLog.WriteLine(buffer, "CapchaLog.txt");
            //m_Client.Timeout = m_Client.Timeout * 10;
            m_Response = m_Client.UploadMultipartData(
                "http://antigate.com/in.php", buffer, boundary);
            if (m_Response.Substring(0, 2) == "OK")
            {
                CaptchaID = m_Response.Substring(3);
                return true;
            }
            return false;
        }
示例#7
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;
     }
 }
示例#8
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;
        }
示例#9
0
        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);
            }
        }
示例#10
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;
        }