I would like to force TOR change the IP on every request. Or at least every few seconds.
Also, it would be great if the solution will work both on Linux and Windows.
Anyone knows how can I achieve this?
I found this PHP code which claims to be what I am looking for but I cannot understand what it is doing.
<?php
$fp = fsockopen('127.0.0.1', 9051, $errno, $errstr, 30);
$auth_code = 'YOUR_PASSWORD';
if ($fp) {
echo "Connected to TOR port<br />";
}
else {
echo "Cant connect to TOR port<br />";
}
fputs($fp, "AUTHENTICATE \"".$auth_code."\"\r\n");
$response = fread($fp, 1024);
list($code, $text) = explode(' ', $response, 2);
if ($code = '250') {
echo "Authenticated 250 OK<br />";
}
else {
echo "Authentication failed<br />";
}
fputs($fp, "SIGNAL NEWNYM\r\n");
$response = fread($fp, 1024);
list($code, $text) = explode(' ', $response, 2);
if ($code = '250') {
echo "New Identity OK<br />";
}
else {
echo "SIGNAL NEWNYM failed<br />";
die();
}
fclose($fp);
?>
Somebody?
It connects via Socket to your local tor relay, authenticates and sends a SIGNAL NEWNYM, which forces the tor relay to change the identity and exit node.
See more at
identity changing in tor
tor options
There is even a SE site about tor.
Related
I think I came down to a very specific PHP bug, that the timeouts set by stream_set_timeout() doesn't get obeyed, ONLY if using SSL websockets.
I am able to reproduce it with the following simple script:
<?php
$context = stream_context_create();
$fp = stream_socket_client ("ssl://echo.websocket.org:443",$errno,$errstr,5,STREAM_CLIENT_CONNECT,$context);
stream_set_timeout($fp, 5);
if (!$fp) {
echo "Unable to open\n";
} else {
//fwrite($fp, "GET / HTTP/1.0\r\n\r\n");
stream_set_timeout($fp, 5);
$res = fread($fp, 2000);
$info = stream_get_meta_data($fp);
//fclose($fp);
if ($info['timed_out']) {
echo 'Connection timed out!';
} else {
echo $res;
}
}
If you switch out ssl://echo.websocket.org:443 with tcp://echo.websocket.org:80, the timeout gets triggered correctly after 5 seconds.
Is this a PHP bug or am I missing some sort of setting?
I'm working on a Server list viewer
and somebody told me that i should use UdpSocket to send data to the master server and receive data from it (in this case for MW2-IW4 game)
So this is the command or the socket you use
"\xff\xff\xff\getservers IW4 <MASTERSERVERPORTHERE> full empty\x00"
so i tried to work with this code
<?php
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$msg = "\xff\xff\xff\getservers IW4 <MASTERSERVERPORT> full empty\x00";
$len = strlen($msg);
socket_sendto($sock, $msg, $len, 0, 'MASTERSERVERIP' , 1223);
socket_close($sock);
?>
but didn't receive any data , just getting the number 36 ...
PS:
i don't know much things about sockets.
i figured out how to do it a while ago and remembered this post, if anybody is still interested, this is how you do it:
<?php
$ip = "127.0.0.1";
$port = 1337;
$socket = fsockopen('udp://'.$ip, $port);
stream_set_blocking($socket, 0);
stream_set_timeout($socket, 1); //1 = timeout
fwrite($socket, "YOUR UDP COMMAND HERE\n");
$time=time()+1; //1=timeout
$returned = "";
while($time > time()) {
$returned .= fgets($socket);
}
echo($returned); // the returned value
#fclose($socket); //we are done, so better close it.
?>
Just use fsockopen it's a lot easier,
$fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr);
if (!$fp) echo "ERROR: $errno - $errstr<br />\n";
fwrite($fp, "\n");
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
I want to read some phrases from an external website which protocol is https.
I've do this for websites with http protocol by this code:
$homepage = file_get_contents('https://www.examlple.com/');
echo $homepage;
but it does not work for https sites. then I used this one:
$fp = fsockopen("https://www.example.com/", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
fwrite($fp, "Data sent by socket");
$content = "";
while (!feof($fp)) { //This looped forever
$content .= fread($fp, 1024);
}
fclose($fp);
echo $content;
}
but I always get an error:
Unable to find the socket transport "http" - did you forget to enable
it when you configured PHP? (2)
actualy the case is to fetch my site's statistics from analytics.
Fsockopen does not know about "http, https". Please remove the http part from your domain and use SSL Port for connection.
See example, this should work:
// open ssl connection - dont add "http or https!"
$host = "ssl://" . "example.com";
$port = 443;
$fp = fsockopen($host,$port);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
fwrite($fp, "Data sent by socket");
$content = "";
while (!feof($fp)) { //This looped forever
$content .= fread($fp, 1024);
}
fclose($fp);
echo $content;
}
Hi I'm trying to write a client-server function. I've written part of the code from the client side asking the server to login, I now need some simple code to start me off that I could use as a response from the server.
Client code:
<?php
$fp = fsockopen("XXXX.XXXXX.com", 1980, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "<UserStatus timestamp='0' type='login' UserID='####' key='XXXX' /> \r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
Please can some give me an example of some code.
I connect to an application for a push/stream data.
With the following code I have a right answer from the app (outcome=OK|item=THEITEM) but can't figure out how to get the var "last_value" and its updates.
The loop is commented out, I have no echo with it (loop)
$port = ('5333');
$address = ('127.0.0.1');
$fp = stream_socket_client("tcp://$address:$port", $errno, $errstr, 1);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$in = "function=subscribe|item=THEITEM|schema=last_value";
fwrite($fp, $in."\n");
//while (!feof($fp)) {
echo fgets($fp, 1024);
//}
fclose($fp);
}
This returns outcome=OK|item=THEITEM.
The updates should be like THEITEM|last_value.