예제 #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;
 }
예제 #2
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 + "key" + NameSuffix + Key + "\r\n";
            formdata += NameAffix + "phrase" + NameSuffix + "1" + "\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;
        }
예제 #3
0
 public PBotFeature(PBot bot)
 {
     Bot = bot;
     Info = bot.Info;
     Client = bot.Client.Clone();
 }
예제 #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)
     {
         MainForm.SetStatus("Unable to load captcha: " + e.Message);
         throw e;
     }
 }
예제 #5
0
 /// <summary>
 /// Клон клинета, эмулирует работу в отдельной вкладке браузера.
 /// </summary>
 public HttpClient Clone()
 {
     HttpClient clone = new HttpClient();
     clone.Cookies = Cookies;
     clone.Proxy = Proxy;
     clone.UserAgent = UserAgent;
     clone.Referer = Referer;
     clone.Timeout = Timeout;
     return clone;
 }