vvanglro / cf-clearance

Purpose To make a cloudflare v2 challenge pass successfully, Can be use cf_clearance bypassed by cloudflare, However, with the cf_clearance, make sure you use the same IP and UA as when you got it.
https://github.com/vvanglro/cf_clearance
353 stars 58 forks source link

cookies中找不到cf_clearance #22

Closed youminxue closed 1 year ago

youminxue commented 1 year ago

image

vvanglro commented 1 year ago

可能是没有通过挑战, 增加再次尝试.

youminxue commented 1 year ago

代码去掉了proxy,本地开vpn,是不是因为这个,下面是代码

youminxue commented 1 year ago

from playwright.sync_api import sync_playwright from cf_clearance import sync_cf_retry, sync_stealth import requests

not use cf_clearance, cf challenge is fail

proxies = { "all": "socks5://localhost:7890" } res = requests.get('https://nowsecure.nl') if 'Please Wait... | Cloudflare' in res.text: print("cf challenge fail")

get cf_clearance

with sync_playwright() as p: browser = p.chromium.launch(headless=False) page = browser.new_page() sync_stealth(page, pure=True) page.goto('https://nowsecure.nl') res = sync_cf_retry(page) if res: cookies = page.context.cookies() for cookie in cookies: if cookie.get('name') == 'cf_clearance': cf_clearance_value = cookie.get('value') print(cf_clearance_value) ua = page.evaluate('() => {return navigator.userAgent}') print(ua) else: print("cf challenge fail") browser.close()

use cf_clearance, must be same IP and UA

headers = {"user-agent": ua} cookies = {"cf_clearance": cf_clearance_value} res = requests.get('https://nowsecure.nl', proxies=proxies, headers=headers, cookies=cookies) if 'Please Wait... | Cloudflare' not in res.text: print("cf challenge success")

vvanglro commented 1 year ago

刚测试日本节点代理不会有Cloudflare盾, 故没有cf_clearance. 可以开着vpn手动在浏览器里打开https://nowsecure.nl 看是否有5s盾.

nowanti commented 1 year ago

刚测试日本节点代理不会有Cloudflare盾, 故没有cf_clearance. 可以开着vpn手动在浏览器里打开https://nowsecure.nl 看是否有5s盾.

经测试,使用示例代码,非日本节点,无法通过cf盾,sync_cf_retry(page)=False

nowanti commented 1 year ago

刚测试日本节点代理不会有Cloudflare盾, 故没有cf_clearance. 可以开着vpn手动在浏览器里打开https://nowsecure.nl 看是否有5s盾.

经测试,使用势力代码,非日本节点,无法通过cf盾,sync_cf_retry(page)=False

1、使用 香港节点, 手动访问 https://nowsecure.nl 时,会触发5s盾,使用项目代码时触发,无法通过; 2、使用 香港节点, 手动访问 https://www.coinbase.com/ventures/content 时,不触发5s盾,使用项目代码时触发,无法通过。

使用该命令重新安装后最新版本后: pip install git+https://github.com/vvanglro/cf-clearance.git@main

1、https://nowsecure.nl 香港节点,手动会触发,使用项目代码时触发,可以自动通过,使用返回的cookies和ua,requests.get能通过; 2、https://www.coinbase.com/ventures/content 香港/新加坡/美国等节点,手动不触发,使用项目代码时不触发,使用返回的cookies和ua,requests.get不能通过;

vvanglro commented 1 year ago

最新代码中加入了点击确定是否是真人按钮的操作, 如果挑战过程中遇到按钮会自动点击. 此项目只针对cloudflare的v2 challenge.

youminxue commented 1 year ago

headless必须使用false吗

vvanglro commented 1 year ago

是的,可以配合Xvfb使用

youminxue commented 1 year ago

我试了国内也可以通过

KohnoseLami commented 1 year ago

Your target coinbase uses passive detection using tls fingerprints instead of JavaScript based tests like cf-clearance.

By using this tls-client you can avoid tls fingerprinting, but this module is just calling a dynamic library written in Go and the performance is terrible.

import tls_client

session = tls_client.Session(client_identifier='chrome_108')

response = session.get('https://www.coinbase.com/ventures/content')
print(response)
nowanti commented 1 year ago

Your target coinbase uses passive detection using tls fingerprints instead of JavaScript based tests like cf-clearance.

By using this tls-client you can avoid tls fingerprinting, but this module is just calling a dynamic library written in Go and the performance is terrible.

import tls_client

session = tls_client.Session(client_identifier='chrome_108')

response = session.get('https://www.coinbase.com/ventures/content')
print(response)

I see. Thank you for your guidance.

KohnoseLami commented 1 year ago

You're welcome, if you want to implement threading or async you need to learn Go or implement an HTTP client from scratch in Python.

This TLS fingerprint is provided to Cloudflare Enterprise, so if the JS challenge screen is not displayed and a 403 error is thrown, using this will usually solve it. Discord and ChatGPT, for example, also uses TLS fingerprinting.

youminxue commented 1 year ago

模拟调用chatgpt官网地址需要哪些步骤,使用cf-clearance和ua和ip还需要哪些条件,tls_client这个也需要吗

vvanglro commented 1 year ago

参考: https://github.com/acheong08/ChatGPT