dapphp / TorUtils

PHP classes for interacting with Tor over the control protocol, querying directory authorities and servers, and DNS exit lists.
BSD 3-Clause "New" or "Revised" License
71 stars 9 forks source link

Build Status Total Downloads Latest Stable Version

Name:

Dapphp\TorUtils - Classes for interacting with Tor over the control protocol, querying directory authorities and servers, DNS exit lists, a curl wrapper that makes it easy to use Tor's SOCKS proxy, and more.

Version:

1.15.3

Author:

Drew Phillips drew@drew-phillips.com

Requirements:

Description:

Dapphp\TorUtils provides some PHP libraries for working with Tor. The main functionality focuses on interacting with Tor using the Tor control protocol and provides many methods to make it easy to send commands, retrieve directory and node information, and modify Tor's configuration using the control protocol. A few other utility classes are provided for robustness.

The following classes are provided:

Basic Example:

This library provides a lot of different functionality (see examples directory) and a wide range of possibility but a common use case is sending a signal to the Tor controller to change IP addresses. This shows how to do just that:

<?php

require_once 'vendor/autoload.php'; // using composer

use Dapphp\TorUtils\ControlClient;

$tc = new ControlClient();

try {
    $tc->connect(); // connect to 127.0.0.1:9051
    $tc->authenticate('password'); // can also use cookie or empty auth
    $tc->signal(ControlClient::SIGNAL_NEWNYM);
    echo "Signal sent - IP changed successfully!\n";
} catch (\Exception $ex) {
    echo "Signal failed: " . $ex->getMessage() . "\n";
}

Examples:

The source package comes with several examples of interacting with the Tor control protocol and directory authorities. See the examples/ directory in the source package.

Currently, the following examples are provided:

TODO:

The following commands are not directly implemented by ControlClient and would need to be implemented or the implementation could communicate directly with the controller using the provided functions to issue commands:

Copyright:

Copyright (c) 2022 Drew Phillips
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Donate:

BTC: 1dJyNBaKBqRXVVMw5uVPyz7M3tMrh3gU2 ETH: 0x51A1057D485da13fB9C37C8ed3C5B3BA59e950D1 Flattr: OpenInternet