titanium-web-proxy icon indicating copy to clipboard operation
titanium-web-proxy copied to clipboard

Google reCaptcha fails via Proxy

Open diliger opened this issue 5 years ago • 1 comments

Hello, I am trying to load the page https://isales.trcont.com/#/tracking it contains captcha script on the page.

My idea is to load the page with fake domain address e.g. test.test.

image

And captcha fails with Error: invalid domain key.

But it works fine with free web proxy - https://hosteagle.club/ image

I start the proxy with code provided in sample.

Implement domain changing onRequest with the code:

            if (e.HttpClient.Request.Host.Contains("test.test"))
            {
                e.HttpClient.Request.RequestUri = new Uri(e.HttpClient.Request.Url.Replace("test.test", "isales.trcont.com"));
                string[] headers = new[] { "Host", "Origin", "Referer" };
                foreach (var header in headers)
                {
                    var h = e.HttpClient.Request.Headers.GetHeaders(header)[0];
                    e.HttpClient.Request.Headers.RemoveHeader(h);
                    h = new HttpHeader(h.Name, h.Value.Replace("test.test", "isales.trcont.com"));
                    e.HttpClient.Request.Headers.AddHeader(h);
                }
            }

And onResponse:

            if (e.HttpClient.Request.Method == "GET" || e.HttpClient.Request.Method == "POST")
            {
                if (e.HttpClient.Response.StatusCode == (int)HttpStatusCode.OK)
                {
                    if (e.HttpClient.Response.ContentType != null && e.HttpClient.Response.ContentType.Trim().ToLower().Contains("text/html") || e.HttpClient.Response.ContentType.Trim().ToLower().Contains("application/j"))
                    {
                        string body = await e.GetResponseBodyAsString();
                        body = body.Replace("test.test", "isales.trcont.com");
                        e.SetResponseBodyString(body);
                    }
                }
            }

So, what am I doing wrong? Any ideas?

I would appreciate for any help.

diliger avatar Jul 10 '20 14:07 diliger

I'm sure that reCaptcha is encoding/adding to the request/using the hash of the client url somehow. Probably the cookies are also valid only for a specific domain, too. It is not that easy to cheat reCaptcha.. there are smart guys at Google.

It would need a lot of development hours to investigate it. You can check recaptcha source, where is it using the client url... and replace that part of the script with TWP, but it is a lot of work. We are not providing that type of support.

By the way, I don't understand this line of code in the onResponse: body = body.Replace("test.test", "isales.trcont.com");

Normally the response should not contain test.test, scince the goal is to replace everything in the onRrequest, and change back in the onResposne. However it does not solve the problem if you switch the parameters.

honfika avatar Aug 20 '20 11:08 honfika