Beispiel #1
0
        public static CaptchaSolver Captcha(string captchaName, string apiKey, string apiSource)
        {
            CaptchaSolver captchaSolver;

            if (captchaName.Equals("9KW") && apiKey != "" && apiSource != "")
            {
                captchaSolver                     = new KwEu();
                captchaSolver.hostname            = "https://www.9kw.eu/index.cgi";
                captchaSolver.APIKeyOrName        = apiKey;
                captchaSolver.APISourceOrPassword = apiSource;
            }
            else if (captchaName.Equals("DeCaptcher") && apiKey != "" && apiSource != "")
            {
                captchaSolver                     = new Decaptcher();
                captchaSolver.hostname            = "http://poster.de-captcher.com/"; //api.de-captcher.com
                captchaSolver.port                = 3500;
                captchaSolver.APIKeyOrName        = apiKey;
                captchaSolver.APISourceOrPassword = apiSource;
            }
            else if (captchaName.Equals("DeathByCaptcha") && apiKey != "" && apiSource != "")
            {
                captchaSolver = new DeathByCaptcha();
                captchaSolver.APIKeyOrName        = apiKey;
                captchaSolver.APISourceOrPassword = apiSource;
            }
            else
            {
                captchaSolver = new ManualCaptcha();
            }
            captchaSolver.provider = captchaName;
            return(captchaSolver);
        }
Beispiel #2
0
        /// <summary>
        /// This Method Decodes The Captcha Image
        /// </summary>
        /// <returns>It Returns Decode String Of Captcha Image</returns>
        private string decaptcha(string ImagePath)
        {
            unsafe
            {
                int id;
                int ret;
                int pic_size;

                int[] p_pict_to;
                int[] p_pict_type;
                int   size_buf;
                int[] major_id;
                int[] minor_id;

                float[] balance;

                if (Decaptcher.DecaptcherInit() == -1)
                {
                    return("");
                }

                id = Decaptcher.CCprotoInit();

                if (id == -1)
                {
                    return("");
                }

                ret = Decaptcher.CCprotoLogin(id, Globals.DeCaptcherHost, int.Parse(Globals.DeCaptcherPort), Globals.DeCaptcherUsername, Globals.DeCaptcherUsername.Length, Globals.DeCaptcherPassword, Globals.DeCaptcherPassword.Length);

                if (ret < 0)
                {
                    return("");
                }

                balance = new float[1];

                fixed(float *balance1 = &balance[0])

                ret = Decaptcher.CCprotoBalance(id, balance1);

                if (ret < 0)
                {
                    return("");
                }

                FileStream fs = new FileStream(ImagePath, FileMode.Open);

                byte[] buffer = new byte[fs.Length];
                pic_size = (int)fs.Length;
                fs.Read(buffer, 0, buffer.Length);
                fs.Close();

                byte[] captcha1 = new byte[256];
                p_pict_to   = new int[1];
                p_pict_type = new int[1];

                major_id = new int[1];
                minor_id = new int[1];

                p_pict_to[0]   = 0;
                p_pict_type[0] = 0;
                size_buf       = 255;

                fixed(int *p_pict_to1 = &p_pict_to[0])
                fixed(int *p_pict_type1 = &p_pict_type[0])
                fixed(int *major_id1    = &major_id[0])
                fixed(int *minor_id1    = &minor_id[0])
                fixed(byte *captcha     = &captcha1[0])
                fixed(byte *bufPass     = &buffer[0])
                {
                    //ret = CCprotoPicture(id,bufPass,pic_size, captcha);
                    ret = Decaptcher.CCprotoPicture2(id, bufPass, pic_size, p_pict_to1, p_pict_type1, captcha, size_buf, major_id1, minor_id1);
                    if (ret == -5)
                    {
                        Console.WriteLine("Decapther Server is overloaded Waiting for 1 sec and re-trying...");
                    }
                }

                string s = "";
                s = new string(Encoding.ASCII.GetChars(captcha1));
                string result = s.Replace("\0", "");
                //if (result.ToString() == "")
                //{
                //    decaptcha();
                //}

                Decaptcher.CCprotoClose(id);
                //this.Invoke(objDecaptchaDelegate, s, true);
                //Logger.LogText("Captcha Text Fetched Successfully", null);
                return(result);
            }
        }