Esempio n. 1
0
        private void IncapsulaResolver()
        {
            string sitekey         = string.Empty;
            string url             = string.Empty;
            var    captchaResolver = new Captcha();

retryCap:
            try
            {
                for (int i = 0; i < 5; i++)
                {
                    AuthClient.Navigate(this.TargetUri.Scheme + Uri.SchemeDelimiter + this.TargetUri.Host.ToString());
                    Sleep(300);
                }
                AuthClient.Navigate(this.TargetUri.Scheme + Uri.SchemeDelimiter + this.TargetUri.Host.ToString());
                Sleep(5000);
                if (!AuthClient.DocumentText.Contains("Request unsuccessful"))
                {
                    return;
                }
                mshtml.HTMLDocument doc    = (mshtml.HTMLDocument)AuthClient.Document.DomDocument;
                object index               = 0;
                mshtml.IHTMLWindow2 frame2 = (mshtml.IHTMLWindow2)doc.frames.item(ref index);
                doc = (mshtml.HTMLDocument)frame2.document;
                Regex           reg    = new Regex("data-sitekey=\"(.[^\"]+)\"");
                MatchCollection result = reg.Matches(doc.documentElement.innerHTML);
                foreach (Match mm in result)
                {
                    sitekey = mm.Groups[1].ToString();
                }
                Regex           reg2    = new Regex("\"POST\", \"(.+)\",");
                MatchCollection result2 = reg2.Matches(doc.documentElement.innerHTML);
                foreach (Match mm in result2)
                {
                    url = mm.Groups[1].ToString();
                }
NoSlot:
                string capId = captchaResolver.reCaptcha(Config.captchaKey, sitekey, AuthClient.Url.ToString());
                if (capId.Equals("ERROR_KEY_DOES_NOT_EXIST") || capId.Equals("ERROR_ZERO_BALANCE"))
                {
                    return;
                }
                else if (capId.Equals("ERROR_NO_SLOT_AVAILABLE"))
                {
                    System.Threading.Thread.Sleep(10000);
                    goto NoSlot;
                }
                else if (capId.Contains("ERROR"))
                {
                    goto retryCap;
                }
                System.Threading.Thread.Sleep(15000);
                string answer = captchaResolver.resCaptcha(Config.captchaKey, capId);
                if (answer.Equals("ERROR_CAPTCHA_UNSOLVABLE"))
                {
                    goto retryCap;
                }
                AuthClient.Document.InvokeScript("eval", new object[] { "var xhr;" });
                AuthClient.Document.InvokeScript("eval", new object[] { "xhr = (window.XMLHttpRequest) ? new XMLHttpRequest : new ActiveXObject(\"Microsoft.XMLHTTP\");" });
                AuthClient.Document.InvokeScript("eval", new object[] { "var msg = \"g-recaptcha-response=" + answer + "\";" });
                AuthClient.Document.InvokeScript("eval", new object[] { "xhr.open(\"POST\", \"" + url + "\", true);" });
                AuthClient.Document.InvokeScript("eval", new object[] { "xhr.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");" });
                AuthClient.Document.InvokeScript("eval", new object[] { "xhr.onreadystatechange = function(){ if (xhr.readyState == 4) { window.parent.location.reload(true); }};" });
                AuthClient.Document.InvokeScript("eval", new object[] { "xhr.send(msg);" });
                Sleep(5000);
                if (AuthClient.DocumentText.Contains("Request unsuccessful"))
                {
                    goto retryCap;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                goto retryCap;
            }
        }
Esempio n. 2
0
        private void CloudflareResolver()
        {
            string sitekey         = string.Empty;
            var    captchaResolver = new Captcha();

retryCap:
            try
            {
                AuthClient.Navigate(this.TargetUri.Scheme + Uri.SchemeDelimiter + this.TargetUri.Host.ToString());
                while (AuthClient.DocumentText.Contains("Just a moment..."))
                {
                    System.Threading.Thread.Sleep(500);
                }
                Sleep(5000);
                if (!AuthClient.DocumentText.Contains("Attention Required"))
                {
                    return;
                }
                Regex           reg    = new Regex("data-sitekey=\"(.[^\"]+)\"");
                MatchCollection result = reg.Matches(AuthClient.DocumentText);
                foreach (Match mm in result)
                {
                    sitekey = mm.Groups[1].ToString();
                }
NoSlot:
                string capId = captchaResolver.hCaptcha("fb3e80d6b9a3e59587e4503769519865", sitekey, AuthClient.Url.ToString());
                if (capId.Equals("ERROR_KEY_DOES_NOT_EXIST") || capId.Equals("ERROR_ZERO_BALANCE"))
                {
                    return;
                }
                else if (capId.Equals("ERROR_NO_SLOT_AVAILABLE"))
                {
                    System.Threading.Thread.Sleep(10000);
                    goto NoSlot;
                }
                else if (capId.Contains("ERROR"))
                {
                    goto retryCap;
                }
                System.Threading.Thread.Sleep(15000);
                while (AuthClient.DocumentText.Contains("Just a moment..."))
                {
                    System.Threading.Thread.Sleep(1000);
                }
                string answer = captchaResolver.resCaptcha("fb3e80d6b9a3e59587e4503769519865", capId);
                if (answer.Equals("ERROR_CAPTCHA_UNSOLVABLE"))
                {
                    goto retryCap;
                }
                AuthClient.Document.InvokeScript("eval", new object[] { "document.getElementsByName(\"g-recaptcha-response\")[0].value = \"" + answer + "\"" });
                AuthClient.Document.InvokeScript("eval", new object[] { "document.getElementsByName(\"h-captcha-response\")[0].value = \"" + answer + "\"" });
                AuthClient.Document.InvokeScript("eval", new object[] { "document.getElementById(\"challenge-form\").submit();" });
                Sleep(5000);
                if (AuthClient.DocumentText.Contains("Attention Required"))
                {
                    goto retryCap;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                goto retryCap;
            }
        }