Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed cf new challenge solution #373

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

Sraq-Zit
Copy link

@Sraq-Zit Sraq-Zit commented Jun 20, 2020

There was mainly 3 problems:

  1. Value of jschl_vc token was taken from commented input element instead of the actual one
  2. The value of the div element with its ID as the variable k is split into multiple divs and numbered at the end of the ID for each div
  3. node: setInterval not defined. I removed that part from js code

Tested on:

EDIT
As of yesterday the tested websites are no more working, due to the new cf challenge.
The challenge lies within the script at the path that goes like example.com/cdn-cgi/challenge-platform/orchestrate/jsch/v1
Once the script is loaded and executed, the function _cf_chl_enter() is called.

I will try and see if I can automate the same process in python

@Sraq-Zit Sraq-Zit mentioned this pull request Jun 20, 2020
4 tasks
@mcronce
Copy link

mcronce commented Jun 21, 2020

I'm getting a failure when I install from your fork:

ERROR:root:Error executing Cloudflare IUAM Javascript. Cloudflare may have changed their technique, or there may be a bug in the script.

Please read https://github.com/Anorov/cloudflare-scrape#updates, then file a bug report at https://github.com/Anorov/cloudflare-scrape/issues."
ERROR:root:'https://www.iptorrents.com/login.php' returned an error. Could not collect tokens.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cfscrape/__init__.py", line 386, in get_tokens
    resp = scraper.get(url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python2.7/site-packages/cfscrape/__init__.py", line 129, in request
    resp = self.solve_cf_challenge(resp, **kwargs)
  File "/usr/lib/python2.7/site-packages/cfscrape/__init__.py", line 204, in solve_cf_challenge
    answer, delay = self.solve_challenge(body, domain)
  File "/usr/lib/python2.7/site-packages/cfscrape/__init__.py", line 331, in solve_challenge
    raise subprocess.CalledProcessError(node.returncode, "node -e ...", stderr)
subprocess.CalledProcessError: Command 'node -e ...' returned non-zero exit status 1

I'm going to try to manually run node and see if its output provides any clue as to why it's bombing out, will report back with results

@Sraq-Zit
Copy link
Author

Alright !

By the way, I tried it and it worked fine with me

image

@pilardo
Copy link

pilardo commented Jun 24, 2020

@Sraq-Zit i'm newbie. how can i update my local file?

@Sraq-Zit
Copy link
Author

@Sraq-Zit i'm newbie. how can i update my local file?

Reinstall it through this fork

pip install https://github.com/Sraq-Zit/cloudflare-scrape/archive/master.zip

challenge, ms = re.search(
r"setTimeout\(function\(\){\s*(var "
r"s,t,o,p,b,r,e,a,k,i,n,g,f.+?\r?\n[\s\S]+?a\.value\s*=.+?)\r?\n"
r"(?:[^{<>]*},\s*(\d{4,}))?",
r"s,t,o,p, b,r,e,a,k,i,n,g,f.+?\r?\n[\s\S]+?a\.value\s*=.+?)\r?\n"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR only works for me if I add ,cpo into this line, like:
r"s,t,o,p, b,r,e,a,k,i,n,g,cpo,f.+?\r?\n[\s\S]+?a\.value\s*=.+?)\r?\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR only works for me if I add ,cpo into this line, like:
r"s,t,o,p, b,r,e,a,k,i,n,g,cpo,f.+?\r?\n[\s\S]+?a\.value\s*=.+?)\r?\n"

It still don't work with me . Can you test this site ?
https://tubortaxdeal.com
https://www.aichoai.com

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird, the JS on those 2 sites looks really different, like it's not even minified or something. I wonder if they're using a different version of the cloudflare protection stuff?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR only works for me if I add ,cpo into this line, like:
r"s,t,o,p, b,r,e,a,k,i,n,g,cpo,f.+?\r?\n[\s\S]+?a\.value\s*=.+?)\r?\n"

It was added just recently for the websites I tested.
Thanks !

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR only works for me if I add ,cpo into this line, like:
r"s,t,o,p, b,r,e,a,k,i,n,g,cpo,f.+?\r?\n[\s\S]+?a\.value\s*=.+?)\r?\n"

It was added just recently for the websites I tested.
Thanks !

don't work for https://localbitcoins.net

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andress134
Copy link

I'm getting a failure when I install from your fork:

ERROR:root:Error executing Cloudflare IUAM Javascript. Cloudflare may have changed their technique, or there may be a bug in the script.

Please read https://github.com/Anorov/cloudflare-scrape#updates, then file a bug report at https://github.com/Anorov/cloudflare-scrape/issues."
ERROR:root:'https://www.iptorrents.com/login.php' returned an error. Could not collect tokens.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cfscrape/__init__.py", line 386, in get_tokens
    resp = scraper.get(url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python2.7/site-packages/cfscrape/__init__.py", line 129, in request
    resp = self.solve_cf_challenge(resp, **kwargs)
  File "/usr/lib/python2.7/site-packages/cfscrape/__init__.py", line 204, in solve_cf_challenge
    answer, delay = self.solve_challenge(body, domain)
  File "/usr/lib/python2.7/site-packages/cfscrape/__init__.py", line 331, in solve_challenge
    raise subprocess.CalledProcessError(node.returncode, "node -e ...", stderr)
subprocess.CalledProcessError: Command 'node -e ...' returned non-zero exit status 1

I'm going to try to manually run node and see if its output provides any clue as to why it's bombing out, will report back with results

I see cloudflare has updated again the default challenge for uam

@F170x
Copy link

F170x commented Jul 30, 2020

Doesn't work with: https://www.pexels.com/search/man/?format=js&seed=&page=2&type=
I don't know how to cloudflare detect between browser incognit mode and a python script, maybe with a difference in the headers or in the ssl protocol version?

@jaeakle
Copy link

jaeakle commented Aug 12, 2020

Did Cloudflare change again?
Im getting the error with this line as usual:
r"s,t,o,p, b,r,e,a,k,i,n,g,cpo,f.+?\r?\n[\s\S]+?a\.value\s*=.+?)\r?\n"

@rnyPlanet
Copy link

works today?

@andress134
Copy link

works today?

no

@rnyPlanet
Copy link

rnyPlanet commented Nov 4, 2020

@chanind @Sraq-Zit can you help update?

@hellcoder420
Copy link

can someone please continue the work of this pr

@ngooty
Copy link

ngooty commented Dec 28, 2020

Is there a solution for this problem. am stuck since a month to resolve this.

@rnyPlanet
Copy link

Is there a solution for this problem. am stuck since a month to resolve this.

Wow. and how are you getting on with the solution? I also tried but I have little knowledge ..

@ngooty
Copy link

ngooty commented Dec 28, 2020 via email

@ngooty
Copy link

ngooty commented Dec 28, 2020 via email

@andress134
Copy link

@Sraq-Zit is posible to fix v1 challenge again?
thanks

@hirios
Copy link

hirios commented Jan 9, 2022

+ 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet