privacypass


Nameprivacypass JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/sergebakharev/privacypass
SummaryBypass Cloudflare's CAPTCHAs by redeming Privacy Pass tokens.
upload_time2024-04-07 23:08:41
maintainerNone
docs_urlNone
authorSerge Bakharev
requires_python>=3.9
licenseMIT
keywords cloudflare captcha scraping
VCS
bugtrack_url
requirements cffi cryptography pycparser
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Privacy Pass

[![Build Status](https://drone.sergeserge.com/api/badges/SergeBakharev/privacypass/status.svg)](https://drone.sergeserge.com/SergeBakharev/privacypass)
[![PyPI version](https://badge.fury.io/py/privacypass.svg)](https://badge.fury.io/py/privacypass)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![image](https://img.shields.io/pypi/pyversions/privacypass.svg)](https://pypi.org/project/privacypass/)

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](https://pypi.python.org/pypi/privacypass)

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

## Dependencies

* Python >= 3.9
* [cryptography](https://cryptography.io/) >= 36.0.1

## Usage

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

``` python
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](https://privacypass.github.io/) installed, and browsing to [captcha.website](https://captcha.website).

1. Solve a number of CAPTCHAs on [captcha.website](https://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](docs/firefox_tokens.png)

## Acknowledgements

This module is a porting of key functions from the [Privacy Pass Extension](https://github.com/privacypass/challenge-bypass-extension) by @privacypass team.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sergebakharev/privacypass",
    "name": "privacypass",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "cloudflare, captcha, scraping",
    "author": "Serge Bakharev",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/ac/54/ce47cc18492d17ec41bb3580f68843d5228ba16362698b6e37d44bb1e366/privacypass-0.2.2.tar.gz",
    "platform": null,
    "description": "# Privacy Pass\n\n[![Build Status](https://drone.sergeserge.com/api/badges/SergeBakharev/privacypass/status.svg)](https://drone.sergeserge.com/SergeBakharev/privacypass)\n[![PyPI version](https://badge.fury.io/py/privacypass.svg)](https://badge.fury.io/py/privacypass)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![image](https://img.shields.io/pypi/pyversions/privacypass.svg)](https://pypi.org/project/privacypass/)\n\nA 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.\n\n## Installation\n\nSimply run `pip install privacypass`. The PyPI package is at [pypi.python.org/pypi/privacypass](https://pypi.python.org/pypi/privacypass)\n\nAlternatively, clone this repository and run python setup.py install.\n\n## Dependencies\n\n* Python >= 3.9\n* [cryptography](https://cryptography.io/) >= 36.0.1\n\n## Usage\n\nCall `privacypass.redemption_token()` to create a redemption token specific to the site/path.\n\n``` python\nimport requests\nimport privacypass\n\n# See `Receiving Privacy Pass Tokens` section of doc for how to retrieve tokens\ncf_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=\"}}\n\nurl = 'https://somewhere.with.captcha'\nrequest = requests.get(url)\n\n# A Privacy Pass compatible CF site is encountered\n# and a CAPTCHA challenge is presented\nif request.status_code == 403 and 'CF-Chl-Bypass' in request.headers:\n    cf_redemption_header = privacypass.redemption_header(token=cf_token, url=url, method='GET')\n    request = requests_session.get(url, headers=cf_redemption_header)\n```\n\n## Troubleshooting Notes\n\n* Tokens have a limited life span. 30 days?\n* 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.\n\n## Receiving Privacy Pass Tokens\n\nCurrently the easiest way to receive tokens is by having the [Browser Extension](https://privacypass.github.io/) installed, and browsing to [captcha.website](https://captcha.website).\n\n1. Solve a number of CAPTCHAs on [captcha.website](https://captcha.website). Each CAPTCHA solved grants 30 tokens.\n2. Extract the tokens from your browser:\n\n    **Firefox**\n\n    1. Browse to the *Extension Debug screen* - (about:debugging#/runtime/this-firefox)\n    2. *Inspect* the *Privacy Pass* extension\n    3. Open Storage -> Local Storage\n    4. Tokens are stored as a list under the `cf-tokens` key.\n\n    ![FirefoxScreenshot](docs/firefox_tokens.png)\n\n## Acknowledgements\n\nThis module is a porting of key functions from the [Privacy Pass Extension](https://github.com/privacypass/challenge-bypass-extension) by @privacypass team.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Bypass Cloudflare's CAPTCHAs by redeming Privacy Pass tokens.",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/sergebakharev/privacypass"
    },
    "split_keywords": [
        "cloudflare",
        " captcha",
        " scraping"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "63e9d40a691fcdce445989adf178b387cd1a39142a61c42d25bd6fb48b84ca93",
                "md5": "a94e1e45340bd1d6d977185379a02064",
                "sha256": "5aacb8bce19f8479b5482f8c8e417b184ba866821c5bad437b43c1d873e50b5a"
            },
            "downloads": -1,
            "filename": "privacypass-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a94e1e45340bd1d6d977185379a02064",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 5736,
            "upload_time": "2024-04-07T23:08:38",
            "upload_time_iso_8601": "2024-04-07T23:08:38.577827Z",
            "url": "https://files.pythonhosted.org/packages/63/e9/d40a691fcdce445989adf178b387cd1a39142a61c42d25bd6fb48b84ca93/privacypass-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac54ce47cc18492d17ec41bb3580f68843d5228ba16362698b6e37d44bb1e366",
                "md5": "605942a0eb1e1e5513ebbdab44fdd30e",
                "sha256": "4cd7ef2a1ad80c50171dab699ad5efaef2b9e084941e1feca7ecd50e5dd0f902"
            },
            "downloads": -1,
            "filename": "privacypass-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "605942a0eb1e1e5513ebbdab44fdd30e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 155766,
            "upload_time": "2024-04-07T23:08:41",
            "upload_time_iso_8601": "2024-04-07T23:08:41.065622Z",
            "url": "https://files.pythonhosted.org/packages/ac/54/ce47cc18492d17ec41bb3580f68843d5228ba16362698b6e37d44bb1e366/privacypass-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-07 23:08:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sergebakharev",
    "github_project": "privacypass",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "cffi",
            "specs": [
                [
                    "==",
                    "1.16.0"
                ]
            ]
        },
        {
            "name": "cryptography",
            "specs": [
                [
                    "==",
                    "42.0.4"
                ]
            ]
        },
        {
            "name": "pycparser",
            "specs": [
                [
                    "==",
                    "2.22"
                ]
            ]
        }
    ],
    "lcname": "privacypass"
}
        
Elapsed time: 0.23759s