forked from Bit-Wasp/node-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtor.php
40 lines (27 loc) · 785 Bytes
/
tor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require "vendor/autoload.php";
function parseKeys(&$results, $string) {
list ($key, $value) = explode("=", $string);
$results[$key] = $value;
}
// Connect to the TOR server using password authentication
$tc = new TorControl\TorControl(
array(
'hostname' => 'localhost',
'port' => 9051,
'password' => 'testtesttesttesttesttest',
'authmethod' => 1
)
);
$tc->connect();
$tc->authenticate();
// Renew identity
//$res = $tc->executeCommand('SIGNAL NEWNYM');
$privateKey = 'NEW:BEST';
$res = $tc->executeCommand('ADD_ONION '.$privateKey.' Port=1234,127.0.0.1:1234');
$parsed = [];
parseKeys($parsed, $res[0]['message']);
parseKeys($parsed, $res[1]['message']);
echo $parsed['ServiceID'] . ".onion";
// Quit
$tc->quit();