Skip to main content

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.

Metadata

Release files for privacypass 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for privacypass 0.2.2
File Size Uploaded Provenance Actions
privacypass-0.2.2.tar.gz 155.8 kB Without provenance Details for privacypass-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for privacypass 0.2.2
File Interpreter ABI Platform Actions
privacypass-0.2.2-py3-none-any.whl Python 3 none any Details for privacypass-0.2.2-py3-none-any.whl

Total release size: 161.5 kB

Release files / privacypass-0.2.2.tar.gz

Download URL privacypass-0.2.2.tar.gz
Size 155.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4cd7ef2a1ad80c50171dab699ad5efaef2b9e084941e1feca7ecd50e5dd0f902
BLAKE2b-256 checksum
How to use checksums
ac54ce47cc18492d17ec41bb3580f68843d5228ba16362698b6e37d44bb1e366
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.8

Release files / privacypass-0.2.2-py3-none-any.whl

Download URL privacypass-0.2.2-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5aacb8bce19f8479b5482f8c8e417b184ba866821c5bad437b43c1d873e50b5a
BLAKE2b-256 checksum
How to use checksums
63e9d40a691fcdce445989adf178b387cd1a39142a61c42d25bd6fb48b84ca93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.8

Security for privacypass 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page