JimmyLaurent / cloudflare-scraper

A package to bypass Cloudflare's protection
MIT License
284 stars 29 forks source link

Can not bypass cloudflare captcha #9

Open kakaska opened 4 years ago

kakaska commented 4 years ago

Hi

I got 403 status code from CF when running the following code:

const cloudflareScraper = require('cloudflare-scraper');

(async () => {
  try {
    const response = await cloudflareScraper.get('https://widtodo.com/4c8rx0tt8ek4');
    console.log(response);
  } catch (error) {
    console.log(error)
  }
})();

packages.json

{
  "dependencies": {
    "cloudflare-scraper": "^1.0.4",
    "puppeteer": "^3.3.0"
  }
}
JimmyLaurent commented 4 years ago

Couldn't reproduce, sorry. The url doesn't seem to be protected by IUAM. Do you have this error every time ?

Cosmysd commented 4 years ago

Couldn't reproduce, sorry. The url doesn't seem to be protected by IUAM. Do you have this error every time ?

@JimmyLaurent Do you have discord, email, tg, or some contact where i can talk with you? we need your services, i can pay

kakaska commented 4 years ago

Couldn't reproduce, sorry. The url doesn't seem to be protected by IUAM. Do you have this error every time ?

yes, I got the 403 http code every time

JimmyLaurent commented 4 years ago

@Cosmysd I'm not available, I already have a fulltime job. I can't promise anything but I'm ok to try to help you in the measure of possible. Give me your discord, I'll add you.

@kakaska Do you have a stacktrace ? Did you try from other IPs (different country for example) ?

Cosmysd commented 4 years ago

@Cosmysd I'm not available, I already have a fulltime job. I can't promise anything but I'm ok to try to help you in the measure of possible. Give me your discord, I'll add you.

@kakaska Do you have a stacktrace ? Did you try from other IPs (different country for example) ?

Alexx#0877

K5HV commented 4 years ago

I can confirm issue. On some websites (probably when using bad reputation IP) Cloudflare presents site with hcaptcha box without "Checking your browser before accessing" page. cloudflare-scraper is finishing job without bypassing it.

However it looks like that captchaResponse from handleCaptcha.js contains valid data for hCaptcha (r and cf_captcha_kind and vc exists) so it looks like it solves it correctly but cookies contains only "__cfduid".

Maybe some additional step is required?

JimmyLaurent commented 4 years ago

Do you have a public proxy with a "bad reputation IP" to help me reproduce this issue ?

Otherwise could you try to access the protected page manually to see if it's not a ban problem ?

K5HV commented 4 years ago

Not a proxy but I can reproduce it using VPN from VPNBook.com (I was testing with vpnbook-fr1-udp25000.ovpn from server FR1)

  1. Connect to VPN
  2. Start Chromium with clean profile and remote debugger chromium --remote-debugging-port=21221 --user-data-dir=9-cloudflare-scraper
  3. Connect to remote debugger and retrieve website: ``const cloudflareScraper = require('cloudflare-scraper');

(async () => { try { const response = await cloudflareScraper.get('https://widtodo.com/4c8rx0tt8ek4', { browserWSEndpoint: 'ws://127.0.0.1:21221/devtools/browser/00000000-0000-0000-0000-000000000000'}); console.log(response); } catch (error) { console.log(error); } })();``

  1. You should see that cloudflare-scraper hangs on captcha. (output from cloudflare-scraper attached) cloudflare-scraper-9.log

And yes, manually solving hCaptcha lets me access website.

JimmyLaurent commented 4 years ago

The hcaptcha bypass uses a bruteforcing method, it's not perfect and often you'll encounter some rate limits from hcaptcha service, but if you wait enough it will work. I tested it 10 times with the same vpn and same ip, some of the tests took some time but all worked.

If you need to bypass it faster, you can either change your ip and try again or you can use a service like 2captcha.

Here is the api:

const cloudflareScraper = require('cloudflare-scraper');

(async () => {
  try {
    const response = await cloudflareScraper.get('https://cloudflare-url.com', {
       solveCaptcha: async (siteKey, url, content) => {
           // call your external service(ex: 2captcha) here and return the captcha response
          const captchaResponse = await 2captchaSolver(siteKey, url);
          return captchaResponse;
      }
    });
    console.log(response);
  } catch (error) {
    console.log(error);
  }
})();

Also don't forget to reuse your cookie if you don't want to have to solve captcha every time.

Revadike commented 4 years ago

You can also try this: https://github.com/JimmyLaurent/cloudflare-scraper/issues/4#issuecomment-645750464