{ "info": { "author": "James Brown", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "Torpy ![Python Versions] [![Build Status](https://travis-ci.com/torpyorg/torpy.svg?branch=master)](https://travis-ci.com/torpyorg/torpy) [![Build status](https://ci.appveyor.com/api/projects/status/14l6t8nq4tvno1pg?svg=true)](https://ci.appveyor.com/project/jbrown299/torpy) [![Coverage Status](https://coveralls.io/repos/github/torpyorg/torpy/badge.svg?branch=master)](https://coveralls.io/github/torpyorg/torpy?branch=master)\n=====\n\nA pure python Tor client implementation of the Tor protocol.\nTorpy can be used to communicate with clearnet hosts or hidden services through the [Tor Network](https://torproject.org/about/overview.html).\n\n**Features**\n- No Stem or official Tor client required\n- Support v2 hidden services ([v2 specification](https://gitweb.torproject.org/torspec.git/tree/rend-spec-v2.txt))\n- Support *Basic* and *Stealth* authorization protocol\n- Provide simple TorHttpAdapter for [requests](https://requests.readthedocs.io/) library\n- Provide simple Socks5 proxy\n\n**Note:** This product is produced independently from the Tor\u00ae anonymity software and carries no guarantee from [The Tor Project](https://www.torproject.org/) about quality, suitability or anything else.\n\nConsole examples\n-----------\nThere are several console utilities to test the client.\n\nA simple HTTP/HTTPS request:\n```bash\n$ torpy_cli --url https://ifconfig.me --header \"User-Agent\" \"curl/7.37.0\"\nLoading cached NetworkStatusDocument from TorCacheDirStorage: .local/share/torpy/network_status\nConnecting to guard node 194.55.15.222:9001 (Haggar; Tor 0.4.0.5)...\nSending: GET https://ifconfig.me\nCreating new circuit #80000001 with 194.55.15.222:9001 (Haggar; Tor 0.4.0.5) router...\nBuilding 3 hops circuit...\nExtending the circuit #80000001 with 104.244.79.131:8443 (slalix; Tor 0.4.0.5)...\nExtending the circuit #80000001 with 185.220.102.4:80 (dorrisdeebrown; Tor 0.4.2.1-alpha)...\nCreating stream #1 attached to #80000001 circuit...\nStream #1: connecting to ('ifconfig.me', 443)\nResponse status: 200\n> 185.220.102.4\nStream #1: closing...\nClosing guard connections...\nDestroy circuit #80000001\n```\n\nCreate Socks5 proxy to relay requests via the Tor Network:\n```\n$ torpy_socks -p 1050 --hops 3\nLoading cached NetworkStatusDocument from TorCacheDirStorage: .local/share/torpy/network_status\nConnecting to guard node 89.142.75.60:9001 (spongebobness; Tor 0.3.5.8)...\nCreating new circuit #80000001 with 89.142.75.60:9001 (spongebobness; Tor 0.3.5.8) router...\nBuilding 3 hops circuit...\nExtending the circuit #80000001 with 185.248.143.42:9001 (torciusv; Tor 0.3.5.8)...\nExtending the circuit #80000001 with 158.174.122.199:9005 (che1; Tor 0.4.1.6)...\nStart socks proxy at 127.0.0.1:1050\n...\n```\n\nTorpy module also has a command-line interface:\n\n```bash\n$ python3.7 -m torpy --url https://facebookcorewwwi.onion --to-file index.html\nLoading cached NetworkStatusDocument from TorCacheDirStorage: .local/share/torpy/network_status\nConnecting to guard node 185.2.31.8:443 (cx10TorServer; Tor 0.4.0.5)...\nSending: GET https://facebookcorewwwi.onion\nCreating new circuit #80000001 with 185.2.31.8:443 (cx10TorServer; Tor 0.4.0.5) router...\nBuilding 3 hops circuit...\nExtending the circuit #80000001 with 144.172.71.110:8447 (TonyBamanaboni; Tor 0.4.1.5)...\nExtending the circuit #80000001 with 179.43.134.154:9001 (father; Tor 0.4.0.5)...\nCreating stream #1 attached to #80000001 circuit...\nStream #1: connecting to ('facebookcorewwwi.onion', 443)\nExtending #80000001 circuit for hidden service facebookcorewwwi.onion...\nRendezvous established (CellRelayRendezvousEstablished())\nIterate over responsible dirs of the hidden service\nIterate over introduction points of the hidden service\nCreate circuit for hsdir\nCreating new circuit #80000002 with 185.2.31.8:443 (cx10TorServer; Tor 0.4.0.5) router...\nBuilding 0 hops circuit...\nExtending the circuit #80000002 with 132.248.241.5:9001 (toritounam; Tor 0.3.5.8)...\nCreating stream #2 attached to #80000002 circuit...\nStream #2: connecting to hsdir\nStream #2: closing...\nDestroy circuit #80000002\nCreating new circuit #80000003 with 185.2.31.8:443 (cx10TorServer; Tor 0.4.0.5) router...\nBuilding 0 hops circuit...\nExtending the circuit #80000003 with 88.198.17.248:8443 (bauruine31; Tor 0.4.1.5)...\nIntroduced (CellRelayIntroduceAck())\nDestroy circuit #80000003\nCreating stream #3 attached to #80000001 circuit...\nStream #3: connecting to ('www.facebookcorewwwi.onion', 443)\nExtending #80000001 circuit for hidden service facebookcorewwwi.onion...\nResponse status: 200\nWriting to file index.html\nStream #1: closing...\nStream #3: closing...\nClosing guard connections...\nDestroy circuit #80000001\n```\n\nUsage examples \n-----------\n\nA basic example of how to send some data to a clearnet host or a hidden service:\n```python\nfrom torpy import TorClient\n\nhostname = 'ifconfig.me' # It's possible use onion hostname here as well\ntor = TorClient()\n# Choose random guard node and create 3-hops circuit\nwith tor.create_circuit(3) as circuit:\n # Create tor stream to host\n with circuit.create_stream((hostname, 80)) as stream:\n # Now we can communicate with host\n stream.send(b'GET / HTTP/1.0\\r\\nHost: %s\\r\\n\\r\\n' % hostname.encode())\n recv = stream.recv(1024)\n```\n\nTorHttpAdapter is a convenient Tor adapter for the [requests library](https://2.python-requests.org/en/master/user/advanced/#transport-adapters).\nThe following example shows the usage of TorHttpAdapter for multi-threaded HTTP requests:\n```python\nfrom multiprocessing.pool import ThreadPool\nfrom torpy.http.requests import tor_requests_session\n\nwith tor_requests_session() as s: # returns requests.Session() object\n links = ['http://nzxj65x32vh2fkhk.onion', 'http://facebookcorewwwi.onion'] * 2\n\n with ThreadPool(3) as pool:\n pool.map(s.get, links)\n\n```\n\nFor more examples see [test_integration.py](https://github.com/torpyorg/torpy/blob/master/tests/integration/test_integration.py)\n\n\nInstallation\n------------\n* `pip3 install torpy`\n\n\nContribute\n----------\n* Use It\n* Code review is appreciated\n* Open [Issue], send [PR]\n\n\nTODO\n----\n- [ ] Implement v3 hidden services [specification](https://gitweb.torproject.org/torspec.git/tree/rend-spec-v3.txt)\n- [ ] Refactor Tor cells serialization/deserialization\n- [ ] More unit tests\n- [ ] Rewrite the library using asyncio\n- [ ] Implement onion services\n\n\nLicense\n-------\nLicensed under the Apache License, Version 2.0\n\n\nReferences\n----------\n- Official [Tor](https://gitweb.torproject.org/tor.git/) client\n- [Pycepa](https://github.com/pycepa/pycepa)\n- [TorPylle](https://github.com/cea-sec/TorPylle)\n- [TinyTor](https://github.com/Marten4n6/TinyTor)\n- C++ Windows only implementation [Mini-tor](https://github.com/wbenny/mini-tor)\n- Nice Java implementation [Orchid](https://github.com/subgraph/Orchid)\n\n\n[Python Versions]: https://img.shields.io/badge/python-3.6,%203.7,%203.8-blue.svg\n[Issue]: https://github.com/torpyorg/torpy/issues\n[PR]: https://github.com/torpyorg/torpy/pulls", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/torpyorg/torpy", "keywords": "python proxy anonymity privacy socks tor protocol onion hiddenservice", "license": "", "maintainer": "", "maintainer_email": "", "name": "torpy", "package_url": "https://pypi.org/project/torpy/", "platform": "", "project_url": "https://pypi.org/project/torpy/", "project_urls": { "Bug Reports": "https://github.com/torpyorg/torpy/issues", "Homepage": "https://github.com/torpyorg/torpy", "Source": "https://github.com/torpyorg/torpy/" }, "release_url": "https://pypi.org/project/torpy/1.0.8/", "requires_dist": null, "requires_python": ">=3.6", "summary": "Pure python tor protocol implementation", "version": "1.0.8" }, "last_serial": 6001222, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "90128b6a528b8ff156ff2e0148b7c7a1", "sha256": "7aa141d91420098057f032e0cbccef0f033acbfce261100d679c01fb941614f5" }, "downloads": -1, "filename": "torpy-1.0.1.tar.gz", "has_sig": false, "md5_digest": "90128b6a528b8ff156ff2e0148b7c7a1", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 43534, "upload_time": "2019-07-18T07:49:07", "url": "https://files.pythonhosted.org/packages/99/6d/b7f93bc6935813af9c46087d417124b102a9b3e095b4d5e6dba0fa3028af/torpy-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "cfc81c5520406d90faba9c93375f16a2", "sha256": "37d8d7227163062060ccfe1c84253d69499782085483a4c3a75342c10f943d79" }, "downloads": -1, "filename": "torpy-1.0.2.tar.gz", "has_sig": false, "md5_digest": "cfc81c5520406d90faba9c93375f16a2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 69341, "upload_time": "2019-08-13T09:27:26", "url": "https://files.pythonhosted.org/packages/c3/d4/93d0d858391a49346e7f6571402159cd334b4dcb7c189e825ee7492ffd75/torpy-1.0.2.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "9b17dae2f8cf04d1547ed56336132f82", "sha256": "5d3f54e4f876bdc6b0630cccb4e49e6e5cf4a337e6c78edaacb9312d13355b9b" }, "downloads": -1, "filename": "torpy-1.0.4.tar.gz", "has_sig": false, "md5_digest": "9b17dae2f8cf04d1547ed56336132f82", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 71702, "upload_time": "2019-09-30T09:14:43", "url": "https://files.pythonhosted.org/packages/46/54/0f54b2adc5bde454c6f54cf750da5fddd2ca2ee6226068d37e56bed85385/torpy-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "38c864161c02b3a6e29f82af1164082e", "sha256": "65b0a5ccebd744e5222d26927f3c35c30be9fa0e73a57102aa12a4a880e488e2" }, "downloads": -1, "filename": "torpy-1.0.5.tar.gz", "has_sig": false, "md5_digest": "38c864161c02b3a6e29f82af1164082e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 71732, "upload_time": "2019-10-11T16:00:00", "url": "https://files.pythonhosted.org/packages/d3/71/d5259b4f35e57860fa208fa8c3445f194152bdac384d7507ed7ba0ded794/torpy-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "bf9ce25e011f39db7b21909f4136237c", "sha256": "05d982e95bd13a6214b8d90d26d5be39fcfc1cbd8c01553300f5bc955602ffd7" }, "downloads": -1, "filename": "torpy-1.0.6.tar.gz", "has_sig": false, "md5_digest": "bf9ce25e011f39db7b21909f4136237c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 72571, "upload_time": "2019-10-15T08:59:59", "url": "https://files.pythonhosted.org/packages/3e/ea/9da7b8db7f372730d1c7f74c76d71b00f11d88b7179a7cd3bd9dd36663b9/torpy-1.0.6.tar.gz" } ], "1.0.7": [ { "comment_text": "", "digests": { "md5": "ef31522488bdf135bc041fe0e19d6294", "sha256": "7c3ceeec1cc829c6fb1bd25a61d2f7419af6ded5a396b70f9a0846eb664b4c4b" }, "downloads": -1, "filename": "torpy-1.0.7.tar.gz", "has_sig": false, "md5_digest": "ef31522488bdf135bc041fe0e19d6294", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 71089, "upload_time": "2019-10-17T10:40:23", "url": "https://files.pythonhosted.org/packages/74/94/dbdcd8cdecb321c950ef3869002d0148309727212eb7666d36502e7d9ddd/torpy-1.0.7.tar.gz" } ], "1.0.8": [ { "comment_text": "", "digests": { "md5": "7ed3efa1db2a427f1b41eddf331e8359", "sha256": "12cd0c32f11ba32d73dace232569849f7fa3ddf9767ccb5c656498113b448b1e" }, "downloads": -1, "filename": "torpy-1.0.8.tar.gz", "has_sig": false, "md5_digest": "7ed3efa1db2a427f1b41eddf331e8359", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 71122, "upload_time": "2019-10-19T22:36:23", "url": "https://files.pythonhosted.org/packages/94/4e/ba7e7d87c92bcb90b3d557956fc9b061bd1ff00a38734a8b84e6f86686ab/torpy-1.0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7ed3efa1db2a427f1b41eddf331e8359", "sha256": "12cd0c32f11ba32d73dace232569849f7fa3ddf9767ccb5c656498113b448b1e" }, "downloads": -1, "filename": "torpy-1.0.8.tar.gz", "has_sig": false, "md5_digest": "7ed3efa1db2a427f1b41eddf331e8359", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 71122, "upload_time": "2019-10-19T22:36:23", "url": "https://files.pythonhosted.org/packages/94/4e/ba7e7d87c92bcb90b3d557956fc9b061bd1ff00a38734a8b84e6f86686ab/torpy-1.0.8.tar.gz" } ] }