Skip to main content

Bypass Cloudflare's CAPTCHAs by redeming Privacy Pass tokens.

Project description

Privacy Pass

Build Status PyPI version License: MIT image

A Python module implementing the Privacy Pass protocol. Privacy Pass is supported by Cloudflare (and is in the process of becoming standardised by the IETF) to enable users to redeem passes instead of having to solve CAPTCHAs to visit protected websites. This can be useful when programmatically interacting with such sites, as CAPTCHAs are intentionally used to tell Computers and Humans Apart.

Installation

Simply run pip install privacypass. The PyPI package is at pypi.python.org/pypi/privacypass

Alternatively, clone this repository and run python setup.py install.

Dependencies

Usage

Call privacypass.redemption_token() to create a redemption token specific to the site/path.

import requests
import privacypass

# See `Receiving Privacy Pass Tokens` section of doc for how to retrieve tokens
cf_token = {"input":[98,207,READACTED,234,181],"factor":"0x5c57a03...REDACTED..68ef47","blindedPoint":"BAV...REDACTED...dss=","unblindedPoint":"BOu0AArK..REDACTED..jdBbeqo=","signed":{"blindedPoint":"BPs6ed..REDACTED..0ZWw=","unblindedPoint":"BHtp..REDACTED..hU0="}}

url = 'https://somewhere.with.captcha'
request = requests.get(url)

# A Privacy Pass compatible CF site is encountered
# and a CAPTCHA challenge is presented
if request.status_code == 403 and 'CF-Chl-Bypass' in request.headers:
    cf_redemption_header = privacypass.redemption_header(token=cf_token, url=url, method='GET')
    request = requests_session.get(url, headers=cf_redemption_header)

Troubleshooting Notes

  • Tokens have a limited life span. 30 days?
  • Note the header in token redemption response 'CF-Chl-Bypass-Resp': '<error-resp>'. <error-resp> is the error value returned by the privacy pass verifier. Possible values are 5 or 6, where 5 is an edge-side connection error and 6 is a pass verification error.

Receiving Privacy Pass Tokens

Currently the easiest way to receive tokens is by having the Browser Extension installed, and browsing to captcha.website.

  1. Solve a number of CAPTCHAs on captcha.website. Each CAPTCHA solved grants 30 tokens.

  2. Extract the tokens from your browser:

    Firefox

    1. Browse to the Extension Debug screen - (about:debugging#/runtime/this-firefox)
    2. Inspect the Privacy Pass extension
    3. Open Storage -> Local Storage
    4. Tokens are stored as a list under the cf-tokens key.

    FirefoxScreenshot

Acknowledgements

This module is a porting of key functions from the Privacy Pass Extension by @privacypass team.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

privacypass-0.2.2.tar.gz (155.8 kB view details)

Uploaded Source

Built Distribution

privacypass-0.2.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file privacypass-0.2.2.tar.gz.

File metadata

  • Download URL: privacypass-0.2.2.tar.gz
  • Upload date:
  • Size: 155.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for privacypass-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4cd7ef2a1ad80c50171dab699ad5efaef2b9e084941e1feca7ecd50e5dd0f902
MD5 605942a0eb1e1e5513ebbdab44fdd30e
BLAKE2b-256 ac54ce47cc18492d17ec41bb3580f68843d5228ba16362698b6e37d44bb1e366

See more details on using hashes here.

File details

Details for the file privacypass-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: privacypass-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for privacypass-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5aacb8bce19f8479b5482f8c8e417b184ba866821c5bad437b43c1d873e50b5a
MD5 a94e1e45340bd1d6d977185379a02064
BLAKE2b-256 63e9d40a691fcdce445989adf178b387cd1a39142a61c42d25bd6fb48b84ca93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page