Giter VIP home page Giter VIP logo

py-tor's Introduction

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.

py-tor's People

Contributors

x404xx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.