Skip to content
/ Py-Tor Public

Enhance your online privacy with Tor network interaction, featuring IP address renewal and robust protection, and use it as a Tor proxy for HTTP requests.

Notifications You must be signed in to change notification settings

x404xx/Py-Tor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Py-Tor provides a simple and convenient way to interact with the Tor network, offering functionalities to renew IP addresses and ensure IP protection. This Python code demonstrates how to utilize the stem and requests libraries to achieve these tasks.

Prerequisites

Installation

To use Py-Tor, open your terminal and navigate to the folder that contains Py-Tor content ::

pip install -r requirements.txt

Example

from json import dumps

from services import TorService


with TorService() as tor:
    tor.local_ip #! Checking Local IP
    tor.tor_ip #! Checking Tor IP
    tor.checking_status #! Checking Tor status

    tor.renew_tor_ip #! Renew Tor IP
    tor.tor_ip #! Checking Tor IP again to confirm IP changed
    tor.checking_status #! Checking Tor status again to confirm using Tor

    result = {}

    #! GET Requests
    response_get = tor.get('https://httpbin.org/get')
    result['GET'] = response_get.json()

    #! GET Request with Query Parameters
    query_params = {'param1': 'value1', 'param2': 'value2'}
    response_query = tor.get('https://httpbin.org/get', params=query_params)
    result['QUERY'] = response_query.json()

    #! GET Requests with Custom Headers
    headers = {'Custom-Header': 'Custom-Value'}
    response_header = tor.get('https://httpbin.org/headers', headers=headers)
    result['HEADER'] = response_header.json()

    #! POST Request
    data = {'key': 'value'}
    response_post = tor.post('https://httpbin.org/post', json=data)
    result['POST'] = response_post.json()

    #! PUT Request
    data = {'updated_key': 'updated_value'}
    response_put = tor.put('https://httpbin.org/put', json=data)
    result['PUT'] = response_put.json()

    #! HEAD Request
    response_head = tor.head('https://httpbin.org/get')
    result['HEAD'] = dict(response_head.headers)

    #! OPTIONS Request
    response_options = tor.options("https://httpbin.org")
    result['OPTIONS'] = dict(response_options.headers)

    #! DELETE Request
    response_delete = tor.delete('https://httpbin.org/delete')
    result['DELETE'] = response_delete.json()

    #! PATCH Request
    data = {'key_to_update': 'new_value'}
    response_patch = tor.patch('https://httpbin.org/patch', json=data)
    result['PATCH'] = response_patch.json()

    #! Testing ONION URL (Facebook onion from https://www.expressvpn.com/blog/best-onion-sites-on-dark-web/)
    response_onion = tor.get('https://www.facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd.onion/')
    result['ONION'] = dict(response_onion.headers)

    print(dumps(result, indent=4))

Note

  • It's important to ensure that the path to the Tor executable (tor_path) is accurate for your system or just use the default.
  • This code does not handle Tor updates, potential network errors, or security considerations in a comprehensive manner. It's intended as a basic example to demonstrate the core functionality of interacting with Tor programmatically.

Legal Disclaimer

This was made for educational purposes only, nobody which directly involved in this project is responsible for any damages caused. You are responsible for your actions.

About

Enhance your online privacy with Tor network interaction, featuring IP address renewal and robust protection, and use it as a Tor proxy for HTTP requests.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages