cloudscraper icon indicating copy to clipboard operation
cloudscraper copied to clipboard

Solving reCaptcha creates recursive loop with POST

Open TaquitoSlayer opened this issue 5 years ago • 0 comments

Please attempt to answer the following questions before submitting a new issue:

  • What version of Cloudscraper are you using?
    • 4.6.0
  • What version of Node.js are you using? (Please share the process information)
    • v10.16.2
  • When did the problem start occurring?
    • As soon as I do any POST request, GET requests seem to resolve themselves fine, but looping still occurs. However, if the GET request has any params in the URL, the looping happens again.

I did notice that if your IP is flagged by CF, or you're using a MITM like Fiddlr, Burp, or Charles, this will automatically be triggered (the looping will be).

  • What is the URL? https://www.starcowparis.com/connexion?back=my-account Logging in here. Keep in mind that the site is currently region locked to France so you'll have to use a vpn.

Please share a minimal working code snippet that reproduces the problem.

Code snippet
 let daProxy = await this.workerProxy;
        let loginOptions = {
            method: 'POST',
            uri: 'https://www.starcowparis.com/connexion?back=my-account',
            body: `back=my-account&email=${this.task.email}&password=${this.task.password}&submitLogin=1`,
            resolveWithFullResponse: true,
            headers: {
                'authority': 'www.starcowparis.com',
                'cache-control': 'max-age=0',
                'origin': 'https://www.starcowparis.com',
                'upgrade-insecure-requests': '1',
                'content-type': 'application/x-www-form-urlencoded',
                'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.0 Safari/537.36',
                'sec-fetch-user': '?1',
                'accept-language': 'en-US,en;q=0.9',
                'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
                'sec-fetch-site': 'same-origin',
                'sec-fetch-mode': 'navigate',
                'referer': 'https://www.starcowparis.com/connexion?back=my-account',
                'accept-encoding': 'gzip, deflate, br',
            },
            jar: this.cj,
            onCaptcha: await this.checkCap.bind(this),
            timeout: 10000,
            proxy: daProxy,
            // followAllRedirects: false
          };
        console.log('login started');
        console.log('Logging in!')


// where when onCaptcha called
 async checkCap(_options, { captcha }) {
            if (this.task.captcha === 'twocap') {
                this.setStatus("Solving CF captcha...")
                this.client = new Client('xxxxx', {
                    timeout: 60000,
                    polling: 5000,
                    throwErrors: false});
                await this.client.decodeRecaptchaV2({
                    googlekey: captcha.siteKey,
                    pageurl: 'www.starcowparis.com'
                  }).then(function(response) {
                    console.log(response.text);
                    captcha.form['g-recaptcha-response'] = response.text;
                    captcha.submit()
                    console.log('submitted!')
                  })
            } else if (this.task.captcha === 'manual') {
                await this.captchaPLZWORK(captcha).then(function(response) {
                    console.log('captcha found')
                    console.log(response)
                    captcha.form['g-recaptcha-response'] = response;
                    captcha.submit()
                    sleep(1000)
                    console.log('submitted!')
                })
            // this.captchaToken = '';
            }
    }  

Above has @infosimples/node_two_captcha used for the 2captcha solving.

TaquitoSlayer avatar Feb 21 '20 03:02 TaquitoSlayer